diff options
| author | 2021-08-20 20:15:30 +0000 | |
|---|---|---|
| committer | 2021-08-20 20:15:30 +0000 | |
| commit | 2cb04ea64ed4bc656584d5f96fcb10da6980faf9 (patch) | |
| tree | 3e7b66bae49ec43a1dd390f471fff0ded7d293fb | |
| parent | 7d4fff3c3374eccd9af6cd16ccd5236a5894d993 (diff) | |
| parent | a46335970d18cd7b0d21d566bd6c8d36c164fb20 (diff) | |
Fixes two bright flashes of the notification scrim am: ddefd45358 am: a46335970d
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15638985
Change-Id: I34aeea0aac065fc9aead8e85f98bd439da2d4418
4 files changed, 59 insertions, 4 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 b3e8dc402f28..e3319e5ef200 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java @@ -111,6 +111,20 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump */ private boolean mTransitioningToFullShade; + /** + * Is there currently an unocclusion animation running. Used to avoid bright flickers + * of the notification scrim. + */ + private boolean mUnOcclusionAnimationRunning; + + /** + * Set whether an unocclusion animation is currently running on the notification panel. Used + * to avoid bright flickers of the notification scrim. + */ + public void setUnocclusionAnimationRunning(boolean unocclusionAnimationRunning) { + mUnOcclusionAnimationRunning = unocclusionAnimationRunning; + } + @IntDef(prefix = {"VISIBILITY_"}, value = { TRANSPARENT, SEMI_TRANSPARENT, @@ -436,6 +450,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump public void onExpandingFinished() { mTracking = false; + setUnocclusionAnimationRunning(false); } @VisibleForTesting @@ -679,6 +694,10 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump if (mKeyguardOccluded) { mNotificationsAlpha = 0; } + if (mUnOcclusionAnimationRunning && mState == ScrimState.KEYGUARD) { + // We're unoccluding the keyguard and don't want to have a bright flash. + mNotificationsAlpha = 0f; + } } assertAlphasValid(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java index 8371407cdafa..be0130899e61 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java @@ -3092,6 +3092,7 @@ public class StatusBar extends SystemUI implements public void animateKeyguardUnoccluding() { mNotificationPanelViewController.setExpandedFraction(0f); mCommandQueueCallbacks.animateExpandNotificationsPanel(); + mScrimController.setUnocclusionAnimationRunning(true); } /** @@ -3755,10 +3756,8 @@ public class StatusBar extends SystemUI implements ScrimState state = mStatusBarKeyguardViewManager.bouncerNeedsScrimming() ? ScrimState.BOUNCER_SCRIMMED : ScrimState.BOUNCER; mScrimController.transitionTo(state); - } else if (isInLaunchTransition() - || mLaunchCameraWhenFinishedWaking - || launchingAffordanceWithPreview) { - // TODO(b/170133395) Investigate whether Emergency Gesture flag should be included here. + } else if (launchingAffordanceWithPreview) { + // We want to avoid animating when launching with a preview. mScrimController.transitionTo(ScrimState.UNLOCKED, mUnlockScrimCallback); } else if (mBrightnessMirrorVisible) { mScrimController.transitionTo(ScrimState.BRIGHTNESS_MIRROR); 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 30fc13b168f3..195390347d1c 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 @@ -1139,6 +1139,19 @@ public class ScrimControllerTest extends SysuiTestCase { } @Test + public void testNotificationTransparency_unnocclusion() { + mScrimController.transitionTo(ScrimState.KEYGUARD); + mScrimController.setUnocclusionAnimationRunning(true); + + assertAlphaAfterExpansion(mNotificationsScrim, /* alpha */ 0.0f, /* expansion */ 0.0f); + assertAlphaAfterExpansion(mNotificationsScrim, /* alpha */ 0.0f, /* expansion */ 1.0f); + + // Verify normal behavior after + mScrimController.setUnocclusionAnimationRunning(false); + assertAlphaAfterExpansion(mNotificationsScrim, /* alpha */ 0.2f, /* expansion */ 0.4f); + } + + @Test public void testNotificationTransparency_inKeyguardState() { mScrimController.transitionTo(ScrimState.KEYGUARD); diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java index 6c59c3e27f23..71c61ab7f9b7 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java @@ -775,6 +775,30 @@ public class StatusBarTest extends SysuiTestCase { } @Test + public void testTransitionLaunch_goesToUnlocked() { + mStatusBar.setBarStateForTest(StatusBarState.KEYGUARD); + mStatusBar.showKeyguardImpl(); + + // Starting a pulse should change the scrim controller to the pulsing state + when(mNotificationPanelViewController.isLaunchTransitionRunning()).thenReturn(true); + when(mNotificationPanelViewController.isLaunchingAffordanceWithPreview()).thenReturn(true); + mStatusBar.updateScrimController(); + verify(mScrimController).transitionTo(eq(ScrimState.UNLOCKED), any()); + } + + @Test + public void testTransitionLaunch_noPreview_doesntGoUnlocked() { + mStatusBar.setBarStateForTest(StatusBarState.KEYGUARD); + mStatusBar.showKeyguardImpl(); + + // Starting a pulse should change the scrim controller to the pulsing state + when(mNotificationPanelViewController.isLaunchTransitionRunning()).thenReturn(true); + when(mNotificationPanelViewController.isLaunchingAffordanceWithPreview()).thenReturn(false); + mStatusBar.updateScrimController(); + verify(mScrimController).transitionTo(eq(ScrimState.KEYGUARD)); + } + + @Test public void testSetOccluded_propagatesToScrimController() { mStatusBar.setOccluded(true); verify(mScrimController).setKeyguardOccluded(eq(true)); |