zoukankan      html  css  js  c++  java
  • android源码修改,实现长按电源键直接关机

    版本:android 4.4.2

    源文件路径:frameworksasepolicysrccomandroidinternalpolicyimplPhoneWindowManager.java

    修改下面的代码:

    private final Runnable mPowerLongPress = new Runnable() {
            @Override
            public void run() {
                // The context isn't read
                if (mLongPressOnPowerBehavior < 0) {
                    mLongPressOnPowerBehavior = mContext.getResources().getInteger(
                            com.android.internal.R.integer.config_longPressOnPowerBehavior);
                }
                int resolvedBehavior = mLongPressOnPowerBehavior;
                if (FactoryTest.isLongPressOnPowerOffEnabled()) {
                    resolvedBehavior = LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM;
                }
    /*
                switch (resolvedBehavior) {
                case LONG_PRESS_POWER_NOTHING:
                    break;
                case LONG_PRESS_POWER_GLOBAL_ACTIONS:
                    mPowerKeyHandled = true;
                    if (!performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false)) {
                        performAuditoryFeedbackForAccessibilityIfNeed();
                    }
                    sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
                    showGlobalActionsDialog();
                    break;
                case LONG_PRESS_POWER_SHUT_OFF:
                case LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM:
                    mPowerKeyHandled = true;
                    performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
                    sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
                    mWindowManagerFuncs.shutdown(resolvedBehavior == LONG_PRESS_POWER_SHUT_OFF);
                    break;
                }
    */
                //注释掉上面的代码后,增加下面的代码
                mPowerKeyHandled = true;
                performHapticFeedbackLw(null, HapticFeedbackConstants.LONG_PRESS, false);
                sendCloseSystemWindows(SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS);
                mWindowManagerFuncs.shutdown(false);//这里false代表不显示关机提示框,true未显示关机提示框
            }
        };
    

     修改后,长按关机键会直接关机。

  • 相关阅读:
    分布式日志收集系统: Facebook Scribe之日志收集方案
    20111030 19:37 杨辉三角形 (java)
    pku acm 1833 排列
    俞敏洪郑大演讲经典语句
    自己在inode客户端的大量问题(不断更新中)(20120223 21:24 )
    智力测验:硬币问题
    windows up可以更新但是无法上网的一天挣扎
    hdu1754 I Hate It
    acm算法资源网站
    pku3041 Asteroids
  • 原文地址:https://www.cnblogs.com/suxiaoqi/p/5812697.html
Copyright © 2011-2022 走看看