长按power key
1、android framework(for android 4.3)
/frameworks/base/core/res/res/values/config.xml...
404 <!-- Control the behavior when the user long presses the power button.
405 0 - Nothing
406 1 - Global actions menu
407 2 - Power off (with confirmation)
408 -->
409 <integer name="config_longPressOnPowerBehavior">1</integer>
/frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java
private final Runnable mPowerLongPress = new Runnable() {
695 @Override
696 public void run() {
697 // The context isn't read
698 if (mLongPressOnPowerBehavior < 0) {
699 mLongPressOnPowerBehavior = mContext.getResources().getInteger(
700 com.android.internal.R.integer.config_longPressOnPowerBehavior);
701 }
702 int resolvedBehavior = mLongPressOnPowerBehavior;
703 if (FactoryTest.isLongPressOnPowerOffEnabled()) {
704 resolvedBehavior = LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM;
705 }
706
707 switch (resolvedBehavior) {
708 case LONG_PRESS_POWER_NOTHING:
709 break;
710 case LONG_PRESS_POWER_GLOBAL_ACTIONS:
711 mPowerKeyHandled = true;
712 if (!performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false)) {
713 performAuditoryFeedbackForAccessibilityIfNeed();
714 }
715 sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
716 showGlobalActionsDialog();
717 break;
718 case LONG_PRESS_POWER_SHUT_OFF:
719 case LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM:
720 mPowerKeyHandled = true;
721 performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
722 sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
723 mWindowManagerFuncs.shutdown(resolvedBehavior == LONG_PRESS_POWER_SHUT_OFF);
724 break;
725 }
726 }
727 };
/frameworks/base/services/java/com/android/server/power/ShutdownThread.java
101 public static void shutdown(final Context context, boolean confirm) {
102 mReboot = false;
103 mRebootSafeMode = false;
104 shutdownInner(context, confirm);
105 }
483 /**
484 * Do not call this directly. Use {@link #reboot(Context, String, boolean)}
485 * or {@link #shutdown(Context, boolean)} instead.
486 *
487 * @param rebo
android long power key流程
最新推荐文章于 2022-12-13 17:47:22 发布