Android source code modification, the realization of long press the power button directly shut down the machine

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.