From 8f26dfb58ecc5fb7366b69af53330a9137493586 Mon Sep 17 00:00:00 2001 From: Hawkwood Glazier Date: Mon, 6 Feb 2023 20:05:31 +0000 Subject: [PATCH] Fix other reproduction of invisible keyguard race Similar to Id20a300edfa52433642747dbcdb1ecceeffadba8, the keyguard becomes invisible after the keyguard erronously enters a bad state due to racing unlock and lock requests from the user. This corrects it for this reproduction by cancelling the inprogress unlock animation. Bug: 267711359 Test: Manually tested on device Change-Id: I6985a667827ac068af8e2eb5756edc30f7545cd9 --- .../systemui/statusbar/phone/CentralSurfacesImpl.java | 3 +++ .../statusbar/phone/CentralSurfacesImplTest.java | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java index 85399ca22d968..ccade375a9409 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfacesImpl.java @@ -3753,6 +3753,9 @@ public class CentralSurfacesImpl implements CoreStartable, CentralSurfaces { } else { mScrimController.transitionTo(ScrimState.AUTH_SCRIMMED); } + // This will cancel the keyguardFadingAway animation if it is running. We need to do + // this as otherwise it can remain pending and leave keyguard in a weird state. + mUnlockScrimCallback.onCancelled(); } else if (mBouncerShowing && !unlocking) { // Bouncer needs the front scrim when it's on top of an activity, // tapping on a notification, editing QS or being dismissed by diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java index 06053987202ce..14a8bdc4542a3 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesImplTest.java @@ -1021,6 +1021,17 @@ public class CentralSurfacesImplTest extends SysuiTestCase { verify(mStatusBarKeyguardViewManager).onKeyguardFadedAway(); } + @Test + public void testSetDozingNotUnlocking_transitionToAuthScrimmed_cancelKeyguardFadingAway() { + when(mAlternateBouncerInteractor.isVisibleState()).thenReturn(true); + when(mKeyguardStateController.isKeyguardFadingAway()).thenReturn(true); + + mCentralSurfaces.updateScrimController(); + + verify(mScrimController).transitionTo(eq(ScrimState.AUTH_SCRIMMED_SHADE)); + verify(mStatusBarKeyguardViewManager).onKeyguardFadedAway(); + } + @Test public void testShowKeyguardImplementation_setsState() { when(mLockscreenUserManager.getCurrentProfiles()).thenReturn(new SparseArray<>());