代码之家  ›  专栏  ›  技术社区  ›  Bazouk55555

当我按下电源按钮超过10秒时,Android设备不会重新启动

  •  0
  • Bazouk55555  · 技术社区  · 6 年前

    我在一个有android源代码的设备上编码。在普通的android设备上,当我长按电源按钮10秒时,设备会重新启动。然而在我的情况下,当我长按电源按钮10秒时,设备会关闭。你有没有一个想法,在android源代码中,这个功能是在哪里编码的(这样我就能理解我的问题在哪里)?

    1 回复  |  直到 6 年前
        1
  •  1
  •   Gavin Wright    6 年前

    干得好:

    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;
            }
        }
    };