From 951aa03a780d11f57cd4f9b0f6fded1967c766c2 Mon Sep 17 00:00:00 2001 From: DrDisagree Date: Tue, 26 Sep 2023 19:04:54 +0600 Subject: [PATCH] Fix CentralSurfacesImpl ClassNotFoundException for A12L --- .../iconify/xposed/mods/QSBlackTheme.java | 76 ++++++++++--------- .../iconify/xposed/mods/QSFluidTheme.java | 29 +++---- .../iconify/xposed/mods/QSLightTheme.java | 30 ++++---- 3 files changed, 72 insertions(+), 63 deletions(-) diff --git a/app/src/main/java/com/drdisagree/iconify/xposed/mods/QSBlackTheme.java b/app/src/main/java/com/drdisagree/iconify/xposed/mods/QSBlackTheme.java index 3fbe11103..94b864b12 100644 --- a/app/src/main/java/com/drdisagree/iconify/xposed/mods/QSBlackTheme.java +++ b/app/src/main/java/com/drdisagree/iconify/xposed/mods/QSBlackTheme.java @@ -89,7 +89,7 @@ public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) { Class InterestingConfigChangesClass = findClass("com.android.settingslib.applications.InterestingConfigChanges", lpparam.classLoader); Class ScrimStateEnum = findClass(SYSTEMUI_PACKAGE + ".statusbar.phone.ScrimState", lpparam.classLoader); Class QSIconViewImplClass = findClass(SYSTEMUI_PACKAGE + ".qs.tileimpl.QSIconViewImpl", lpparam.classLoader); - Class CentralSurfacesImplClass = findClass(SYSTEMUI_PACKAGE + ".statusbar.phone.CentralSurfacesImpl", lpparam.classLoader); + Class CentralSurfacesImplClass = findClassIfExists(SYSTEMUI_PACKAGE + ".statusbar.phone.CentralSurfacesImpl", lpparam.classLoader); Class ClockClass = findClass(SYSTEMUI_PACKAGE + ".statusbar.policy.Clock", lpparam.classLoader); Class QuickStatusBarHeaderClass = findClass(SYSTEMUI_PACKAGE + ".qs.QuickStatusBarHeader", lpparam.classLoader); Class BrightnessControllerClass = findClass(SYSTEMUI_PACKAGE + ".settings.brightness.BrightnessController", lpparam.classLoader); @@ -124,32 +124,34 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { Class ShadeHeaderControllerClass = findClassIfExists(SYSTEMUI_PACKAGE + ".shade.ShadeHeaderController", lpparam.classLoader); //QPR2 if (ShadeHeaderControllerClass == null) - ShadeHeaderControllerClass = findClass(SYSTEMUI_PACKAGE + ".shade.LargeScreenShadeHeaderController", lpparam.classLoader); + ShadeHeaderControllerClass = findClassIfExists(SYSTEMUI_PACKAGE + ".shade.LargeScreenShadeHeaderController", lpparam.classLoader); Class QSContainerImplClass = findClass(SYSTEMUI_PACKAGE + ".qs.QSContainerImpl", lpparam.classLoader); - hookAllMethods(ShadeHeaderControllerClass, "onInit", new XC_MethodHook() { - @Override - protected void afterHookedMethod(MethodHookParam param) throws Throwable { - try { - View mView = (View) getObjectField(param.thisObject, "mView"); - Object iconManager = getObjectField(param.thisObject, "iconManager"); - Object batteryIcon = getObjectField(param.thisObject, "batteryIcon"); - Object configurationControllerListener = getObjectField(param.thisObject, "configurationControllerListener"); - - hookAllMethods(configurationControllerListener.getClass(), "onConfigChanged", new XC_MethodHook() { - @SuppressLint("DiscouragedApi") - @Override - protected void afterHookedMethod(MethodHookParam param) throws Throwable { - setHeaderComponentsColor(mView, iconManager, batteryIcon); - } - }); + if (ShadeHeaderControllerClass != null) { + hookAllMethods(ShadeHeaderControllerClass, "onInit", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + try { + View mView = (View) getObjectField(param.thisObject, "mView"); + Object iconManager = getObjectField(param.thisObject, "iconManager"); + Object batteryIcon = getObjectField(param.thisObject, "batteryIcon"); + Object configurationControllerListener = getObjectField(param.thisObject, "configurationControllerListener"); + + hookAllMethods(configurationControllerListener.getClass(), "onConfigChanged", new XC_MethodHook() { + @SuppressLint("DiscouragedApi") + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + setHeaderComponentsColor(mView, iconManager, batteryIcon); + } + }); - setHeaderComponentsColor(mView, iconManager, batteryIcon); - } catch (Throwable throwable) { - log(TAG + throwable); + setHeaderComponentsColor(mView, iconManager, batteryIcon); + } catch (Throwable throwable) { + log(TAG + throwable); + } } - } - }); + }); + } hookAllMethods(QSContainerImplClass, "updateResources", new XC_MethodHook() { @SuppressLint("DiscouragedApi") @@ -302,12 +304,21 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { } }); - hookAllConstructors(CentralSurfacesImplClass, new XC_MethodHook() { - @Override - protected void afterHookedMethod(MethodHookParam param) throws Throwable { - initColors(true); - } - }); + if (CentralSurfacesImplClass != null) { + hookAllConstructors(CentralSurfacesImplClass, new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + initColors(true); + } + }); + + hookAllMethods(CentralSurfacesImplClass, "updateTheme", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + initColors(false); + } + }); + } hookAllConstructors(QSTileViewImplClass, new XC_MethodHook() { @Override @@ -343,13 +354,6 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable { } }); - hookAllMethods(CentralSurfacesImplClass, "updateTheme", new XC_MethodHook() { - @Override - protected void afterHookedMethod(MethodHookParam param) throws Throwable { - initColors(false); - } - }); - try { mBehindColors = GradientColorsClass.getDeclaredConstructor().newInstance(); } catch (Throwable throwable) { diff --git a/app/src/main/java/com/drdisagree/iconify/xposed/mods/QSFluidTheme.java b/app/src/main/java/com/drdisagree/iconify/xposed/mods/QSFluidTheme.java index db49fdd0f..85af4a2fe 100644 --- a/app/src/main/java/com/drdisagree/iconify/xposed/mods/QSFluidTheme.java +++ b/app/src/main/java/com/drdisagree/iconify/xposed/mods/QSFluidTheme.java @@ -12,6 +12,7 @@ import static de.robv.android.xposed.XposedBridge.hookAllMethods; import static de.robv.android.xposed.XposedBridge.log; import static de.robv.android.xposed.XposedHelpers.findClass; +import static de.robv.android.xposed.XposedHelpers.findClassIfExists; import static de.robv.android.xposed.XposedHelpers.getIntField; import static de.robv.android.xposed.XposedHelpers.getObjectField; import static de.robv.android.xposed.XposedHelpers.setObjectField; @@ -99,7 +100,7 @@ public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) { Class QSTileViewImplClass = findClass(SYSTEMUI_PACKAGE + ".qs.tileimpl.QSTileViewImpl", lpparam.classLoader); Class QSIconViewImplClass = findClass(SYSTEMUI_PACKAGE + ".qs.tileimpl.QSIconViewImpl", lpparam.classLoader); Class FooterViewClass = findClass(SYSTEMUI_PACKAGE + ".statusbar.notification.row.FooterView", lpparam.classLoader); - Class CentralSurfacesImplClass = findClass(SYSTEMUI_PACKAGE + ".statusbar.phone.CentralSurfacesImpl", lpparam.classLoader); + Class CentralSurfacesImplClass = findClassIfExists(SYSTEMUI_PACKAGE + ".statusbar.phone.CentralSurfacesImpl", lpparam.classLoader); Class NotificationExpandButtonClass = findClass("com.android.internal.widget.NotificationExpandButton", lpparam.classLoader); Class BrightnessSliderViewClass = findClass(SYSTEMUI_PACKAGE + ".settings.brightness.BrightnessSliderView", lpparam.classLoader); Class BrightnessControllerClass = findClass(SYSTEMUI_PACKAGE + ".settings.brightness.BrightnessController", lpparam.classLoader); @@ -119,19 +120,21 @@ protected void beforeHookedMethod(MethodHookParam param) { } }); - hookAllConstructors(CentralSurfacesImplClass, new XC_MethodHook() { - @Override - protected void afterHookedMethod(MethodHookParam param) { - initResources(); - } - }); + if (CentralSurfacesImplClass != null) { + hookAllConstructors(CentralSurfacesImplClass, new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) { + initResources(); + } + }); - hookAllMethods(CentralSurfacesImplClass, "updateTheme", new XC_MethodHook() { - @Override - protected void afterHookedMethod(MethodHookParam param) { - initResources(); - } - }); + hookAllMethods(CentralSurfacesImplClass, "updateTheme", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) { + initResources(); + } + }); + } // QS tile color hookAllConstructors(QSTileViewImplClass, new XC_MethodHook() { diff --git a/app/src/main/java/com/drdisagree/iconify/xposed/mods/QSLightTheme.java b/app/src/main/java/com/drdisagree/iconify/xposed/mods/QSLightTheme.java index 5082f23bc..eceb54a81 100644 --- a/app/src/main/java/com/drdisagree/iconify/xposed/mods/QSLightTheme.java +++ b/app/src/main/java/com/drdisagree/iconify/xposed/mods/QSLightTheme.java @@ -100,7 +100,7 @@ public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) { Class InterestingConfigChangesClass = findClass("com.android.settingslib.applications.InterestingConfigChanges", lpparam.classLoader); Class ScrimStateEnum = findClass(SYSTEMUI_PACKAGE + ".statusbar.phone.ScrimState", lpparam.classLoader); Class QSIconViewImplClass = findClass(SYSTEMUI_PACKAGE + ".qs.tileimpl.QSIconViewImpl", lpparam.classLoader); - Class CentralSurfacesImplClass = findClass(SYSTEMUI_PACKAGE + ".statusbar.phone.CentralSurfacesImpl", lpparam.classLoader); + Class CentralSurfacesImplClass = findClassIfExists(SYSTEMUI_PACKAGE + ".statusbar.phone.CentralSurfacesImpl", lpparam.classLoader); Class ClockClass = findClass(SYSTEMUI_PACKAGE + ".statusbar.policy.Clock", lpparam.classLoader); Class QuickStatusBarHeaderClass = findClass(SYSTEMUI_PACKAGE + ".qs.QuickStatusBarHeader", lpparam.classLoader); @@ -293,12 +293,21 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable { } }); - hookAllConstructors(CentralSurfacesImplClass, new XC_MethodHook() { - @Override - protected void afterHookedMethod(MethodHookParam param) throws Throwable { - applyOverlays(true); - } - }); + if (CentralSurfacesImplClass != null) { + hookAllConstructors(CentralSurfacesImplClass, new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + applyOverlays(true); + } + }); + + hookAllMethods(CentralSurfacesImplClass, "updateTheme", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) throws Throwable { + applyOverlays(false); + } + }); + } hookAllConstructors(QSTileViewImplClass, new XC_MethodHook() { @Override @@ -346,13 +355,6 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { } }); - hookAllMethods(CentralSurfacesImplClass, "updateTheme", new XC_MethodHook() { - @Override - protected void afterHookedMethod(MethodHookParam param) throws Throwable { - applyOverlays(false); - } - }); - hookAllMethods(ScrimControllerClass, "updateThemeColors", new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable {