diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 36c939d1156e4..d6418d0829a31 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -1614,7 +1614,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 798839dcc1f63..804960dc3b181 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java @@ -167,6 +167,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);