Fix flicker when unlocking the screen.

Fixes: 197113783
Test: atest ScrimControllerTest
Test: fp from: shade locked, aod, lock screen
Test: switch between light and dark themes, look at scrim anim
Change-Id: Iacd46b99c5a86c8f7a7706b91b0b78a3beb4c414
Merged-In: Iacd46b99c5a86c8f7a7706b91b0b78a3beb4c414
This commit is contained in:
Selim Cinek
2021-08-23 21:26:23 +02:00
committed by Lucas Dupin
parent f16b3f76aa
commit c2dda240a7
3 changed files with 50 additions and 5 deletions

View File

@@ -418,7 +418,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
if (mKeyguardUpdateMonitor.needsSlowUnlockTransition() && mState == ScrimState.UNLOCKED) {
mAnimationDelay = StatusBar.FADE_KEYGUARD_START_DELAY;
scheduleUpdate();
} else if ((oldState == ScrimState.AOD // leaving doze
} else if (((oldState == ScrimState.AOD || oldState == ScrimState.PULSING) // leaving doze
&& (!mDozeParameters.getAlwaysOn() || mState == ScrimState.UNLOCKED))
|| (mState == ScrimState.AOD && !mDozeParameters.getDisplayNeedsBlanking())) {
// Scheduling a frame isn't enough when:

View File

@@ -244,7 +244,8 @@ public enum ScrimState {
? mKeyguardFadingAwayDuration
: StatusBar.FADE_KEYGUARD_DURATION;
mAnimateChange = !mLaunchingAffordanceWithPreview;
boolean fromAod = previousState == AOD || previousState == PULSING;
mAnimateChange = !mLaunchingAffordanceWithPreview && !fromAod;
mFrontTint = Color.TRANSPARENT;
mBehindTint = Color.BLACK;

View File

@@ -20,6 +20,8 @@ import static com.android.systemui.statusbar.phone.ScrimController.OPAQUE;
import static com.android.systemui.statusbar.phone.ScrimController.SEMI_TRANSPARENT;
import static com.android.systemui.statusbar.phone.ScrimController.TRANSPARENT;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyFloat;
@@ -734,9 +736,9 @@ public class ScrimControllerTest extends SysuiTestCase {
}
@Test
public void transitionToUnlockedFromAod() {
// Simulate unlock with fingerprint
mScrimController.transitionTo(ScrimState.AOD);
public void transitionToUnlockedFromOff() {
// Simulate unlock with fingerprint without AOD
mScrimController.transitionTo(ScrimState.OFF);
mScrimController.setPanelExpansion(0f);
finishAnimationsImmediately();
mScrimController.transitionTo(ScrimState.UNLOCKED);
@@ -764,6 +766,28 @@ public class ScrimControllerTest extends SysuiTestCase {
));
}
@Test
public void transitionToUnlockedFromAod() {
// Simulate unlock with fingerprint
mScrimController.transitionTo(ScrimState.AOD);
mScrimController.setPanelExpansion(0f);
finishAnimationsImmediately();
mScrimController.transitionTo(ScrimState.UNLOCKED);
finishAnimationsImmediately();
// All scrims should be transparent at the end of fade transition.
assertScrimAlpha(Map.of(
mScrimInFront, TRANSPARENT,
mScrimBehind, TRANSPARENT));
// Make sure at the very end of the animation, we're reset to transparent
assertScrimTinted(Map.of(
mScrimInFront, false,
mScrimBehind, true
));
}
@Test
public void scrimBlanksBeforeLeavingAod() {
// Simulate unlock with fingerprint
@@ -1080,6 +1104,26 @@ public class ScrimControllerTest extends SysuiTestCase {
mScrimInFront, TRANSPARENT));
}
@Test
public void testDoesntAnimate_whenUnlocking() {
// LightRevealScrim will animate the transition, we should only hide the keyguard scrims.
ScrimState.UNLOCKED.prepare(ScrimState.KEYGUARD);
assertThat(ScrimState.UNLOCKED.getAnimateChange()).isTrue();
ScrimState.UNLOCKED.prepare(ScrimState.PULSING);
assertThat(ScrimState.UNLOCKED.getAnimateChange()).isFalse();
ScrimState.UNLOCKED.prepare(ScrimState.KEYGUARD);
assertThat(ScrimState.UNLOCKED.getAnimateChange()).isTrue();
ScrimState.UNLOCKED.prepare(ScrimState.AOD);
assertThat(ScrimState.UNLOCKED.getAnimateChange()).isFalse();
// LightRevealScrim doesn't animate when AOD is disabled. We need to use the legacy anim.
ScrimState.UNLOCKED.prepare(ScrimState.KEYGUARD);
assertThat(ScrimState.UNLOCKED.getAnimateChange()).isTrue();
ScrimState.UNLOCKED.prepare(ScrimState.OFF);
assertThat(ScrimState.UNLOCKED.getAnimateChange()).isTrue();
}
@Test
public void testScrimsVisible_whenShadeVisible_clippingQs() {
mScrimController.setClipsQsScrim(true);