Skip to content
Permalink
Browse files

Fix Animation Control for Android 4.2

1) Somehow Android 4.2 throws MethodNotFoundError even though it
clearly exists. So I added a backup method in case of a throwable.

(Kept original because XposedHelpers.findAndHookMethod uses cachine
while hookAllMethods don't Animation Controls is run every activity
change is we need to prevent performance loss if possible)

2) JB has an extra boolean in setAnimation method
  • Loading branch information...
zst123 committed Dec 12, 2013
1 parent d7e0018 commit 5eb8b7f0b143ad9d30fcbfa54b8cf1ca19c7e59f
Showing with 44 additions and 18 deletions.
  1. +44 −18 src/com/zst/xposed/xuimod/mods/AnimationControlsMod.java
@@ -119,25 +119,47 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
} }


private static void hookloadAnimation_animAttr(LoadPackageParam o, Class<?> clazz) { private static void hookloadAnimation_animAttr(LoadPackageParam o, Class<?> clazz) {
XposedHelpers.findAndHookMethod(clazz, "loadAnimation", try {
WindowManager.LayoutParams.class, int.class, new XC_MethodHook(){ XposedHelpers.findAndHookMethod(clazz, "loadAnimation",
@Override WindowManager.LayoutParams.class, int.class, new XC_MethodHook() {
protected void beforeHookedMethod(MethodHookParam param) throws Throwable { @Override
int animAttr = (Integer) param.args[1]; protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
if (animAttr >= 0) { int animAttr = (Integer) param.args[1];
if (!mIsResId) return; if (animAttr >= 0) {

if (!mIsResId) return;
if (animAttr != 0) {
param.setResult(AnimationUtils.loadAnimation(mContext, animAttr)); if (animAttr != 0) {
}else{ param.setResult(AnimationUtils
param.setResult(null); .loadAnimation(mContext, animAttr));
} else {
param.setResult(null);
}
/* If it equals zero, return null and skip the method since we have
* to skip the getCachedAnimations if mIsResId is true
*/
} }
/* If it equals zero, return null and skip the method since we have
* to skip the getCachedAnimations if mIsResId is true
*/
} }
} });
}); } catch (Throwable e) {
XposedBridge.hookAllMethods(clazz, "loadAnimation", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
if (param.args.length != 2) return;
if (param.args[0] instanceof WindowManager.LayoutParams
&& param.args[1] instanceof Integer) {
int animAttr = (Integer) param.args[1];
if (animAttr >= 0) {
if (!mIsResId) return;
if (animAttr != 0) {
param.setResult(AnimationUtils.loadAnimation(mContext, animAttr));
} else {
param.setResult(null);
}
}
}
}
});
}
} }


// Checks API level // Checks API level
@@ -214,7 +236,11 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Animation anim = (Animation) animator.getClass().getDeclaredField("animation") Animation anim = (Animation) animator.getClass().getDeclaredField("animation")
.get(animator); .get(animator);
if (anim != null) { if (anim != null) {
XposedHelpers.callMethod(animator, "setAnimation", applyDuration(anim)); if ((Build.VERSION.SDK_INT <= 15)) {
XposedHelpers.callMethod(animator, "setAnimation", applyDuration(anim));
} else { // JB
XposedHelpers.callMethod(animator, "setAnimation", applyDuration(anim), false);
}
param.setResult(true); param.setResult(true);
} }
} }

0 comments on commit 5eb8b7f

Please sign in to comment.
You can’t perform that action at this time.