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

Commit 0e52664b authored by Lucas Dupin's avatar Lucas Dupin Committed by Android (Google) Code Review
Browse files

Merge "Fade to black without showing system wallpaper" into pi-dev

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


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


    public void setMediaBackdropVisible(boolean visible) {
    public void setHasBackdrop(boolean hasBackdrop) {
        if (mMediaBackdropVisible != visible) {
        if (mHasBackdrop != hasBackdrop) {
            mMediaBackdropVisible = visible;
            mHasBackdrop = hasBackdrop;
            triggerColorsChanged(WallpaperManager.FLAG_LOCK);
            triggerColorsChanged(WallpaperManager.FLAG_LOCK);
        }
        }
    }
    }
+15 −19
Original line number Original line Diff line number Diff line
@@ -29,9 +29,7 @@ import android.os.Handler;
import android.os.Trace;
import android.os.Trace;
import android.util.Log;
import android.util.Log;
import android.util.MathUtils;
import android.util.MathUtils;
import android.view.Choreographer;
import android.view.View;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
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.graphics.ColorUtils;
import com.android.internal.util.function.TriConsumer;
import com.android.internal.util.function.TriConsumer;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.systemui.Dependency;
import com.android.systemui.Dependency;
import com.android.systemui.Dumpable;
import com.android.systemui.Dumpable;
import com.android.systemui.R;
import com.android.systemui.R;
import com.android.systemui.colorextraction.SysuiColorExtractor;
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.ScrimView;
import com.android.systemui.statusbar.stack.ViewState;
import com.android.systemui.statusbar.stack.ViewState;
import com.android.systemui.util.AlarmTimeout;
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.
        // Make sure we have the right gradients and their opacities will satisfy GAR.
        if (mNeedsDrawableColorUpdate) {
        if (mNeedsDrawableColorUpdate) {
            mNeedsDrawableColorUpdate = false;
            mNeedsDrawableColorUpdate = false;
            final GradientColors currentScrimColors;
            boolean isKeyguard = mKeyguardUpdateMonitor.isKeyguardVisible() && !mKeyguardOccluded;
            if (mState == ScrimState.KEYGUARD || mState == ScrimState.BOUNCER_SCRIMMED
            GradientColors currentScrimColors = isKeyguard ? mLockColors : mSystemColors;
                    || 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 {
            // Only animate scrim color if the scrim view is actually visible
            // Only animate scrim color if the scrim view is actually visible
                boolean animateScrimInFront = mScrimInFront.getViewAlpha() != 0;
            boolean animateScrimInFront = mScrimInFront.getViewAlpha() != 0 && !mBlankScreen;
                boolean animateScrimBehind = mScrimBehind.getViewAlpha() != 0;
            boolean animateScrimBehind = mScrimBehind.getViewAlpha() != 0 && !mBlankScreen;
                mScrimInFront.setColors(mSystemColors, animateScrimInFront);
            mScrimInFront.setColors(currentScrimColors, animateScrimInFront);
                mScrimBehind.setColors(mSystemColors, animateScrimBehind);
            mScrimBehind.setColors(currentScrimColors, animateScrimBehind);
                currentScrimColors = mSystemColors;
            }


            // Calculate minimum scrim opacity for white or black text.
            // Calculate minimum scrim opacity for white or black text.
            int textColor = currentScrimColors.supportsDarkText() ? Color.BLACK : Color.WHITE;
            int textColor = currentScrimColors.supportsDarkText() ? Color.BLACK : Color.WHITE;
@@ -899,6 +888,13 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
        updateScrims();
        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 {
    public interface Callback {
        default void onStart() {
        default void onStart() {
        }
        }
+7 −7
Original line number Original line Diff line number Diff line
@@ -20,7 +20,6 @@ import android.graphics.Color;
import android.os.Trace;
import android.os.Trace;
import android.util.MathUtils;
import android.util.MathUtils;


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


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


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


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

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


        final boolean hasArtwork = artworkDrawable != null;
        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)
                && (mState != StatusBarState.SHADE || allowWhenShade)
                && mFingerprintUnlockController.getMode()
                && mFingerprintUnlockController.getMode()
                        != FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING
                        != FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING
@@ -1669,7 +1673,6 @@ public class StatusBar extends SystemUI implements DemoMode,
                    mBackdrop.setAlpha(1f);
                    mBackdrop.setAlpha(1f);
                }
                }
                mStatusBarWindowManager.setBackdropShowing(true);
                mStatusBarWindowManager.setBackdropShowing(true);
                mColorExtractor.setMediaBackdropVisible(true);
                metaDataChanged = true;
                metaDataChanged = true;
                if (DEBUG_MEDIA) {
                if (DEBUG_MEDIA) {
                    Log.v(TAG, "DEBUG_MEDIA: Fading in album artwork");
                    Log.v(TAG, "DEBUG_MEDIA: Fading in album artwork");
@@ -1721,7 +1724,6 @@ public class StatusBar extends SystemUI implements DemoMode,
                if (DEBUG_MEDIA) {
                if (DEBUG_MEDIA) {
                    Log.v(TAG, "DEBUG_MEDIA: Fading out album artwork");
                    Log.v(TAG, "DEBUG_MEDIA: Fading out album artwork");
                }
                }
                mColorExtractor.setMediaBackdropVisible(false);
                boolean cannotAnimateDoze = mDozing && !ScrimState.AOD.getAnimateChange();
                boolean cannotAnimateDoze = mDozing && !ScrimState.AOD.getAnimateChange();
                if (mFingerprintUnlockController.getMode()
                if (mFingerprintUnlockController.getMode()
                        == FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING
                        == FingerprintUnlockController.MODE_WAKE_AND_UNLOCK_PULSING
@@ -3853,7 +3855,7 @@ public class StatusBar extends SystemUI implements DemoMode,
     * Switches theme from light to dark and vice-versa.
     * Switches theme from light to dark and vice-versa.
     */
     */
    protected void updateTheme() {
    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.
        // The system wallpaper defines if QS should be light or dark.
        WallpaperColors systemColors = mColorExtractor
        WallpaperColors systemColors = mColorExtractor
Loading