Skip to content

Commit

Permalink
Move Advanced Reboot in a different Class
Browse files Browse the repository at this point in the history
  • Loading branch information
DHD2280 committed Jun 20, 2024
1 parent 087d8c7 commit 67ac75d
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
import it.dhd.oxygencustomizer.xposed.hooks.systemui.AdaptivePlayback;
import it.dhd.oxygencustomizer.xposed.hooks.systemui.AudioDataProvider;
import it.dhd.oxygencustomizer.xposed.hooks.systemui.BatteryDataProvider;
import it.dhd.oxygencustomizer.xposed.hooks.systemui.FeatureEnabler;
import it.dhd.oxygencustomizer.xposed.hooks.systemui.AdvancedReboot;
import it.dhd.oxygencustomizer.xposed.hooks.systemui.FeatureOption;
import it.dhd.oxygencustomizer.xposed.hooks.systemui.MiscMods;
import it.dhd.oxygencustomizer.xposed.hooks.systemui.OpUtils;
import it.dhd.oxygencustomizer.xposed.hooks.systemui.PulseViewHook;
Expand Down Expand Up @@ -69,7 +70,10 @@ public static ArrayList<Class<? extends XposedMods>> getMods(String packageName)
modPacks.add(OpUtils.class);

// Oplus Feature Enabler
modPacks.add(FeatureEnabler.class);
modPacks.add(FeatureOption.class);

// Advanced Reboot
modPacks.add(AdvancedReboot.class);

// AOD
modPacks.add(AodClock.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,11 @@
import it.dhd.oxygencustomizer.xposed.XPLauncher;
import it.dhd.oxygencustomizer.xposed.XposedMods;

public class FeatureEnabler extends XposedMods {
public class AdvancedReboot extends XposedMods {

private static final String listenPackage = Constants.Packages.SYSTEM_UI;
private Class<?> FeatureOptionsVolatile = null;
private boolean hideSosPowerMenu, showAdvancedReboot, useAuthForAdvancedReboot;
private int volumePanelPosition;
private Drawable mAdvancedRebootDrawable;
private int mAdvancedRebootTopMargin;
private Paint buttonPaint;
private Paint textPaint;
private int centerX;
Expand All @@ -67,14 +64,13 @@ public void onReceive(Context context, Intent intent) {
}
};

public FeatureEnabler(Context context) {
public AdvancedReboot(Context context) {
super(context);
mAdvancedRebootDrawable = ResourcesCompat.getDrawable(mContext.getResources(), mContext.getResources().getIdentifier("oplus_reboot", "drawable", listenPackage), mContext.getTheme());
}

@Override
public void updatePrefs(String... Key) {
volumePanelPosition = Integer.parseInt(Xprefs.getString("volume_panel_position", "0"));
hideSosPowerMenu = Xprefs.getBoolean("power_menu_hide_sos", false);
showAdvancedReboot = Xprefs.getBoolean("show_advanced_reboot", false);
useAuthForAdvancedReboot = Xprefs.getBoolean("advanced_reboot_auth", false);
Expand All @@ -92,7 +88,6 @@ public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Th
mContext.registerReceiver(broadcastReceiver, intentFilter, RECEIVER_EXPORTED); //for Android 14, receiver flag is mandatory
}

//Class<?> ShutdownViewControl = findClass("com.oplus.systemui.shutdown.ShutdownViewControl", lpparam.classLoader);
SystemUIDialogClass = findClass("com.android.systemui.statusbar.phone.SystemUIDialog", lpparam.classLoader);

Class<?> ShutdownView;
Expand Down Expand Up @@ -143,26 +138,6 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
param.setResult(false);
}
});

Class<?> FeatureOptions;
try {
FeatureOptions = findClass("com.oplusos.systemui.common.feature.FeatureOption", lpparam.classLoader);
} catch (Throwable t) {
FeatureOptions = findClass("com.oplusos.systemui.common.feature.FeatureOption", lpparam.classLoader);
}


hookAllMethods(FeatureOptions, "isOplusVolumeKeyInRight", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
if (volumePanelPosition == 0) return;

if (volumePanelPosition == 1)
param.setResult(true);
else
param.setResult(false);
}
});
}

private void showAuth() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package it.dhd.oxygencustomizer.xposed.hooks.systemui;

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 it.dhd.oxygencustomizer.utils.Constants.Packages.SYSTEM_UI;
import static it.dhd.oxygencustomizer.xposed.XPrefs.Xprefs;

import android.content.Context;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.callbacks.XC_LoadPackage;
import it.dhd.oxygencustomizer.xposed.XposedMods;

public class FeatureOption extends XposedMods {

private static final String listenPackage = SYSTEM_UI;
private int volumePanelPosition = 0;
private boolean showMyDevice = false;

public FeatureOption(Context context) {
super(context);
}

@Override
public void updatePrefs(String... Key) {
volumePanelPosition = Integer.parseInt(Xprefs.getString("volume_panel_position", "0"));
showMyDevice = Xprefs.getBoolean("qs_show_my_device", false);
}

@Override
public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable {

Class<?> FeatureOptions = findClass("com.oplusos.systemui.common.feature.FeatureOption", lpparam.classLoader);


hookAllMethods(FeatureOptions, "isOplusVolumeKeyInRight", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
if (volumePanelPosition == 0) return;

if (volumePanelPosition == 1)
param.setResult(true);
else
param.setResult(false);
}
});

hookAllMethods(FeatureOptions, "isSupportMyDevice", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
if (showMyDevice) param.setResult(true);
}
});

}

@Override
public boolean listensTo(String packageName) {
return listenPackage.equals(packageName);
}
}

0 comments on commit 67ac75d

Please sign in to comment.