android long power key流程

长按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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值