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

Commit 218a0cb4 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Hide wallpaper when backdrop arrives

Some apps may set a backdrop image after the device enters doze,
causing the artwork to be visible in AOD. Let's draw black.

Test: manual
Test: packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java
Change-Id: Ib13e14f285594349c1df263f713883449884ff00
Fixes: 110959983
parent c4cf07a1
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -892,6 +892,16 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
        for (ScrimState state : ScrimState.values()) {
            state.setHasBackdrop(hasBackdrop);
        }

        // Backdrop event may arrive after state was already applied,
        // in this case, back-scrim needs to be re-evaluated
        if (mState == ScrimState.AOD || mState == ScrimState.PULSING) {
            float newBehindAlpha = mState.getBehindAlpha(mNotificationDensity);
            if (mCurrentBehindAlpha != newBehindAlpha) {
                mCurrentBehindAlpha = newBehindAlpha;
                updateScrims();
            }
        }
    }

    public void setLaunchingAffordanceWithPreview(boolean launchingAffordanceWithPreview) {
+10 −2
Original line number Diff line number Diff line
@@ -105,7 +105,6 @@ public enum ScrimState {
        public void prepare(ScrimState previousState) {
            final boolean alwaysOnEnabled = mDozeParameters.getAlwaysOn();
            mBlankScreen = mDisplayRequiresBlanking;
            mCurrentBehindAlpha = mWallpaperSupportsAmbientMode && !mHasBackdrop ? 0f : 1f;
            mCurrentInFrontAlpha = alwaysOnEnabled ? mAodFrontScrimAlpha : 1f;
            mCurrentInFrontTint = Color.BLACK;
            mCurrentBehindTint = Color.BLACK;
@@ -115,6 +114,11 @@ public enum ScrimState {
            mAnimateChange = mDozeParameters.shouldControlScreenOff();
        }

        @Override
        public float getBehindAlpha(float busyness) {
            return mWallpaperSupportsAmbientMode && !mHasBackdrop ? 0f : 1f;
        }

        @Override
        public boolean isLowPowerState() {
            return true;
@@ -129,10 +133,14 @@ public enum ScrimState {
        public void prepare(ScrimState previousState) {
            mCurrentInFrontAlpha = 0;
            mCurrentInFrontTint = Color.BLACK;
            mCurrentBehindAlpha = mWallpaperSupportsAmbientMode && !mHasBackdrop ? 0f : 1f;
            mCurrentBehindTint = Color.BLACK;
            mBlankScreen = mDisplayRequiresBlanking;
        }

        @Override
        public float getBehindAlpha(float busyness) {
            return mWallpaperSupportsAmbientMode && !mHasBackdrop ? 0f : 1f;
        }
    },

    /**
+14 −0
Original line number Diff line number Diff line
@@ -151,6 +151,20 @@ public class ScrimControllerTest extends SysuiTestCase {
        assertScrimTint(mScrimInFront, true /* tinted */);
    }

    @Test
    public void setHasBackdrop_withAodWallpaperAndAlbumArt() {
        mScrimController.setWallpaperSupportsAmbientMode(true);
        mScrimController.transitionTo(ScrimState.AOD);
        mScrimController.finishAnimationsImmediately();
        mScrimController.setHasBackdrop(true);
        mScrimController.finishAnimationsImmediately();
        // Front scrim should be transparent
        // Back scrim should be visible with tint
        assertScrimVisibility(VISIBILITY_FULLY_TRANSPARENT, VISIBILITY_FULLY_OPAQUE);
        assertScrimTint(mScrimBehind, true /* tinted */);
        assertScrimTint(mScrimInFront, true /* tinted */);
    }

    @Test
    public void transitionToAod_withFrontAlphaUpdates() {
        // Assert that setting the AOD front scrim alpha doesn't take effect in a non-AOD state.