Skip to content

Commit

Permalink
Fix CentralSurfacesImpl ClassNotFoundException for A12L
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmud0808 committed Sep 26, 2023
1 parent 46fa2ac commit 951aa03
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 951aa03

Please sign in to comment.