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

Commit f8463ee0 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

Fade to black without showing system wallpaper

When on the lock screen, and going to AOD animated, user would
temporarily see the system wallpaper. That's not what we want,
we want to fade from semi-transparent black to black, on top
of the backdrop - lock screen wallpaper or media art.

Test: press power on the lock screen when playing media
Test: press power on the lock screen after dismissing media
Test: unlock from AOD
Test: atest packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java
Fixes: 80575770
Change-Id: I6796e844add889ff86be0cd2052db7c5d5073039
parent 70630354
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1589,6 +1589,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
        }
    }

    public boolean isKeyguardVisible() {
        return mKeyguardIsVisible;
    }

    /**
     * Notifies that the visibility state of Keyguard has changed.
     *
+5 −6
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import android.app.WallpaperManager;
import android.content.Context;
import android.os.Handler;
import android.os.RemoteException;
import android.os.Trace;
import android.os.UserHandle;
import android.util.Log;
import android.view.Display;
@@ -46,7 +45,7 @@ import java.util.Arrays;
public class SysuiColorExtractor extends ColorExtractor implements Dumpable {
    private static final String TAG = "SysuiColorExtractor";
    private boolean mWallpaperVisible;
    private boolean mMediaBackdropVisible;
    private boolean mHasBackdrop;
    // Colors to return when the wallpaper isn't visible
    private final GradientColors mWpHiddenColors;

@@ -165,7 +164,7 @@ public class SysuiColorExtractor extends ColorExtractor implements Dumpable {
                return mWpHiddenColors;
            }
        } else {
            if (mMediaBackdropVisible) {
            if (mHasBackdrop) {
                return mWpHiddenColors;
            } else {
                return super.getColors(which, type);
@@ -181,9 +180,9 @@ public class SysuiColorExtractor extends ColorExtractor implements Dumpable {
        }
    }

    public void setMediaBackdropVisible(boolean visible) {
        if (mMediaBackdropVisible != visible) {
            mMediaBackdropVisible = visible;
    public void setHasBackdrop(boolean hasBackdrop) {
        if (mHasBackdrop != hasBackdrop) {
            mHasBackdrop = hasBackdrop;
            triggerColorsChanged(WallpaperManager.FLAG_LOCK);
        }
    }
+15 −19
Original line number Diff line number Diff line
@@ -29,9 +29,7 @@ import android.os.Handler;
import android.os.Trace;
import android.util.Log;
import android.util.MathUtils;
import android.view.Choreographer;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
@@ -43,12 +41,11 @@ import com.android.internal.colorextraction.ColorExtractor.OnColorsChangedListen
import com.android.internal.graphics.ColorUtils;
import com.android.internal.util.function.TriConsumer;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.systemui.Dependency;
import com.android.systemui.Dumpable;
import com.android.systemui.R;
import com.android.systemui.colorextraction.SysuiColorExtractor;
import com.android.systemui.statusbar.ExpandableNotificationRow;
import com.android.systemui.statusbar.NotificationData;
import com.android.systemui.statusbar.ScrimView;
import com.android.systemui.statusbar.stack.ViewState;
import com.android.systemui.util.AlarmTimeout;
@@ -482,21 +479,13 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
        // Make sure we have the right gradients and their opacities will satisfy GAR.
        if (mNeedsDrawableColorUpdate) {
            mNeedsDrawableColorUpdate = false;
            final GradientColors currentScrimColors;
            if (mState == ScrimState.KEYGUARD || mState == ScrimState.BOUNCER_SCRIMMED
                    || mState == ScrimState.BOUNCER) {
                // Always animate color changes if we're seeing the keyguard
                mScrimInFront.setColors(mLockColors, true /* animated */);
                mScrimBehind.setColors(mLockColors, true /* animated */);
                currentScrimColors = mLockColors;
            } else {
            boolean isKeyguard = mKeyguardUpdateMonitor.isKeyguardVisible() && !mKeyguardOccluded;
            GradientColors currentScrimColors = isKeyguard ? mLockColors : mSystemColors;
            // Only animate scrim color if the scrim view is actually visible
                boolean animateScrimInFront = mScrimInFront.getViewAlpha() != 0;
                boolean animateScrimBehind = mScrimBehind.getViewAlpha() != 0;
                mScrimInFront.setColors(mSystemColors, animateScrimInFront);
                mScrimBehind.setColors(mSystemColors, animateScrimBehind);
                currentScrimColors = mSystemColors;
            }
            boolean animateScrimInFront = mScrimInFront.getViewAlpha() != 0 && !mBlankScreen;
            boolean animateScrimBehind = mScrimBehind.getViewAlpha() != 0 && !mBlankScreen;
            mScrimInFront.setColors(currentScrimColors, animateScrimInFront);
            mScrimBehind.setColors(currentScrimColors, animateScrimBehind);

            // Calculate minimum scrim opacity for white or black text.
            int textColor = currentScrimColors.supportsDarkText() ? Color.BLACK : Color.WHITE;
@@ -899,6 +888,13 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
        updateScrims();
    }

    public void setHasBackdrop(boolean hasBackdrop) {
        ScrimState[] states = ScrimState.values();
        for (int i = 0; i < states.length; i++) {
            states[i].setHasBackdrop(hasBackdrop);
        }
    }

    public interface Callback {
        default void onStart() {
        }
+7 −7
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.graphics.Color;
import android.os.Trace;
import android.util.MathUtils;

import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.systemui.statusbar.ScrimView;
import com.android.systemui.statusbar.stack.StackStateAnimator;

@@ -106,8 +105,7 @@ public enum ScrimState {
        public void prepare(ScrimState previousState) {
            final boolean alwaysOnEnabled = mDozeParameters.getAlwaysOn();
            mBlankScreen = mDisplayRequiresBlanking;
            mCurrentBehindAlpha = mWallpaperSupportsAmbientMode
                    && !mKeyguardUpdateMonitor.hasLockscreenWallpaper() ? 0f : 1f;
            mCurrentBehindAlpha = mWallpaperSupportsAmbientMode && !mHasBackdrop ? 0f : 1f;
            mCurrentInFrontAlpha = alwaysOnEnabled ? mAodFrontScrimAlpha : 1f;
            mCurrentInFrontTint = Color.BLACK;
            mCurrentBehindTint = Color.BLACK;
@@ -131,8 +129,7 @@ public enum ScrimState {
        public void prepare(ScrimState previousState) {
            mCurrentInFrontAlpha = 0;
            mCurrentInFrontTint = Color.BLACK;
            mCurrentBehindAlpha = mWallpaperSupportsAmbientMode
                    && !mKeyguardUpdateMonitor.hasLockscreenWallpaper() ? 0f : 1f;
            mCurrentBehindAlpha = mWallpaperSupportsAmbientMode && !mHasBackdrop ? 0f : 1f;
            mCurrentBehindTint = Color.BLACK;
            mBlankScreen = mDisplayRequiresBlanking;
        }
@@ -178,8 +175,8 @@ public enum ScrimState {
    DozeParameters mDozeParameters;
    boolean mDisplayRequiresBlanking;
    boolean mWallpaperSupportsAmbientMode;
    KeyguardUpdateMonitor mKeyguardUpdateMonitor;
    int mIndex;
    boolean mHasBackdrop;

    ScrimState(int index) {
        mIndex = index;
@@ -190,7 +187,6 @@ public enum ScrimState {
        mScrimBehind = scrimBehind;
        mDozeParameters = dozeParameters;
        mDisplayRequiresBlanking = dozeParameters.getDisplayNeedsBlanking();
        mKeyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(scrimInFront.getContext());
    }

    public void prepare(ScrimState previousState) {
@@ -256,4 +252,8 @@ public enum ScrimState {
    public boolean isLowPowerState() {
        return false;
    }

    public void setHasBackdrop(boolean hasBackdrop) {
        mHasBackdrop = hasBackdrop;
    }
}
 No newline at end of file
+6 −4
Original line number Diff line number Diff line
@@ -1651,8 +1651,12 @@ public class StatusBar extends SystemUI implements DemoMode,
                && mStatusBarKeyguardViewManager.isOccluded();

        final boolean hasArtwork = artworkDrawable != null;
        mColorExtractor.setHasBackdrop(hasArtwork);
        if (mScrimController != null) {
            mScrimController.setHasBackdrop(hasArtwork);
        }

        if ((hasArtwork || DEBUG_MEDIA_FAKE_ARTWORK) && !mDozing
        if ((hasArtwork || DEBUG_MEDIA_FAKE_ARTWORK)
                && (mState != StatusBarState.SHADE || allowWhenShade)
                && mFingerprintUnlockController.getMode()
                        != FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING
@@ -1668,7 +1672,6 @@ public class StatusBar extends SystemUI implements DemoMode,
                    mBackdrop.setAlpha(1f);
                }
                mStatusBarWindowManager.setBackdropShowing(true);
                mColorExtractor.setMediaBackdropVisible(true);
                metaDataChanged = true;
                if (DEBUG_MEDIA) {
                    Log.v(TAG, "DEBUG_MEDIA: Fading in album artwork");
@@ -1720,7 +1723,6 @@ public class StatusBar extends SystemUI implements DemoMode,
                if (DEBUG_MEDIA) {
                    Log.v(TAG, "DEBUG_MEDIA: Fading out album artwork");
                }
                mColorExtractor.setMediaBackdropVisible(false);
                boolean cannotAnimateDoze = mDozing && !ScrimState.AOD.getAnimateChange();
                if (mFingerprintUnlockController.getMode()
                        == FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING
@@ -3852,7 +3854,7 @@ public class StatusBar extends SystemUI implements DemoMode,
     * Switches theme from light to dark and vice-versa.
     */
    protected void updateTheme() {
        final boolean inflated = mStackScroller != null;
        final boolean inflated = mStackScroller != null && mStatusBarWindowManager != null;

        // The system wallpaper defines if QS should be light or dark.
        WallpaperColors systemColors = mColorExtractor
Loading