From 4bb7522ab074a62b3d569a5e51fdf254b2dea7ac Mon Sep 17 00:00:00 2001 From: Josh Tsuji Date: Tue, 6 Dec 2022 15:56:52 -0500 Subject: [PATCH] Don't re-lock if we're wake and unlocking. This can make the wallpaper visible through the scrim if you wake and unlock during the screen off animation. Fixes: 261440698 Test: wake and unlock during screen off repeatedly Change-Id: I6d48dc2211e16b88168e03a56f338222b582b97b --- .../keyguard/KeyguardViewMediator.java | 2 +- .../keyguard/KeyguardViewMediatorTest.java | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 6ed555056cb1b..b50ce519a8790 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -1613,7 +1613,7 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, // TODO: Rename all screen off/on references to interactive/sleeping synchronized (this) { mDeviceInteractive = true; - if (mPendingLock && !cameraGestureTriggered) { + if (mPendingLock && !cameraGestureTriggered && !mWakeAndUnlocking) { doKeyguardLocked(null); } mAnimatingScreenOff = false; diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java index d17e3744edc68..7528f6e02fd2c 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java @@ -141,6 +141,45 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { verify(mStatusBarKeyguardViewManager, never()).setKeyguardGoingAwayState(anyBoolean()); } + @Test + @TestableLooper.RunWithLooper(setAsMainLooper = true) + public void testOnStartedWakingUp_whileSleeping_ifWakeAndUnlocking_doesNotShowKeyguard() { + when(mLockPatternUtils.isLockScreenDisabled(anyInt())).thenReturn(false); + when(mLockPatternUtils.getPowerButtonInstantlyLocks(anyInt())).thenReturn(true); + mViewMediator.onSystemReady(); + TestableLooper.get(this).processAllMessages(); + + mViewMediator.setShowingLocked(false); + TestableLooper.get(this).processAllMessages(); + + mViewMediator.onStartedGoingToSleep(OFF_BECAUSE_OF_USER); + mViewMediator.onWakeAndUnlocking(); + mViewMediator.onStartedWakingUp(OFF_BECAUSE_OF_USER, false); + TestableLooper.get(this).processAllMessages(); + + assertFalse(mViewMediator.isShowingAndNotOccluded()); + verify(mKeyguardStateController, never()).notifyKeyguardState(eq(true), anyBoolean()); + } + + @Test + @TestableLooper.RunWithLooper(setAsMainLooper = true) + public void testOnStartedWakingUp_whileSleeping_ifNotWakeAndUnlocking_showsKeyguard() { + when(mLockPatternUtils.isLockScreenDisabled(anyInt())).thenReturn(false); + when(mLockPatternUtils.getPowerButtonInstantlyLocks(anyInt())).thenReturn(true); + mViewMediator.onSystemReady(); + TestableLooper.get(this).processAllMessages(); + + mViewMediator.setShowingLocked(false); + TestableLooper.get(this).processAllMessages(); + + mViewMediator.onStartedGoingToSleep(OFF_BECAUSE_OF_USER); + mViewMediator.onStartedWakingUp(OFF_BECAUSE_OF_USER, false); + + TestableLooper.get(this).processAllMessages(); + + assertTrue(mViewMediator.isShowingAndNotOccluded()); + } + @Test public void testRegisterDumpable() { verify(mDumpManager).registerDumpable(KeyguardViewMediator.class.getName(), mViewMediator);