Skip to content

Commit

Permalink
opt: DisableDeviceManaged
Browse files Browse the repository at this point in the history
  • Loading branch information
Sevtinge committed Jun 20, 2024
1 parent 39bdcf0 commit 9729d02
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public void handleLoadPackage() {
initHook(new FixTilesList(), mPrefsMap.getBoolean("system_ui_control_center_fix_tiles_list"));
initHook(new AllowAllThemesNotificationBlur(), mPrefsMap.getBoolean("system_ui_control_center_unlock_blur_supported"));
initHook(new DisableTransparent(), mPrefsMap.getBoolean("system_ui_control_center_notification_disable_transparent"));
initHook(DisableDeviceManaged.INSTANCE, mPrefsMap.getBoolean("system_ui_control_center_disable_device_managed"));
initHook(new DisableDeviceManaged(), mPrefsMap.getBoolean("system_ui_control_center_disable_device_managed"));

// Actions
initHook(new StatusBarActions(), true);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.sevtinge.hyperceiler.module.hook.systemui.controlcenter;

import static de.robv.android.xposed.XposedHelpers.setBooleanField;

import android.app.admin.DevicePolicyManager;
import android.graphics.drawable.Drawable;

import com.sevtinge.hyperceiler.module.base.BaseHook;

public class DisableDeviceManaged extends BaseHook {
@Override
public void init() throws NoSuchMethodException {
findAndHookMethod(DevicePolicyManager.class, "isDeviceManaged", new MethodHook(){
@Override
protected void before(MethodHookParam param) throws Throwable {
param.setResult(false);
}
});
findAndHookMethod("com.android.systemui.statusbar.policy.SecurityControllerImpl", "isDeviceManaged", new MethodHook(){
@Override
protected void before(MethodHookParam param) throws Throwable {
param.setResult(false);
}
});
findAndHookMethod("com.android.systemui.statusbar.policy.SecurityControllerImpl", "hasCACertInCurrentUser", new MethodHook(){
@Override
protected void before(MethodHookParam param) throws Throwable {
param.setResult(false);
}
});
findAndHookMethod("com.android.systemui.statusbar.policy.SecurityControllerImpl", "hasCACertInWorkProfile", new MethodHook(){
@Override
protected void before(MethodHookParam param) throws Throwable {
param.setResult(false);
}
});
findAndHookConstructor("com.android.systemui.security.data.model.SecurityModel", boolean.class, boolean.class, boolean.class, boolean.class, String.class, String.class, boolean.class, boolean.class, String.class, String.class, boolean.class, boolean.class, boolean.class, Drawable.class, new MethodHook(){
@Override
protected void before(MethodHookParam param) throws Throwable {
param.args[0] = false;
param.args[10] = false;
param.args[11] = false;
setBooleanField(param.thisObject, "isDeviceManaged", false);
setBooleanField(param.thisObject, "hasCACertInCurrentUser", false);
setBooleanField(param.thisObject, "hasCACertInWorkProfile", false);
}
});
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.sevtinge.hyperceiler.module.hook.systemui.plugin;

import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.os.Handler;

import java.util.concurrent.Executor;

import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XC_MethodReplacement;
import de.robv.android.xposed.XposedHelpers;

public class DisableDeviceManaged {
public static void initDisableDeviceManaged(ClassLoader classLoader) {
XposedHelpers.findAndHookMethod(DevicePolicyManager.class, "isDeviceManaged", XC_MethodReplacement.returnConstant(false));
XposedHelpers.findAndHookMethod("miui.systemui.controlcenter.policy.SecurityController", classLoader, "isDeviceManaged", XC_MethodReplacement.returnConstant(false));
XposedHelpers.findAndHookMethod("miui.systemui.controlcenter.policy.SecurityController", classLoader, "hasCACertInCurrentUser", XC_MethodReplacement.returnConstant(false));
XposedHelpers.findAndHookMethod("miui.systemui.controlcenter.policy.SecurityController", classLoader, "hasCACertInWorkProfile", XC_MethodReplacement.returnConstant(false));
XposedHelpers.findAndHookConstructor("miui.systemui.controlcenter.policy.SecurityController", classLoader, Context.class, Handler.class, Executor.class, "miui.systemui.boardcast.BroadcastDispatcher", "miui.systemui.util.SystemUIResourcesHelper", new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
XposedHelpers.setObjectField(param.thisObject, "hasCACerts", null);
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,10 @@ public void setClassLoader(ClassLoader classLoader) {
if (mPrefsMap.getBoolean("systemui_plugin_card_tiles_enabled") && !mPrefsMap.getString("systemui_plugin_card_tiles", "").isEmpty()) {
CustomCardTiles.initCustomCardTiles(classLoader, mCardStyleTiles);
}
if(mPrefsMap.getStringAsInt("system_ui_control_center_hide_operator", 0) == 3)
if (mPrefsMap.getStringAsInt("system_ui_control_center_hide_operator", 0) == 3)
ShowDeviceName.initShowDeviceName(classLoader);
if (mPrefsMap.getBoolean("system_ui_control_center_disable_device_managed"))
DisableDeviceManaged.initDisableDeviceManaged(classLoader);
}

private static List<String> getTileList() {
Expand Down

0 comments on commit 9729d02

Please sign in to comment.