需求描述:
平板或手机上, 长按POWER键, 一般会弹出关机选择界面, 提示关机或切换模式,
需求中,要求把这一部分去掉, 直接长按POWER 3秒后关机.
实现:
frameworks/base/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java @@ -656,7 +656,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { private void interceptPowerKeyDown(boolean handled) { mPowerKeyHandled = handled; if (!handled) { - mHandler.postDelayed(mPowerLongPress, ViewConfiguration.getGlobalActionKeyTimeout());//原来的代码 + mHandler.postDelayed(mPowerLongPress, 3000);//ViewConfiguration.getGlobalActionKeyTimeout());//修改后, 3 秒钟后会触发. } } @@ -717,7 +717,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (FactoryTest.isLongPressOnPowerOffEnabled()) { resolvedBehavior = LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM; } - +resolvedBehavior = LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM;//AnsonCode 2013.7.5 //添加这行代码, 不显示确认窗口,并直接调用poweroff关机 switch (resolvedBehavior) { case LONG_PRESS_POWER_NOTHING: break;