From 657f8fb0e5683f9e1aab91ecb36e3c938e0f95ec Mon Sep 17 00:00:00 2001 From: DrDisagree Date: Fri, 15 Sep 2023 13:01:13 +0600 Subject: [PATCH] QS Transparency: Remove parameterized condition from hook method --- .../iconify/xposed/mods/QSTransparency.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/com/drdisagree/iconify/xposed/mods/QSTransparency.java b/app/src/main/java/com/drdisagree/iconify/xposed/mods/QSTransparency.java index 7f6104aed..88354aab2 100644 --- a/app/src/main/java/com/drdisagree/iconify/xposed/mods/QSTransparency.java +++ b/app/src/main/java/com/drdisagree/iconify/xposed/mods/QSTransparency.java @@ -5,13 +5,12 @@ import static com.drdisagree.iconify.common.Preferences.QSALPHA_LEVEL; import static com.drdisagree.iconify.common.Preferences.QS_TRANSPARENCY_SWITCH; import static com.drdisagree.iconify.config.XPrefs.Xprefs; -import static de.robv.android.xposed.XposedHelpers.findAndHookMethod; +import static de.robv.android.xposed.XposedBridge.hookAllMethods; import static de.robv.android.xposed.XposedHelpers.findClass; import static de.robv.android.xposed.XposedHelpers.findField; import static de.robv.android.xposed.XposedHelpers.getObjectField; import android.content.Context; -import android.view.View; import com.drdisagree.iconify.xposed.ModPack; @@ -42,26 +41,27 @@ public void updatePrefs(String... Key) { public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpParam) { if (!lpParam.packageName.equals(SYSTEMUI_PACKAGE)) return; - final Class ScrimController = findClass(SYSTEMUI_PACKAGE + ".statusbar.phone.ScrimController", lpParam.classLoader); + final Class ScrimControllerClass = findClass(SYSTEMUI_PACKAGE + ".statusbar.phone.ScrimController", lpParam.classLoader); - findAndHookMethod(ScrimController, "updateScrimColor", View.class, Integer.TYPE, Float.TYPE, new XC_MethodHook() { + hookAllMethods(ScrimControllerClass, "updateScrimColor", new XC_MethodHook() { protected void beforeHookedMethod(MethodHookParam param) throws Throwable { if (!qsTransparencyActive && !onlyNotifTransparencyActive) return; + int alphaIndex = param.args[2] instanceof Float ? 2 : 1; String scrimState = getObjectField(param.thisObject, "mState").toString(); if (scrimState.equals("KEYGUARD")) { - param.args[2] = 0.0f; + param.args[alphaIndex] = 0.0f; } else if (scrimState.contains("BOUNCER")) { - param.args[2] = (Float) param.args[2] * keyguard_alpha; + param.args[alphaIndex] = (Float) param.args[alphaIndex] * keyguard_alpha; } else { String scrimName = "unknown_scrim"; - if (findField(ScrimController, "mScrimInFront").get(param.thisObject).equals(param.args[0])) { + if (findField(ScrimControllerClass, "mScrimInFront").get(param.thisObject).equals(param.args[0])) { scrimName = "front_scrim"; - } else if (findField(ScrimController, "mScrimBehind").get(param.thisObject).equals(param.args[0])) { + } else if (findField(ScrimControllerClass, "mScrimBehind").get(param.thisObject).equals(param.args[0])) { scrimName = "behind_scrim"; - } else if (findField(ScrimController, "mNotificationsScrim").get(param.thisObject).equals(param.args[0])) { + } else if (findField(ScrimControllerClass, "mNotificationsScrim").get(param.thisObject).equals(param.args[0])) { scrimName = "notifications_scrim"; } @@ -71,7 +71,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable { break; } case "notifications_scrim": - param.args[2] = (Float) param.args[2] * alpha; + param.args[alphaIndex] = (Float) param.args[alphaIndex] * alpha; break; default: break;