From 3ca0c57064999e7c48548a72355531aafc6f126e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A1s=20Kurucz?= Date: Thu, 11 May 2023 20:29:26 +0000 Subject: [PATCH] Fix LightReveal Scrim animation flickering Sometimes the NotificationShadeWindow was becoming invisible during a LightReveal Scrim animation causing it to flicker. A reliable repro: - have a device with AOD on - send a HUN and press the power button while the HUN is HUNning - this will make the HUN to animate away - the end of the animation triggers a call on NotificationPanelViewController#updateExpansionAndVisibility() - which checks NPVC#isExpanded, which at the moment thinks that there is no reason to keep the NotificationShade open, so it tries to close it This fix adds a check to NPVC#isExpanded to see if we have the UnlockedScreenOff animation running. Note: `UnlockedScreenOffAnimationController#startAnimation()` does a call to NPVC#showAodUi() which sets a property (expansionFraction), which makes the NPVC#isExpanded() `true`, but it is fired async to fix another animation issue, so there is a window where NPVC#isExpanded() needs this new condition to keep the shade visible. Test: post a HUN, lock the device, and observe the animation Test: atest NotificationPanelViewControllerTest Fixes: b/278810768 Change-Id: I326bce6b6d636301f9e1f17f49dfdb4252289aa5 --- .../NotificationPanelViewController.java | 5 +++ .../NotificationPanelViewControllerTest.java | 37 +++++++++++++++++-- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java index 926ede99f5a9c..f3ecb15f15d5a 100644 --- a/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/shade/NotificationPanelViewController.java @@ -2908,6 +2908,10 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump && mBarState == StatusBarState.SHADE; } + private boolean isPanelVisibleBecauseScrimIsAnimatingOff() { + return mUnlockedScreenOffAnimationController.isAnimationPlaying(); + } + @Override public boolean shouldHideStatusBarIconsWhenExpanded() { if (mIsLaunchAnimationRunning) { @@ -3967,6 +3971,7 @@ public final class NotificationPanelViewController implements ShadeSurface, Dump || isPanelVisibleBecauseOfHeadsUp() || mTracking || mHeightAnimator != null + || isPanelVisibleBecauseScrimIsAnimatingOff() && !mIsSpringBackAnimation; } diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java index 48e0b53fc931e..10e3ff3af9f55 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerTest.java @@ -1099,7 +1099,7 @@ public class NotificationPanelViewControllerTest extends NotificationPanelViewCo } @Test - public void shadeExpanded_inShadeState() { + public void shadeFullyExpanded_inShadeState() { mStatusBarStateController.setState(SHADE); mNotificationPanelViewController.setExpandedHeight(0); @@ -1111,7 +1111,7 @@ public class NotificationPanelViewControllerTest extends NotificationPanelViewCo } @Test - public void shadeExpanded_onKeyguard() { + public void shadeFullyExpanded_onKeyguard() { mStatusBarStateController.setState(KEYGUARD); int transitionDistance = mNotificationPanelViewController.getMaxPanelTransitionDistance(); @@ -1120,8 +1120,39 @@ public class NotificationPanelViewControllerTest extends NotificationPanelViewCo } @Test - public void shadeExpanded_onShadeLocked() { + public void shadeFullyExpanded_onShadeLocked() { mStatusBarStateController.setState(SHADE_LOCKED); assertThat(mNotificationPanelViewController.isShadeFullyExpanded()).isTrue(); } + + @Test + public void shadeExpanded_whenHasHeight() { + int transitionDistance = mNotificationPanelViewController.getMaxPanelTransitionDistance(); + mNotificationPanelViewController.setExpandedHeight(transitionDistance); + assertThat(mNotificationPanelViewController.isExpanded()).isTrue(); + } + + @Test + public void shadeExpanded_whenInstantExpanding() { + mNotificationPanelViewController.expand(true); + assertThat(mNotificationPanelViewController.isExpanded()).isTrue(); + } + + @Test + public void shadeExpanded_whenHunIsPresent() { + when(mHeadsUpManager.hasPinnedHeadsUp()).thenReturn(true); + assertThat(mNotificationPanelViewController.isExpanded()).isTrue(); + } + + @Test + public void shadeExpanded_whenWaitingForExpandGesture() { + mNotificationPanelViewController.startWaitingForExpandGesture(); + assertThat(mNotificationPanelViewController.isExpanded()).isTrue(); + } + + @Test + public void shadeExpanded_whenUnlockedOffscreenAnimationRunning() { + when(mUnlockedScreenOffAnimationController.isAnimationPlaying()).thenReturn(true); + assertThat(mNotificationPanelViewController.isExpanded()).isTrue(); + } }