diff options
| author | 2024-10-09 15:35:44 +0000 | |
|---|---|---|
| committer | 2024-10-09 15:51:07 +0000 | |
| commit | b8c444b99a7afcfd46c6ff1a426859b54b4c82db (patch) | |
| tree | e8438a8bff3d4422afaaada0c64f1006ac36ce40 | |
| parent | c6ac402ead66e7e489795a152c30f1690797e7ff (diff) | |
Prevent UnlockAnimationController from dismissing keyguard...
... on exit animation cancel. When the animators are canceled,
they will still call exitKeyguardAndFinishSurfaceBehindRemoteAnimation()
which can then continue to dismiss the keyguard even though it
decided to just relock. Short circuit this call.
Seems to happen during a race condition with SIM PIN/PUK screens.
Fixes: 370748717
Test: atest KeyguardViewMediatorTest
Flag: com.android.systemui.relock_with_power_button_immediately
Change-Id: I42a0aaa221ed2120ad2cf8b2a4ab88c4685f692b
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java | 6 | ||||
| -rw-r--r-- | packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java | 28 |
2 files changed, 34 insertions, 0 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 2052459692b2..2dd2a1ea4d90 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -3428,6 +3428,12 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, return; } + if (mIsKeyguardExitAnimationCanceled) { + Log.d(TAG, "Ignoring exitKeyguardAndFinishSurfaceBehindRemoteAnimation. " + + "mIsKeyguardExitAnimationCanceled==true"); + return; + } + // Block the panel from expanding, in case we were doing a swipe to dismiss gesture. mKeyguardViewControllerLazy.get().blockPanelExpansionFromCurrentTouch(); final boolean wasShowing = mShowing; 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 6608542980b0..b3cccea97e08 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/KeyguardViewMediatorTest.java @@ -26,6 +26,7 @@ import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STR import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_NON_STRONG_BIOMETRICS_TIMEOUT; import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_USER_LOCKDOWN; import static com.android.systemui.Flags.FLAG_KEYGUARD_WM_STATE_REFACTOR; +import static com.android.systemui.Flags.FLAG_RELOCK_WITH_POWER_BUTTON_IMMEDIATELY; import static com.android.systemui.Flags.FLAG_SIM_PIN_BOUNCER_RESET; import static com.android.systemui.keyguard.KeyguardViewMediator.DELAYED_KEYGUARD_ACTION; import static com.android.systemui.keyguard.KeyguardViewMediator.KEYGUARD_LOCK_AFTER_DELAY_DEFAULT; @@ -63,6 +64,7 @@ import android.content.Context; import android.os.PowerManager; import android.os.PowerManager.WakeLock; import android.os.RemoteException; +import android.platform.test.annotations.DisableFlags; import android.platform.test.annotations.EnableFlags; import android.telephony.TelephonyManager; import android.testing.AndroidTestingRunner; @@ -841,6 +843,32 @@ public class KeyguardViewMediatorTest extends SysuiTestCase { @Test @TestableLooper.RunWithLooper(setAsMainLooper = true) + @EnableFlags(FLAG_RELOCK_WITH_POWER_BUTTON_IMMEDIATELY) + public void testCancelKeyguardExitAnimationDueToSleep_withPendingLockAndRelockFlag_keyguardWillBeShowing() { + startMockKeyguardExitAnimation(); + + mViewMediator.onStartedGoingToSleep(PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON); + mViewMediator.onFinishedGoingToSleep(PowerManager.GO_TO_SLEEP_REASON_POWER_BUTTON, false); + + cancelMockKeyguardExitAnimation(); + + mViewMediator.maybeHandlePendingLock(); + TestableLooper.get(this).processAllMessages(); + + assertTrue(mViewMediator.isShowingAndNotOccluded()); + + verify(mKeyguardUnlockAnimationController).notifyFinishedKeyguardExitAnimation(true); + + // Unlock animators call `exitKeyguardAndFinishSurfaceBehindRemoteAnimation` when canceled + mViewMediator.exitKeyguardAndFinishSurfaceBehindRemoteAnimation(false); + TestableLooper.get(this).processAllMessages(); + + verify(mUpdateMonitor, never()).dispatchKeyguardDismissAnimationFinished(); + } + + @Test + @TestableLooper.RunWithLooper(setAsMainLooper = true) + @DisableFlags(FLAG_RELOCK_WITH_POWER_BUTTON_IMMEDIATELY) public void testCancelKeyguardExitAnimationDueToSleep_withPendingLock_keyguardWillBeShowing() { startMockKeyguardExitAnimation(); |