From 8a07d3e6e8d7f207a2a34230c0c708156eebe556 Mon Sep 17 00:00:00 2001 From: Matt Pietal Date: Mon, 7 Mar 2022 13:03:02 -0500 Subject: [PATCH] Revert^2 "Scrim was flickering on FPS unlock" 5c62dd44b9554dd2ac1f13c6101e414a5d456ffc Change-Id: I94ed141db8f137f28238c46ebcf3259ee7207178 --- .../systemui/statusbar/phone/CentralSurfaces.java | 11 +++++------ .../systemui/statusbar/phone/ScrimController.java | 2 +- .../systemui/statusbar/phone/CentralSurfacesTest.java | 2 ++ .../systemui/statusbar/phone/ScrimControllerTest.java | 6 ++---- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java index 84adc5679a814..a7f950eaf167f 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/CentralSurfaces.java @@ -663,7 +663,6 @@ public class CentralSurfaces extends CoreStartable implements protected final BatteryController mBatteryController; protected boolean mPanelExpanded; private UiModeManager mUiModeManager; - protected boolean mIsKeyguard; private LogMaker mStatusBarStateLog; protected final NotificationIconAreaController mNotificationIconAreaController; @Nullable private View mAmbientIndicationContainer; @@ -1142,7 +1141,7 @@ public class CentralSurfaces extends CoreStartable implements } if (leaveOpen) { mStatusBarStateController.setLeaveOpenOnKeyguardHide(true); - if (mIsKeyguard) { + if (mKeyguardStateController.isShowing()) { // When device state changes on keyguard we don't want to keep the state of // the shade and instead we open clean state of keyguard with shade closed. // Normally some parts of QS state (like expanded/collapsed) are persisted and @@ -2890,7 +2889,9 @@ public class CentralSurfaces extends CoreStartable implements // late in the transition, so we also allow the device to start dozing once the screen has // turned off fully. boolean keyguardForDozing = mDozeServiceHost.getDozingRequested() - && (!mDeviceInteractive || isGoingToSleep() && (isScreenFullyOff() || mIsKeyguard)); + && (!mDeviceInteractive || (isGoingToSleep() + && (isScreenFullyOff() + || (mKeyguardStateController.isShowing() && !isOccluded())))); boolean isWakingAndOccluded = isOccluded() && isWaking(); boolean shouldBeKeyguard = (mStatusBarStateController.isKeyguardRequested() || keyguardForDozing) && !wakeAndUnlocking && !isWakingAndOccluded; @@ -2923,7 +2924,6 @@ public class CentralSurfaces extends CoreStartable implements public void showKeyguardImpl() { Trace.beginSection("CentralSurfaces#showKeyguard"); - mIsKeyguard = true; // In case we're locking while a smartspace transition is in progress, reset it. mKeyguardUnlockAnimationController.resetSmartspaceTransition(); if (mKeyguardStateController.isLaunchTransitionFadingAway()) { @@ -3044,7 +3044,6 @@ public class CentralSurfaces extends CoreStartable implements * @return true if we would like to stay in the shade, false if it should go away entirely */ public boolean hideKeyguardImpl(boolean forceStateChange) { - mIsKeyguard = false; Trace.beginSection("CentralSurfaces#hideKeyguard"); boolean staying = mStatusBarStateController.leaveOpenOnKeyguardHide(); int previousState = mStatusBarStateController.getState(); @@ -3771,7 +3770,7 @@ public class CentralSurfaces extends CoreStartable implements }); } else if (mDozing && !unlocking) { mScrimController.transitionTo(ScrimState.AOD); - } else if (mIsKeyguard && !unlocking) { + } else if (mKeyguardStateController.isShowing() && !isOccluded() && !unlocking) { mScrimController.transitionTo(ScrimState.KEYGUARD); } else { mScrimController.transitionTo(ScrimState.UNLOCKED, mUnlockScrimCallback); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java index a3c795f36d5d5..419661b766d69 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java @@ -773,7 +773,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump } if (mUnOcclusionAnimationRunning && mState == ScrimState.KEYGUARD) { // We're unoccluding the keyguard and don't want to have a bright flash. - mNotificationsAlpha = mScrimBehindAlphaKeyguard; + mNotificationsAlpha = ScrimState.KEYGUARD.getNotifAlpha(); mNotificationsTint = ScrimState.KEYGUARD.getNotifTint(); } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesTest.java index 953a330d2e65c..3810783d4f768 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/CentralSurfacesTest.java @@ -846,6 +846,7 @@ public class CentralSurfacesTest extends SysuiTestCase { @Test public void testTransitionLaunch_noPreview_doesntGoUnlocked() { mCentralSurfaces.setBarStateForTest(StatusBarState.KEYGUARD); + when(mKeyguardStateController.isShowing()).thenReturn(true); mCentralSurfaces.showKeyguardImpl(); // Starting a pulse should change the scrim controller to the pulsing state @@ -868,6 +869,7 @@ public class CentralSurfacesTest extends SysuiTestCase { @Test public void testPulseWhileDozing_updatesScrimController() { mCentralSurfaces.setBarStateForTest(StatusBarState.KEYGUARD); + when(mKeyguardStateController.isShowing()).thenReturn(true); mCentralSurfaces.showKeyguardImpl(); // Starting a pulse should change the scrim controller to the pulsing state diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java index 10f4435d3f97a..0b25467d20d8e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java @@ -1234,10 +1234,8 @@ public class ScrimControllerTest extends SysuiTestCase { mScrimController.transitionTo(ScrimState.KEYGUARD); mScrimController.setUnocclusionAnimationRunning(true); - assertAlphaAfterExpansion(mNotificationsScrim, /* alpha */ KEYGUARD_SCRIM_ALPHA, - /* expansion */ 0.0f); - assertAlphaAfterExpansion(mNotificationsScrim, /* alpha */ KEYGUARD_SCRIM_ALPHA, - /* expansion */ 1.0f); + assertAlphaAfterExpansion(mNotificationsScrim, /* alpha */ 0f, /* expansion */ 0f); + assertAlphaAfterExpansion(mNotificationsScrim, /* alpha */ 0f, /* expansion */ 1.0f); // Verify normal behavior after mScrimController.setUnocclusionAnimationRunning(false);