Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3ca0c570 authored by András Kurucz's avatar András Kurucz
Browse files

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
parent b75484c0
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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;
    }

+34 −3
Original line number Diff line number Diff line
@@ -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();
    }
}