Merge "Fade to black without showing system wallpaper" into pi-dev
This commit is contained in:
@@ -1589,6 +1589,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isKeyguardVisible() {
|
||||
return mKeyguardIsVisible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies that the visibility state of Keyguard has changed.
|
||||
*
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
// 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 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 && !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() {
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -1652,8 +1652,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
|
||||
@@ -1669,7 +1673,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");
|
||||
@@ -1721,7 +1724,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
|
||||
@@ -3853,7 +3855,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
|
||||
|
||||
@@ -93,7 +93,7 @@ public class SysuiColorExtractorTests extends SysuiTestCase {
|
||||
SysuiColorExtractor extractor = getTestableExtractor(colors);
|
||||
simulateEvent(extractor);
|
||||
extractor.setWallpaperVisible(true);
|
||||
extractor.setMediaBackdropVisible(true);
|
||||
extractor.setHasBackdrop(true);
|
||||
|
||||
ColorExtractor.GradientColors fallbackColors = extractor.getFallbackColors();
|
||||
|
||||
|
||||
@@ -44,7 +44,6 @@ import android.view.View;
|
||||
|
||||
import com.android.internal.colorextraction.ColorExtractor.GradientColors;
|
||||
import com.android.internal.util.function.TriConsumer;
|
||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||
import com.android.systemui.SysuiTestCase;
|
||||
import com.android.systemui.statusbar.ScrimView;
|
||||
import com.android.systemui.util.wakelock.WakeLock;
|
||||
@@ -94,6 +93,7 @@ public class ScrimControllerTest extends SysuiTestCase {
|
||||
mScrimInFrontColor = scrimInFrontColor;
|
||||
},
|
||||
visible -> mScrimVisibility = visible, mDozeParamenters, mAlarmManager);
|
||||
mScrimController.setHasBackdrop(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -140,12 +140,7 @@ public class ScrimControllerTest extends SysuiTestCase {
|
||||
|
||||
@Test
|
||||
public void transitionToAod_withAodWallpaperAndLockScreenWallpaper() {
|
||||
ScrimState.AOD.mKeyguardUpdateMonitor = new KeyguardUpdateMonitor(getContext()) {
|
||||
@Override
|
||||
public boolean hasLockscreenWallpaper() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
mScrimController.setHasBackdrop(true);
|
||||
mScrimController.setWallpaperSupportsAmbientMode(true);
|
||||
mScrimController.transitionTo(ScrimState.AOD);
|
||||
mScrimController.finishAnimationsImmediately();
|
||||
|
||||
Reference in New Issue
Block a user