Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7ee74471 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Fix flicker when unlocking the screen." into sc-dev am: 6431f95d

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15660797

Change-Id: Ibb032b545c1379bbee40276891da23e0678aabe1
parents 5d29a96c 6431f95d
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -432,7 +432,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, Dump
        if (mKeyguardUpdateMonitor.needsSlowUnlockTransition() && mState == ScrimState.UNLOCKED) {
        if (mKeyguardUpdateMonitor.needsSlowUnlockTransition() && mState == ScrimState.UNLOCKED) {
            mAnimationDelay = StatusBar.FADE_KEYGUARD_START_DELAY;
            mAnimationDelay = StatusBar.FADE_KEYGUARD_START_DELAY;
            scheduleUpdate();
            scheduleUpdate();
        } else if ((oldState == ScrimState.AOD  // leaving doze
        } else if (((oldState == ScrimState.AOD || oldState == ScrimState.PULSING)  // leaving doze
                && (!mDozeParameters.getAlwaysOn() || mState == ScrimState.UNLOCKED))
                && (!mDozeParameters.getAlwaysOn() || mState == ScrimState.UNLOCKED))
                || (mState == ScrimState.AOD && !mDozeParameters.getDisplayNeedsBlanking())) {
                || (mState == ScrimState.AOD && !mDozeParameters.getDisplayNeedsBlanking())) {
            // Scheduling a frame isn't enough when:
            // Scheduling a frame isn't enough when:
+2 −1
Original line number Original line Diff line number Diff line
@@ -244,7 +244,8 @@ public enum ScrimState {
                    ? mKeyguardFadingAwayDuration
                    ? mKeyguardFadingAwayDuration
                    : StatusBar.FADE_KEYGUARD_DURATION;
                    : StatusBar.FADE_KEYGUARD_DURATION;


            mAnimateChange = !mLaunchingAffordanceWithPreview;
            boolean fromAod = previousState == AOD || previousState == PULSING;
            mAnimateChange = !mLaunchingAffordanceWithPreview && !fromAod;


            mFrontTint = Color.TRANSPARENT;
            mFrontTint = Color.TRANSPARENT;
            mBehindTint = Color.BLACK;
            mBehindTint = Color.BLACK;
+47 −3
Original line number Original line Diff line number Diff line
@@ -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.SEMI_TRANSPARENT;
import static com.android.systemui.statusbar.phone.ScrimController.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.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyFloat;
import static org.mockito.ArgumentMatchers.anyFloat;
@@ -734,9 +736,9 @@ public class ScrimControllerTest extends SysuiTestCase {
    }
    }


    @Test
    @Test
    public void transitionToUnlockedFromAod() {
    public void transitionToUnlockedFromOff() {
        // Simulate unlock with fingerprint
        // Simulate unlock with fingerprint without AOD
        mScrimController.transitionTo(ScrimState.AOD);
        mScrimController.transitionTo(ScrimState.OFF);
        mScrimController.setPanelExpansion(0f);
        mScrimController.setPanelExpansion(0f);
        finishAnimationsImmediately();
        finishAnimationsImmediately();
        mScrimController.transitionTo(ScrimState.UNLOCKED);
        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
    @Test
    public void scrimBlanksBeforeLeavingAod() {
    public void scrimBlanksBeforeLeavingAod() {
        // Simulate unlock with fingerprint
        // Simulate unlock with fingerprint
@@ -1080,6 +1104,26 @@ public class ScrimControllerTest extends SysuiTestCase {
                mScrimInFront, TRANSPARENT));
                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
    @Test
    public void testScrimsVisible_whenShadeVisible_clippingQs() {
    public void testScrimsVisible_whenShadeVisible_clippingQs() {
        mScrimController.setClipsQsScrim(true);
        mScrimController.setClipsQsScrim(true);