The Android system does not automatically shut down after a long hold of the power key like Nokia. You have to select the Shutdown option and then confirm the shutdown. In this way, sometimes it is inconvenient.Source codeAfter a small change, the system automatically shuts down after a long press of the power key pop-up option box is held for three seconds. The procedure is as follows:
1. Open the frameworks \ base \ Policy \ SRC \ com \ Android \ internal \ Policy \ impl \ phonewindowmanager. Java file in the android source code.
2. Create a mpowerlongpress2 thread by referring to mpowerlongpress,CodeAs follows:
Runnable mpowerlongpress2 = new runnable () {public void run () {mshouldturnoffonkeyup = false; performhapticfeedbacklw (null, hapticfeedbackconstants. long_press, false); sendclosesystemwindows (system_dialog_reason_global_actions); shutdownthread. shutdown (mcontext, false); // shutdown directly when the second option is flase. If the value is true, the shutdown dialog box is displayed }};
3. In the code
If (keycode = keyevent. keycode_endcall | keycode = keyevent. keycode_power)
Previously added
If (keycode = keyevent. keycode_power) if (down) {mshouldturnoffonkeyup = true; mhandler. postdelayed (mpowerlongpress2, 3000); // The mpowerlongpress2 thread is executed 3 seconds later} else {mhandler. removecallbacks (mpowerlongpress2 );}
After adding the above two pieces of code, return to the source code root directory and execute. build/envsetup. SH and then execute Mmm frameworks/base/policy or execute mm in the frameworks/base/policy directory. /mkimage. sh. Burn system. IMG to the board, enable the Board length and press the power key.
Automatically shut down after holding down for 3 seconds.