首页 > 解决方案 > 按下电源按钮超过 10 秒时设备不重启

问题描述

我正在具有 android 源代码的设备上进行编码。在普通的安卓设备上,当我长按电源按钮 10 秒时,设备会重新启动,但在我的情况下,当我长按电源按钮 10 秒时,设备会关闭。你有一个想法,在android源代码中,这个功能是编码的(这样我就会明白我的问题在哪里)?

标签: android

解决方案


干得好:

https://android.googlesource.com/platform/frameworks/base/+/7d276c3/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java

private final Runnable mPowerLongPress = new Runnable() {
    public void run() {
        // The context isn't read
        if (mLongPressOnPowerBehavior < 0) {
            mLongPressOnPowerBehavior = mContext.getResources().getInteger(
                    com.android.internal.R.integer.config_longPressOnPowerBehavior);
        }
        switch (mLongPressOnPowerBehavior) {
        case LONG_PRESS_POWER_NOTHING:
            break;
        case LONG_PRESS_POWER_GLOBAL_ACTIONS:
            mPowerKeyHandled = true;
            performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
            sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
            showGlobalActionsDialog();
            break;
        case LONG_PRESS_POWER_SHUT_OFF:
            mPowerKeyHandled = true;
            performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
            sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
            ShutdownThread.shutdown(mContext, true);
            break;
        }
    }
};

推荐阅读