Merge "Hide wallpaper when backdrop arrives" into pi-dev

am: 78c941d063

Change-Id: I82f13ea6a3ecde7f91899f23da45479ece97ac7d
This commit is contained in:
Lucas Dupin
2018-11-13 13:17:34 -08:00
committed by android-build-merger
3 changed files with 34 additions and 2 deletions

View File

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

View File

@@ -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;
}
},
/**

View File

@@ -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.