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

Commit ddefd453 authored by Selim Cinek's avatar Selim Cinek
Browse files

Fixes two bright flashes of the notification scrim

We were previously going to UNLOCKED state if if there was no camera
preview leading to a bright flash in light mode. we now only do this
when the whole screen is obscured anyway by the camera preview.
This also fixes another scrim issue where the unocclusion would
flash the notification scrim, because it's expanding, which
usually shows the bouncer with a bright background during the
expansion.

Test: atest SystemUITests
Fixes: 197160246
Change-Id: I418e878698c2606856b93faf774cd87830773815
parent 7aedd374
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -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();
+3 −4
Original line number Diff line number Diff line
@@ -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);
+13 −0
Original line number Diff line number Diff line
@@ -1138,6 +1138,19 @@ public class ScrimControllerTest extends SysuiTestCase {
        assertAlphaAfterExpansion(mNotificationsScrim, /* alpha */ 0.47f, /* expansion */ 0.2f);
    }

    @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);
+24 −0
Original line number Diff line number Diff line
@@ -774,6 +774,30 @@ public class StatusBarTest extends SysuiTestCase {
        verify(mScrimController).transitionTo(eq(ScrimState.UNLOCKED), any());
    }

    @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);