Don't animate scrim changes to UNLOCKED if we're occluding.

The occlude animation suppresses the notification scrim
alpha to 0f so that the animation can play over the
lockscreen contents. When we finish that animation, we
are currently animating from 1f to 0f, despite the
current alpha being 0f already (due to the suppression).

We can simply not animate this change to fix this, which
is already done for activity launches.

Fixes: 251275444
Test: launch timer from assistant on tablet
Test: atest ScrimControllerTest
Change-Id: Iccbe0124381a6cf1d813e8c1edb6c44b46cbd3fb
This commit is contained in:
Josh Tsuji
2023-03-14 17:30:45 -04:00
parent fe532fc2cb
commit fd49d593fe
3 changed files with 31 additions and 8 deletions

View File

@@ -796,6 +796,11 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
public void setOccludeAnimationPlaying(boolean occludeAnimationPlaying) {
mOccludeAnimationPlaying = occludeAnimationPlaying;
for (ScrimState state : ScrimState.values()) {
state.setOccludeAnimationPlaying(occludeAnimationPlaying);
}
applyAndDispatchState();
}
@@ -840,7 +845,6 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
if (mState == ScrimState.UNLOCKED || mState == ScrimState.DREAMING) {
final boolean occluding =
mOccludeAnimationPlaying || mState.mLaunchingAffordanceWithPreview;
// Darken scrim as it's pulled down while unlocked. If we're unlocked but playing the
// screen off/occlusion animations, ignore expansion changes while those animations
// play.

View File

@@ -243,7 +243,12 @@ public enum ScrimState {
: CentralSurfaces.FADE_KEYGUARD_DURATION;
boolean fromAod = previousState == AOD || previousState == PULSING;
mAnimateChange = !mLaunchingAffordanceWithPreview && !fromAod;
// If launch/occlude animations were playing, they already animated the scrim
// alpha to 0f as part of the animation. If we animate it now, we'll set it back
// to 1f and animate it back to 0f, causing an unwanted scrim flash.
mAnimateChange = !mLaunchingAffordanceWithPreview
&& !mOccludeAnimationPlaying
&& !fromAod;
mFrontTint = Color.TRANSPARENT;
mBehindTint = Color.BLACK;
@@ -308,6 +313,7 @@ public enum ScrimState {
boolean mWallpaperSupportsAmbientMode;
boolean mHasBackdrop;
boolean mLaunchingAffordanceWithPreview;
boolean mOccludeAnimationPlaying;
boolean mWakeLockScreenSensorActive;
boolean mKeyguardFadingAway;
long mKeyguardFadingAwayDuration;
@@ -411,6 +417,10 @@ public enum ScrimState {
mLaunchingAffordanceWithPreview = launchingAffordanceWithPreview;
}
public void setOccludeAnimationPlaying(boolean occludeAnimationPlaying) {
mOccludeAnimationPlaying = occludeAnimationPlaying;
}
public boolean isLowPowerState() {
return false;
}

View File

@@ -25,6 +25,7 @@ import static com.android.systemui.statusbar.phone.ScrimState.SHADE_LOCKED;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.anyInt;
@@ -1163,8 +1164,8 @@ public class ScrimControllerTest extends SysuiTestCase {
@Test
public void testScrimFocus() {
mScrimController.transitionTo(ScrimState.AOD);
Assert.assertFalse("Should not be focusable on AOD", mScrimBehind.isFocusable());
Assert.assertFalse("Should not be focusable on AOD", mScrimInFront.isFocusable());
assertFalse("Should not be focusable on AOD", mScrimBehind.isFocusable());
assertFalse("Should not be focusable on AOD", mScrimInFront.isFocusable());
mScrimController.transitionTo(ScrimState.KEYGUARD);
Assert.assertTrue("Should be focusable on keyguard", mScrimBehind.isFocusable());
@@ -1224,7 +1225,7 @@ public class ScrimControllerTest extends SysuiTestCase {
public void testAnimatesTransitionToAod() {
when(mDozeParameters.shouldControlScreenOff()).thenReturn(false);
ScrimState.AOD.prepare(ScrimState.KEYGUARD);
Assert.assertFalse("No animation when ColorFade kicks in",
assertFalse("No animation when ColorFade kicks in",
ScrimState.AOD.getAnimateChange());
reset(mDozeParameters);
@@ -1236,9 +1237,9 @@ public class ScrimControllerTest extends SysuiTestCase {
@Test
public void testViewsDontHaveFocusHighlight() {
Assert.assertFalse("Scrim shouldn't have focus highlight",
assertFalse("Scrim shouldn't have focus highlight",
mScrimInFront.getDefaultFocusHighlightEnabled());
Assert.assertFalse("Scrim shouldn't have focus highlight",
assertFalse("Scrim shouldn't have focus highlight",
mScrimBehind.getDefaultFocusHighlightEnabled());
}
@@ -1738,7 +1739,7 @@ public class ScrimControllerTest extends SysuiTestCase {
@Test
public void aodStateSetsFrontScrimToNotBlend() {
mScrimController.transitionTo(ScrimState.AOD);
Assert.assertFalse("Front scrim should not blend with main color",
assertFalse("Front scrim should not blend with main color",
mScrimInFront.shouldBlendWithMainColor());
}
@@ -1773,6 +1774,14 @@ public class ScrimControllerTest extends SysuiTestCase {
verify(mStatusBarKeyguardViewManager).onKeyguardFadedAway();
}
@Test
public void testDoNotAnimateChangeIfOccludeAnimationPlaying() {
mScrimController.setOccludeAnimationPlaying(true);
mScrimController.transitionTo(ScrimState.UNLOCKED);
assertFalse(ScrimState.UNLOCKED.mAnimateChange);
}
private void assertAlphaAfterExpansion(ScrimView scrim, float expectedAlpha, float expansion) {
mScrimController.setRawPanelExpansionFraction(expansion);
finishAnimationsImmediately();