Version: Android 4.4.2
Source file path: Frameworks\base\policy\src\com\android\internal\policy\impl\phonewindowmanager.java
Modify the following code:
Private final Runnable mpowerlongpress = new Runnable () {@Override public void run () {//the CO ntext isn ' t read if (Mlongpressonpowerbehavior < 0) {Mlongpressonpowerbehavior = mcontext.ge Tresources (). 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)) {Performauditoryfeedbac Kforaccessibilityifneed (); } sendclosesystemwindows (System_diaLog_reason_global_actions); Showglobalactionsdialog (); Break Case Long_press_power_shut_off:case long_press_power_shut_off_no_confirm:mpowerkeyhandled = tr Ue PERFORMHAPTICFEEDBACKLW (null, hapticfeedbackconstants.long_press, FALSE); Sendclosesystemwindows (system_dialog_reason_global_actions); Mwindowmanagerfuncs.shutdown (Resolvedbehavior = = Long_press_power_shut_off); Break }*///Comment out the above code, add the following code mpowerkeyhandled = true; PERFORMHAPTICFEEDBACKLW (null, hapticfeedbackconstants.long_press, FALSE); Sendclosesystemwindows (system_dialog_reason_global_actions); Mwindowmanagerfuncs.shutdown (false);//Here false means do not display the Shutdown prompt box, true does not display the Shutdown prompt box}};
When modified, long press the shut down key will shut down directly.
Android source code modification, the realization of long press the power button directly shut down the machine