Loading core/res/res/values/config.xml +1 −0 Original line number Diff line number Diff line Loading @@ -1159,6 +1159,7 @@ 3 - Power off (without confirmation) 4 - Go to voice assist 5 - Go to assistant (Settings.Secure.ASSISTANT) 6 - Go to sleep (doze) --> <integer name="config_longPressOnPowerBehavior">5</integer> Loading services/core/java/com/android/server/policy/PhoneWindowManager.java +9 −0 Original line number Diff line number Diff line Loading @@ -317,6 +317,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { static final int LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM = 3; static final int LONG_PRESS_POWER_GO_TO_VOICE_ASSIST = 4; static final int LONG_PRESS_POWER_ASSISTANT = 5; // Settings.Secure.ASSISTANT static final int LONG_PRESS_POWER_GO_TO_SLEEP = 6; // must match: config_veryLongPresOnPowerBehavior in config.xml // The config value can be overridden using Settings.Global.POWER_BUTTON_VERY_LONG_PRESS Loading Loading @@ -1488,6 +1489,12 @@ public class PhoneWindowManager implements WindowManagerPolicy { launchAssistAction(null, powerKeyDeviceId, eventTime, AssistUtils.INVOCATION_TYPE_POWER_BUTTON_LONG_PRESS); break; case LONG_PRESS_POWER_GO_TO_SLEEP: mPowerKeyHandled = true; performHapticFeedback(HapticFeedbackConstants.LONG_PRESS_POWER_BUTTON, "Power - Long Press - Go To Sleep (Doze)"); sleepDefaultDisplayFromPowerButton(eventTime, 0); break; } } Loading Loading @@ -6562,6 +6569,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { return "LONG_PRESS_POWER_GO_TO_VOICE_ASSIST"; case LONG_PRESS_POWER_ASSISTANT: return "LONG_PRESS_POWER_ASSISTANT"; case LONG_PRESS_POWER_GO_TO_SLEEP: return "LONG_PRESS_POWER_GO_TO_SLEEP"; default: return Integer.toString(behavior); } Loading services/tests/wmtests/src/com/android/server/policy/PowerKeyGestureTests.java +11 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import static com.android.cts.input.inputeventmatchers.InputEventMatchersKt.with import static com.android.cts.input.inputeventmatchers.InputEventMatchersKt.withKeyFlags; import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_ASSISTANT; import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_GLOBAL_ACTIONS; import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_GO_TO_SLEEP; import static com.android.server.policy.PhoneWindowManager.POWER_MULTI_PRESS_TIMEOUT_MILLIS; import static com.android.server.policy.PhoneWindowManager.SHORT_PRESS_POWER_DREAM_OR_SLEEP; import static com.android.server.policy.PhoneWindowManager.SHORT_PRESS_POWER_GO_TO_SLEEP; Loading Loading @@ -152,6 +153,16 @@ public class PowerKeyGestureTests extends ShortcutKeyTestBase { mPhoneWindowManager.assertShowGlobalActionsCalled(); } /** * Power long press to go to sleep (doze). */ @Test public void testPowerLongPressGoToSleep() { mPhoneWindowManager.overrideLongPressOnPower(LONG_PRESS_POWER_GO_TO_SLEEP); sendKey(KEYCODE_POWER, SingleKeyGestureDetector.sDefaultLongPressTimeout); mPhoneWindowManager.assertPowerSleep(); } /** * Ignore power press if combination key already triggered. */ Loading services/tests/wmtests/src/com/android/server/policy/TestPhoneWindowManager.java +2 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.times; import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify; import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_ASSISTANT; import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_GLOBAL_ACTIONS; import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_GO_TO_SLEEP; import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_GO_TO_VOICE_ASSIST; import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_NOTHING; import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_SHUT_OFF; Loading Loading @@ -497,6 +498,7 @@ class TestPhoneWindowManager { case LONG_PRESS_POWER_SHUT_OFF: case LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM: case LONG_PRESS_POWER_GO_TO_VOICE_ASSIST: case LONG_PRESS_POWER_GO_TO_SLEEP: break; case LONG_PRESS_POWER_ASSISTANT: setupAssistForLaunch(); Loading Loading
core/res/res/values/config.xml +1 −0 Original line number Diff line number Diff line Loading @@ -1159,6 +1159,7 @@ 3 - Power off (without confirmation) 4 - Go to voice assist 5 - Go to assistant (Settings.Secure.ASSISTANT) 6 - Go to sleep (doze) --> <integer name="config_longPressOnPowerBehavior">5</integer> Loading
services/core/java/com/android/server/policy/PhoneWindowManager.java +9 −0 Original line number Diff line number Diff line Loading @@ -317,6 +317,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { static final int LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM = 3; static final int LONG_PRESS_POWER_GO_TO_VOICE_ASSIST = 4; static final int LONG_PRESS_POWER_ASSISTANT = 5; // Settings.Secure.ASSISTANT static final int LONG_PRESS_POWER_GO_TO_SLEEP = 6; // must match: config_veryLongPresOnPowerBehavior in config.xml // The config value can be overridden using Settings.Global.POWER_BUTTON_VERY_LONG_PRESS Loading Loading @@ -1488,6 +1489,12 @@ public class PhoneWindowManager implements WindowManagerPolicy { launchAssistAction(null, powerKeyDeviceId, eventTime, AssistUtils.INVOCATION_TYPE_POWER_BUTTON_LONG_PRESS); break; case LONG_PRESS_POWER_GO_TO_SLEEP: mPowerKeyHandled = true; performHapticFeedback(HapticFeedbackConstants.LONG_PRESS_POWER_BUTTON, "Power - Long Press - Go To Sleep (Doze)"); sleepDefaultDisplayFromPowerButton(eventTime, 0); break; } } Loading Loading @@ -6562,6 +6569,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { return "LONG_PRESS_POWER_GO_TO_VOICE_ASSIST"; case LONG_PRESS_POWER_ASSISTANT: return "LONG_PRESS_POWER_ASSISTANT"; case LONG_PRESS_POWER_GO_TO_SLEEP: return "LONG_PRESS_POWER_GO_TO_SLEEP"; default: return Integer.toString(behavior); } Loading
services/tests/wmtests/src/com/android/server/policy/PowerKeyGestureTests.java +11 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import static com.android.cts.input.inputeventmatchers.InputEventMatchersKt.with import static com.android.cts.input.inputeventmatchers.InputEventMatchersKt.withKeyFlags; import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_ASSISTANT; import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_GLOBAL_ACTIONS; import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_GO_TO_SLEEP; import static com.android.server.policy.PhoneWindowManager.POWER_MULTI_PRESS_TIMEOUT_MILLIS; import static com.android.server.policy.PhoneWindowManager.SHORT_PRESS_POWER_DREAM_OR_SLEEP; import static com.android.server.policy.PhoneWindowManager.SHORT_PRESS_POWER_GO_TO_SLEEP; Loading Loading @@ -152,6 +153,16 @@ public class PowerKeyGestureTests extends ShortcutKeyTestBase { mPhoneWindowManager.assertShowGlobalActionsCalled(); } /** * Power long press to go to sleep (doze). */ @Test public void testPowerLongPressGoToSleep() { mPhoneWindowManager.overrideLongPressOnPower(LONG_PRESS_POWER_GO_TO_SLEEP); sendKey(KEYCODE_POWER, SingleKeyGestureDetector.sDefaultLongPressTimeout); mPhoneWindowManager.assertPowerSleep(); } /** * Ignore power press if combination key already triggered. */ Loading
services/tests/wmtests/src/com/android/server/policy/TestPhoneWindowManager.java +2 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.times; import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify; import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_ASSISTANT; import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_GLOBAL_ACTIONS; import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_GO_TO_SLEEP; import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_GO_TO_VOICE_ASSIST; import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_NOTHING; import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_SHUT_OFF; Loading Loading @@ -497,6 +498,7 @@ class TestPhoneWindowManager { case LONG_PRESS_POWER_SHUT_OFF: case LONG_PRESS_POWER_SHUT_OFF_NO_CONFIRM: case LONG_PRESS_POWER_GO_TO_VOICE_ASSIST: case LONG_PRESS_POWER_GO_TO_SLEEP: break; case LONG_PRESS_POWER_ASSISTANT: setupAssistForLaunch(); Loading