diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarIcons.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarIcons.java index 3ee9f755..2d42fedb 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarIcons.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarIcons.java @@ -1,9 +1,6 @@ package it.dhd.oxygencustomizer.xposed.hooks.systemui.statusbar; -import static de.robv.android.xposed.XposedBridge.hookAllMethods; import static de.robv.android.xposed.XposedHelpers.callMethod; -import static de.robv.android.xposed.XposedHelpers.findAndHookMethod; -import static de.robv.android.xposed.XposedHelpers.findClass; import static de.robv.android.xposed.XposedHelpers.getObjectField; import static it.dhd.oxygencustomizer.utils.Constants.Packages.SYSTEM_UI; import static it.dhd.oxygencustomizer.xposed.XPrefs.Xprefs; @@ -13,9 +10,9 @@ import android.view.View; import android.widget.ImageView; -import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.callbacks.XC_LoadPackage; import it.dhd.oxygencustomizer.xposed.XposedMods; +import it.dhd.oxygencustomizer.xposed.utils.toolkit.ReflectedClass; public class StatusbarIcons extends XposedMods { @@ -36,72 +33,86 @@ public void updatePrefs(String... Key) { @Override public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { try { - Class OplusPhoneStatusBarPolicyExImpl; - try { - OplusPhoneStatusBarPolicyExImpl = findClass("com.oplus.systemui.statusbar.phone.OplusPhoneStatusBarPolicyExImpl", lpparam.classLoader); - } catch (Throwable t) { - OplusPhoneStatusBarPolicyExImpl = findClass("com.oplusos.systemui.statusbar.phone.PhoneStatusBarPolicyEx", lpparam.classLoader); - } + ReflectedClass OplusPhoneStatusBarPolicyExImpl = ReflectedClass.of( + "com.oplus.systemui.statusbar.phone.OplusPhoneStatusBarPolicyExImpl" /* OOS15-14 */, + "com.oplusos.systemui.statusbar.phone.PhoneStatusBarPolicyEx" /* OOS13 */); // private final void updateBluetoothIcon(int i, int i2, CharSequence charSequence, boolean z) { - findAndHookMethod(OplusPhoneStatusBarPolicyExImpl, "updateBluetoothIcon", - int.class, - int.class, - CharSequence.class, - boolean.class, new XC_MethodHook() { - @Override - protected void beforeHookedMethod(MethodHookParam param) throws Throwable { - boolean enabled = (boolean) param.args[3]; - - if (!enabled || !hideBluetooth) return; - - Object bluetoothController = getObjectField(param.thisObject, Build.VERSION.SDK_INT >= 34 ? "bluetoothController" : "mBluetooth"); - boolean connected = (boolean) callMethod(bluetoothController, "isBluetoothConnected"); - - if (!connected) - param.setResult(connected); - } - }); + OplusPhoneStatusBarPolicyExImpl + .before("updateBluetoothIcon") + .run(param -> { + boolean enabled = (boolean) param.args[3]; + + if (!enabled || !hideBluetooth) return; + + Object bluetoothController = getObjectField(param.thisObject, Build.VERSION.SDK_INT >= 34 ? "bluetoothController" : "mBluetooth"); + boolean connected = (boolean) callMethod(bluetoothController, "isBluetoothConnected"); + + if (!connected) + param.setResult(connected); + }); } catch (Throwable t) { - log("Class Not Found " + t.getMessage()); + log(t); } try { - Class OplusStatusBarSignalPolicyExImpl; - try { - OplusStatusBarSignalPolicyExImpl = findClass("com.oplus.systemui.statusbar.phone.signal.OplusStatusBarSignalPolicyExImpl", lpparam.classLoader); - } catch (Throwable t) { - OplusStatusBarSignalPolicyExImpl = findClass("com.oplusos.systemui.statusbar.phone.StatusBarSignalPolicyEx", lpparam.classLoader); + ReflectedClass OplusStatusBarSignalPolicyExImpl = ReflectedClass.of( + "com.oplus.systemui.statusbar.pipeline.OplusWifiSignalExImpl" /* OOS15 */, + "com.oplus.systemui.statusbar.phone.signal.OplusStatusBarSignalPolicyExImpl" /* OOS14 */, + "com.oplusos.systemui.statusbar.phone.StatusBarSignalPolicyEx" /* OOS13 */); + + if (Build.VERSION.SDK_INT >= 35) { + OplusStatusBarSignalPolicyExImpl + .before("bindEx$updateActivityIcon") + .run(param -> { + try { + if (mHideWifiActivity) + param.args[1] = 0; + } catch (Throwable t) { + log(t); + } + }); + } else { + OplusStatusBarSignalPolicyExImpl + .before("getWifiActivityId") + .run(param -> { + if (mHideWifiActivity) + param.setResult(0); + }); } - hookAllMethods(OplusStatusBarSignalPolicyExImpl, "getWifiActivityId", new XC_MethodHook() { - @Override - protected void beforeHookedMethod(MethodHookParam param) throws Throwable { - if (mHideWifiActivity) - param.setResult(0); - } - }); - } catch (Throwable t) { - log(" getWifiActivityId " + t.getMessage()); + log(t); } try { - Class OplusStatusBarMobileViewExImpl = findClass("com.oplus.systemui.statusbar.phone.signal.OplusStatusBarMobileViewExImpl", lpparam.classLoader); - hookAllMethods(OplusStatusBarMobileViewExImpl, "updateState", new XC_MethodHook() { - @Override - protected void afterHookedMethod(MethodHookParam param) throws Throwable { - if (!mHideMobileActivity) return; - ImageView mDataActivity = (ImageView) getObjectField(param.thisObject, "mDataActivity"); - mDataActivity.setVisibility(View.GONE); - ImageView mIn = (ImageView) getObjectField(param.thisObject, "mIn"); - mIn.setVisibility(View.GONE); - ImageView mOut = (ImageView) getObjectField(param.thisObject, "mOut"); - mOut.setVisibility(View.GONE); - } - }); + ReflectedClass OplusStatusBarMobileViewExImpl = ReflectedClass.of( + "com.oplus.systemui.statusbar.pipeline.mobile.ui.view.OplusStatusBarMobileViewBinder" /* OOS15 */, + "com.oplus.systemui.statusbar.phone.signal.OplusStatusBarMobileViewExImpl" /* OOS14-13 */); + + if (Build.VERSION.SDK_INT >= 35) { + OplusStatusBarMobileViewExImpl + .before("bindCustEx$updateDataActivity") + .run(param -> { + if (mHideMobileActivity) { + param.args[1] = 0; + } + }); + } else { + OplusStatusBarMobileViewExImpl + .after("updateState") + .run(param -> { + if (!mHideMobileActivity) return; + ImageView mDataActivity = (ImageView) getObjectField(param.thisObject, "mDataActivity"); + mDataActivity.setVisibility(View.GONE); + ImageView mIn = (ImageView) getObjectField(param.thisObject, "mIn"); + mIn.setVisibility(View.GONE); + ImageView mOut = (ImageView) getObjectField(param.thisObject, "mOut"); + mOut.setVisibility(View.GONE); + }); + } } catch (Throwable t) { - log(" - Class Not Found " + t); + log(t); } }