4242import android .media .IAudioService ;
4343import android .os .BatteryManager ;
4444import android .os .Bundle ;
45+ import android .os .FactoryTest ;
4546import android .os .Handler ;
4647import android .os .IBinder ;
4748import android .os .IRemoteCallback ;
@@ -172,6 +173,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
172173 static final int LONG_PRESS_POWER_NOTHING = 0 ;
173174 static final int LONG_PRESS_POWER_GLOBAL_ACTIONS = 1 ;
174175 static final int LONG_PRESS_POWER_SHUT_OFF = 2 ;
176+ static final int LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM = 3 ;
175177
176178 // These need to match the documentation/constant in
177179 // core/res/res/values/config.xml
@@ -716,8 +718,12 @@ private void cancelPendingScreenshotChordAction() {
716718 public void run () {
717719 // The context isn't read
718720 if (mLongPressOnPowerBehavior < 0 ) {
719- mLongPressOnPowerBehavior = mContext .getResources ().getInteger (
720- com .android .internal .R .integer .config_longPressOnPowerBehavior );
721+ if (FactoryTest .isLongPressOnPowerOffEnabled ()) {
722+ mLongPressOnPowerBehavior = LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM ;
723+ } else {
724+ mLongPressOnPowerBehavior = mContext .getResources ().getInteger (
725+ com .android .internal .R .integer .config_longPressOnPowerBehavior );
726+ }
721727 }
722728 switch (mLongPressOnPowerBehavior ) {
723729 case LONG_PRESS_POWER_NOTHING :
@@ -729,10 +735,12 @@ public void run() {
729735 showGlobalActionsDialog ();
730736 break ;
731737 case LONG_PRESS_POWER_SHUT_OFF :
738+ case LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM :
732739 mPowerKeyHandled = true ;
733740 performHapticFeedbackLw (null , HapticFeedbackConstants .LONG_PRESS , false );
734741 sendCloseSystemWindows (SYSTEM_DIALOG_REASON_GLOBAL_ACTIONS );
735- mWindowManagerFuncs .shutdown ();
742+ mWindowManagerFuncs .shutdown (
743+ mLongPressOnPowerBehavior == LONG_PRESS_POWER_SHUT_OFF );
736744 break ;
737745 }
738746 }
0 commit comments