From 4750e9657daa2c0efa553980922659b30ee5522e Mon Sep 17 00:00:00 2001 From: Matt Pietal Date: Tue, 29 Nov 2022 14:15:24 +0000 Subject: [PATCH] Fix keyguard -> shade_locked scrim transition A recent fix to not apply the bouncer scrim exposed this bug, where pulling down the shade over the lockscreen was not correctly setting the notif scrim. Remove the hardcoded BLACK value, and align with all other ScrimStates to use conditional logic for mClipsQsScrim. Fixes: 259684978 Test: atest ScrimControllerTest Test: manual pull down shade and use bouncer over lockscreen, in regular and split shade modes Change-Id: I057fad9149523e418f909bade90490effdc26eb5 --- .../statusbar/phone/ScrimController.java | 9 +++++---- .../systemui/statusbar/phone/ScrimState.java | 8 +------- .../statusbar/phone/ScrimControllerTest.java | 16 +++++++++++++++- 3 files changed, 21 insertions(+), 12 deletions(-) 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 fb0d3e4406bf6..d500f999b5e2b 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java @@ -352,6 +352,11 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump .getBoolean(R.bool.notification_scrim_transparent); updateScrims(); mKeyguardUpdateMonitor.registerCallback(mKeyguardVisibilityCallback); + + // prepare() sets proper initial values for most states + for (ScrimState state : ScrimState.values()) { + state.prepare(state); + } } /** @@ -641,10 +646,6 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump private void setTransitionToFullShade(boolean transitioning) { if (transitioning != mTransitioningToFullShade) { mTransitioningToFullShade = transitioning; - if (transitioning) { - // Let's make sure the shade locked is ready - ScrimState.SHADE_LOCKED.prepare(mState); - } } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java index 52430d33cbf08..0e9d3ce33d5b1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimState.java @@ -146,18 +146,12 @@ public enum ScrimState { mBehindAlpha = mClipQsScrim ? 1 : mDefaultScrimAlpha; mNotifAlpha = 1f; mFrontAlpha = 0f; - mBehindTint = Color.BLACK; + mBehindTint = mClipQsScrim ? Color.TRANSPARENT : Color.BLACK; if (mClipQsScrim) { updateScrimColor(mScrimBehind, 1f /* alpha */, Color.BLACK); } } - - // to make sure correct color is returned before "prepare" is called - @Override - public int getBehindTint() { - return Color.BLACK; - } }, /** 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 de71e2c250c4e..e4759057a59ca 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 @@ -1442,16 +1442,30 @@ public class ScrimControllerTest extends SysuiTestCase { @Test public void testNotificationTransparency_followsTransitionToFullShade() { + mScrimController.setClipsQsScrim(true); + mScrimController.transitionTo(SHADE_LOCKED); mScrimController.setRawPanelExpansionFraction(1.0f); finishAnimationsImmediately(); + + assertScrimTinted(Map.of( + mScrimInFront, false, + mScrimBehind, true, + mNotificationsScrim, false + )); + float shadeLockedAlpha = mNotificationsScrim.getViewAlpha(); mScrimController.transitionTo(ScrimState.KEYGUARD); mScrimController.setRawPanelExpansionFraction(1.0f); finishAnimationsImmediately(); float keyguardAlpha = mNotificationsScrim.getViewAlpha(); - mScrimController.setClipsQsScrim(true); + assertScrimTinted(Map.of( + mScrimInFront, true, + mScrimBehind, true, + mNotificationsScrim, true + )); + float progress = 0.5f; float lsNotifProgress = 0.3f; mScrimController.setTransitionToFullShadeProgress(progress, lsNotifProgress);