Merge "Fix flicker when unlocking the screen." into sc-dev

This commit is contained in:
TreeHugger Robot
2021-08-24 19:59:12 +00:00
committed by Android (Google) Code Review
3 changed files with 50 additions and 5 deletions

View File

@@ -432,7 +432,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);