Android 屏蔽安全模式+去掉系统安全模式(SAFE MODE)

xwbar的头像
2025-10-11 11:14:35
/
世界杯克罗地亚

去除:进入 alps\frameworks\base\core\res\res\values\config.xml

+ no_safe_boot

frameworks/base/services/core/java/com/android/server/power/ShutdownThread.java

public static void rebootSafeMode(final Context context, boolean confirm) {

UserManager um = (UserManager) context.getSystemService(Context.USER_SERVICE);

if (um.hasUserRestriction(UserManager.DISALLOW_SAFE_BOOT)) {

return;

}

mReboot = true;

mRebootSafeMode = false;//true

mRebootHasProgressBar = false;

mReason = null;

shutdownInner(context, confirm);

}

WindowManagerService.java 【直接有效验证】

/frameworks/base/services/core/java/com/android/server/wm/WindowManagerService.java

public boolean detectSafeMode() {

if (!mInputManagerCallback.waitForInputDevicesReady(

INPUT_DEVICES_READY_FOR_SAFE_MODE_DETECTION_TIMEOUT_MILLIS)) {

ProtoLog.w(WM_ERROR, "Devices still not ready after waiting %d"

+ " milliseconds before attempting to detect safe mode.",

INPUT_DEVICES_READY_FOR_SAFE_MODE_DETECTION_TIMEOUT_MILLIS);

}

if (Settings.Global.getInt(

mContext.getContentResolver(), Settings.Global.SAFE_BOOT_DISALLOWED, 0) != 0) {

return false;

}

int menuState = mInputManager.getKeyCodeState(-1, InputDevice.SOURCE_ANY,

KeyEvent.KEYCODE_MENU);

int sState = mInputManager.getKeyCodeState(-1, InputDevice.SOURCE_ANY, KeyEvent.KEYCODE_S);

int dpadState = mInputManager.getKeyCodeState(-1, InputDevice.SOURCE_DPAD,

KeyEvent.KEYCODE_DPAD_CENTER);

int trackballState = mInputManager.getScanCodeState(-1, InputDevice.SOURCE_TRACKBALL,

InputManagerService.BTN_MOUSE);

int volumeDownState = mInputManager.getKeyCodeState(-1, InputDevice.SOURCE_ANY,

KeyEvent.KEYCODE_VOLUME_DOWN);

mSafeMode = menuState > 0 || sState > 0 || dpadState > 0 || trackballState > 0

|| volumeDownState > 0;

try {

if (SystemProperties.getInt(ShutdownThread.REBOOT_SAFEMODE_PROPERTY, 0) != 0

|| SystemProperties.getInt(ShutdownThread.RO_SAFEMODE_PROPERTY, 0) != 0) {

mSafeMode = true;

SystemProperties.set(ShutdownThread.REBOOT_SAFEMODE_PROPERTY, "");

}

} catch (IllegalArgumentException e) {

}

if (mSafeMode) {

// May already be set if (for instance) this process has crashed

if (SystemProperties.getInt(ShutdownThread.RO_SAFEMODE_PROPERTY, 0) == 0) {

SystemProperties.set(ShutdownThread.RO_SAFEMODE_PROPERTY, "1");

}

} else {

ProtoLog.i(WM_ERROR, "SAFE MODE not enabled");

}

mPolicy.setSafeMode(mSafeMode);

return false;//mSafeMode

}

@Override

public boolean isSafeModeEnabled() {

return false;//mSafeMode

}

vendor/mediatek/proprietary/packages/apps/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialogLite.java

删除重启进入安全模式:

@Override

public boolean onLongPress() {

mUiEventLogger.log(GlobalActionsEvent.GA_REBOOT_LONG_PRESS);

/*/remove reboot safe mode

if (!mUserManager.hasUserRestriction(UserManager.DISALLOW_SAFE_BOOT)) {

mWindowManagerFuncs.reboot(true);

return true;

}

return false;

/*/

mWindowManagerFuncs.reboot(false);

return true;

//*/

}

Wsappx 是什麼?解決 wsappc 佔用 CPU 使用率
腾达的产品质量和使用体验怎么样?