Loading services/core/java/com/android/server/policy/PhoneWindowManager.java +2 −6 Original line number Diff line number Diff line Loading @@ -917,7 +917,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } else { // handled by another power key policy. if (!mSingleKeyGestureDetector.isKeyIntercepted(KEYCODE_POWER)) { if (mSingleKeyGestureDetector.isKeyIntercepted(KEYCODE_POWER)) { Slog.d(TAG, "Skip power key gesture for other policy has handled it."); mSingleKeyGestureDetector.reset(); } } Loading @@ -931,11 +932,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { // Abort possibly stuck animations only when power key up without long press case. mHandler.post(mWindowManagerFuncs::triggerAnimationFailsafe); } } else { // handled by single key or another power key policy. if (!mSingleKeyGestureDetector.isKeyIntercepted(KEYCODE_POWER)) { mSingleKeyGestureDetector.reset(); } } finishPowerKeyPress(); Loading services/tests/wmtests/src/com/android/server/policy/PowerKeyGestureTests.java +14 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static android.view.KeyEvent.KEYCODE_VOLUME_UP; import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_ASSISTANT; import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_GLOBAL_ACTIONS; import android.provider.Settings; import android.view.Display; import org.junit.Test; Loading Loading @@ -81,4 +82,17 @@ public class PowerKeyGestureTests extends ShortcutKeyTestBase { sendKeyCombination(new int[]{KEYCODE_POWER, KEYCODE_VOLUME_UP}, 0); mPhoneWindowManager.assertNoPowerSleep(); } /** * When a phone call is active, and INCALL_POWER_BUTTON_BEHAVIOR_HANGUP is enabled, then the * power button should only stop phone call. The screen should not be turned off (power sleep * should not be activated). */ @Test public void testIgnoreSinglePressWhenEndCall() { mPhoneWindowManager.overrideIncallPowerBehavior( Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP); sendKey(KEYCODE_POWER); mPhoneWindowManager.assertNoPowerSleep(); } } services/tests/wmtests/src/com/android/server/policy/TestPhoneWindowManager.java +12 −0 Original line number Diff line number Diff line Loading @@ -298,6 +298,18 @@ class TestPhoneWindowManager { Mockito.reset(mPowerManager); } void overrideIncallPowerBehavior(int behavior) { mPhoneWindowManager.mIncallPowerBehavior = behavior; setPhoneCallIsInProgress(); } void setPhoneCallIsInProgress() { // Let device has an ongoing phone call. doReturn(false).when(mTelecomManager).isRinging(); doReturn(true).when(mTelecomManager).isInCall(); doReturn(true).when(mTelecomManager).endCall(); } /** * Below functions will check the policy behavior could be invoked. */ Loading Loading
services/core/java/com/android/server/policy/PhoneWindowManager.java +2 −6 Original line number Diff line number Diff line Loading @@ -917,7 +917,8 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } else { // handled by another power key policy. if (!mSingleKeyGestureDetector.isKeyIntercepted(KEYCODE_POWER)) { if (mSingleKeyGestureDetector.isKeyIntercepted(KEYCODE_POWER)) { Slog.d(TAG, "Skip power key gesture for other policy has handled it."); mSingleKeyGestureDetector.reset(); } } Loading @@ -931,11 +932,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { // Abort possibly stuck animations only when power key up without long press case. mHandler.post(mWindowManagerFuncs::triggerAnimationFailsafe); } } else { // handled by single key or another power key policy. if (!mSingleKeyGestureDetector.isKeyIntercepted(KEYCODE_POWER)) { mSingleKeyGestureDetector.reset(); } } finishPowerKeyPress(); Loading
services/tests/wmtests/src/com/android/server/policy/PowerKeyGestureTests.java +14 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static android.view.KeyEvent.KEYCODE_VOLUME_UP; import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_ASSISTANT; import static com.android.server.policy.PhoneWindowManager.LONG_PRESS_POWER_GLOBAL_ACTIONS; import android.provider.Settings; import android.view.Display; import org.junit.Test; Loading Loading @@ -81,4 +82,17 @@ public class PowerKeyGestureTests extends ShortcutKeyTestBase { sendKeyCombination(new int[]{KEYCODE_POWER, KEYCODE_VOLUME_UP}, 0); mPhoneWindowManager.assertNoPowerSleep(); } /** * When a phone call is active, and INCALL_POWER_BUTTON_BEHAVIOR_HANGUP is enabled, then the * power button should only stop phone call. The screen should not be turned off (power sleep * should not be activated). */ @Test public void testIgnoreSinglePressWhenEndCall() { mPhoneWindowManager.overrideIncallPowerBehavior( Settings.Secure.INCALL_POWER_BUTTON_BEHAVIOR_HANGUP); sendKey(KEYCODE_POWER); mPhoneWindowManager.assertNoPowerSleep(); } }
services/tests/wmtests/src/com/android/server/policy/TestPhoneWindowManager.java +12 −0 Original line number Diff line number Diff line Loading @@ -298,6 +298,18 @@ class TestPhoneWindowManager { Mockito.reset(mPowerManager); } void overrideIncallPowerBehavior(int behavior) { mPhoneWindowManager.mIncallPowerBehavior = behavior; setPhoneCallIsInProgress(); } void setPhoneCallIsInProgress() { // Let device has an ongoing phone call. doReturn(false).when(mTelecomManager).isRinging(); doReturn(true).when(mTelecomManager).isInCall(); doReturn(true).when(mTelecomManager).endCall(); } /** * Below functions will check the policy behavior could be invoked. */ Loading