android 短按电源键关机
打开文件:\frameworks\base\policy\src\com\android\internal\policy\impl\PhoneWindowManager.java
在代码:
private static final int MSG_POWER_LONG_PRESS = 14;
下面添加:
private static final int MSG_POWER_SHUT_DOWN=15;
在:
case MSG_POWER_LONG_PRESS:
powerLongPress();
break;
下面添加:
case MSG_POWER_SHUT_DOWN:
mWindowManagerFuncs.shutdown(false);
break;
找到 case KeyEvent.KEYCODE_POWER:
注释掉
/*result &= ~ACTION_PASS_TO_USER;
isWakeKey = false; // wake-up will be handled separately
if (down) {
interceptPowerKeyDown(event, interactive);
} else {
interceptPowerKeyUp(event, interactive, canceled);
}
break;*/
再添加:
if(down){
if(mPowerManager.isScreenOn()) {
Message msg = mHandler.obtainMessage(MSG_POWER_SHUT_DOWN);
msg.setAsynchronous(true);
mHandler.sendMessageDelayed(msg,
ViewConfiguration.get(mContext).getDeviceGlobalActionKeyTimeout());
} else {
Log.e("GO to Wakeup--------> TTTEEE","keyCode :"+keyCode);
wakeUpFromPowerKey(event.getDownTime());
}
}
break;
之后在目录frameworks/base/policy中mm编译出android.policy.jar push到system/framework重启即可