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

Commit e4cb6c8a authored by Adrian Roos's avatar Adrian Roos
Browse files

Flicker free screen-on from AOD

When pulsing from AOD, we force the display OFF first. This allows
us to transition smoothly from AOD.

Also, we add a scrim transition for whenever we are waking up from
dozing. This relies on I4f3a863709a970f0fc8682c0a0c3547886e1fd0f
which forces the DOZE -> ON transition through OFF first.

Also fixes the WAKE_AND_UNLOCK transition that happens when waking
up with the fingerprint sensor.

Also fix an issue where KeyguardViewMediator's mWakeAndUnlocking
was cleared in onScreenTurnedOff; this should have been added to
the wakefulness lifecycle instead and now that the AOD -> ON transtion
dispatches the screen off callback it broke the fingerprint unlock
transition.

Fixes: 35849781
Fixes: 63887857
Fixes: 63783651
Fixes: 63727166
Test: AOD, receive notification; AOD, unlock with fingerprint; AOD, wake to lockscreen. Verify that everything is flicker-free.
Change-Id: I7d539db80a1c7e9216cf4c5c1e6d314c1893f12d
parent 29119b6f
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -91,6 +91,7 @@ public class DozeMachine {
                case UNINITIALIZED:
                case UNINITIALIZED:
                case INITIALIZED:
                case INITIALIZED:
                case DOZE:
                case DOZE:
                case DOZE_REQUEST_PULSE:
                case DOZE_AOD_PAUSED:
                case DOZE_AOD_PAUSED:
                    return Display.STATE_OFF;
                    return Display.STATE_OFF;
                case DOZE_PULSING:
                case DOZE_PULSING:
+1 −1
Original line number Original line Diff line number Diff line
@@ -811,6 +811,7 @@ public class KeyguardViewMediator extends SystemUI {
        synchronized (this) {
        synchronized (this) {
            mDeviceInteractive = false;
            mDeviceInteractive = false;
            mGoingToSleep = false;
            mGoingToSleep = false;
            mWakeAndUnlocking = false;


            resetKeyguardDonePendingLocked();
            resetKeyguardDonePendingLocked();
            mHideAnimationRun = false;
            mHideAnimationRun = false;
@@ -1957,7 +1958,6 @@ public class KeyguardViewMediator extends SystemUI {
            if (DEBUG) Log.d(TAG, "handleNotifyScreenTurnedOff");
            if (DEBUG) Log.d(TAG, "handleNotifyScreenTurnedOff");
            mStatusBarKeyguardViewManager.onScreenTurnedOff();
            mStatusBarKeyguardViewManager.onScreenTurnedOff();
            mDrawnCallback = null;
            mDrawnCallback = null;
            mWakeAndUnlocking = false;
        }
        }
    }
    }


+1 −4
Original line number Original line Diff line number Diff line
@@ -114,6 +114,7 @@ public class DozeScrimController {
        // be invoked when we're done so that the caller can drop the pulse wakelock.
        // be invoked when we're done so that the caller can drop the pulse wakelock.
        mPulseCallback = callback;
        mPulseCallback = callback;
        mPulseReason = reason;
        mPulseReason = reason;
        mScrimController.setDozeInFrontAlpha(1f);
        mHandler.post(mPulseIn);
        mHandler.post(mPulseIn);
    }
    }


@@ -290,10 +291,6 @@ public class DozeScrimController {


            // Signal that the pulse is ready to turn the screen on and draw.
            // Signal that the pulse is ready to turn the screen on and draw.
            pulseStarted();
            pulseStarted();

            if (mDozeParameters.getAlwaysOn()) {
                mHandler.post(DozeScrimController.this::onScreenTurnedOn);
            }
        }
        }
    };
    };


+1 −1
Original line number Original line Diff line number Diff line
@@ -285,7 +285,7 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback {
        if (!mUpdateMonitor.isDeviceInteractive()) {
        if (!mUpdateMonitor.isDeviceInteractive()) {
            if (!mStatusBarKeyguardViewManager.isShowing()) {
            if (!mStatusBarKeyguardViewManager.isShowing()) {
                return MODE_ONLY_WAKE;
                return MODE_ONLY_WAKE;
            } else if (pulsingOrAod() && unlockingAllowed) {
            } else if (mDozeScrimController.isPulsing() && unlockingAllowed) {
                return MODE_WAKE_AND_UNLOCK_PULSING;
                return MODE_WAKE_AND_UNLOCK_PULSING;
            } else if (unlockingAllowed || !mUnlockMethodCache.isMethodSecure()) {
            } else if (unlockingAllowed || !mUnlockMethodCache.isMethodSecure()) {
                return MODE_WAKE_AND_UNLOCK;
                return MODE_WAKE_AND_UNLOCK;
+45 −3
Original line number Original line Diff line number Diff line
@@ -25,7 +25,6 @@ import android.content.Context;
import android.graphics.Color;
import android.graphics.Color;
import android.graphics.Rect;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable;
import android.util.Log;
import android.util.MathUtils;
import android.util.MathUtils;
import android.view.View;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup;
@@ -120,6 +119,12 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
    private boolean mKeyguardFadingOutInProgress;
    private boolean mKeyguardFadingOutInProgress;
    private boolean mAnimatingDozeUnlock;
    private boolean mAnimatingDozeUnlock;
    private ValueAnimator mKeyguardFadeoutAnimation;
    private ValueAnimator mKeyguardFadeoutAnimation;
    /** Wake up from AOD transition is starting; need fully opaque front scrim */
    private boolean mWakingUpFromAodStarting;
    /** Wake up from AOD transition is in progress; need black tint */
    private boolean mWakingUpFromAodInProgress;
    /** Wake up from AOD transition is animating; need to reset when animation finishes */
    private boolean mWakingUpFromAodAnimationRunning;


    public ScrimController(LightBarController lightBarController, ScrimView scrimBehind,
    public ScrimController(LightBarController lightBarController, ScrimView scrimBehind,
            ScrimView scrimInFront, View headsUpScrim) {
            ScrimView scrimInFront, View headsUpScrim) {
@@ -187,9 +192,32 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
        scheduleUpdate();
        scheduleUpdate();
    }
    }


    public void prepareWakeUpFromAod() {
        mWakingUpFromAodInProgress = true;
        mWakingUpFromAodStarting = true;
        mAnimateChange = false;
        scheduleUpdate();
        onPreDraw();
    }

    public void wakeUpFromAod() {
        if (mWakeAndUnlocking || mAnimateKeyguardFadingOut) {
            // Wake and unlocking has a separate transition that must not be interfered with.
            mWakingUpFromAodStarting = false;
            return;
        }
        if (mWakingUpFromAodStarting) {
            mWakingUpFromAodInProgress = true;
            mWakingUpFromAodStarting = false;
            mAnimateChange = true;
            scheduleUpdate();
        }
    }

    public void setWakeAndUnlocking() {
    public void setWakeAndUnlocking() {
        mWakeAndUnlocking = true;
        mWakeAndUnlocking = true;
        mAnimatingDozeUnlock = true;
        mAnimatingDozeUnlock = true;
        mWakingUpFromAodStarting = false;
        scheduleUpdate();
        scheduleUpdate();
    }
    }


@@ -356,7 +384,11 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
            setScrimBehindAlpha(mScrimBehindAlpha);
            setScrimBehindAlpha(mScrimBehindAlpha);
        } else {
        } else {
            float fraction = Math.max(0, Math.min(mFraction, 1));
            float fraction = Math.max(0, Math.min(mFraction, 1));
            if (mWakingUpFromAodStarting) {
                setScrimInFrontAlpha(1f);
            } else {
                setScrimInFrontAlpha(0f);
                setScrimInFrontAlpha(0f);
            }
            setScrimBehindAlpha(fraction
            setScrimBehindAlpha(fraction
                    * (mScrimBehindAlphaKeyguard - mScrimBehindAlphaUnlocking)
                    * (mScrimBehindAlphaKeyguard - mScrimBehindAlphaUnlocking)
                    + mScrimBehindAlphaUnlocking);
                    + mScrimBehindAlphaUnlocking);
@@ -426,7 +458,10 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
            scrimView.setViewAlpha(alpha);
            scrimView.setViewAlpha(alpha);


            int dozeTint = Color.TRANSPARENT;
            int dozeTint = Color.TRANSPARENT;
            if (mAnimatingDozeUnlock || mDozing) {

            boolean dozing = mAnimatingDozeUnlock || mDozing;
            boolean frontScrimDozing = mWakingUpFromAodInProgress;
            if (dozing || frontScrimDozing && scrim == mScrimInFront) {
                dozeTint = Color.BLACK;
                dozeTint = Color.BLACK;
            }
            }
            scrimView.setTint(dozeTint);
            scrimView.setTint(dozeTint);
@@ -458,6 +493,10 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
                    mKeyguardFadingOutInProgress = false;
                    mKeyguardFadingOutInProgress = false;
                    mAnimatingDozeUnlock = false;
                    mAnimatingDozeUnlock = false;
                }
                }
                if (mWakingUpFromAodAnimationRunning) {
                    mWakingUpFromAodAnimationRunning = false;
                    mWakingUpFromAodInProgress = false;
                }
                scrim.setTag(TAG_KEY_ANIM, null);
                scrim.setTag(TAG_KEY_ANIM, null);
                scrim.setTag(TAG_KEY_ANIM_TARGET, null);
                scrim.setTag(TAG_KEY_ANIM_TARGET, null);
            }
            }
@@ -467,6 +506,9 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener,
            mKeyguardFadingOutInProgress = true;
            mKeyguardFadingOutInProgress = true;
            mKeyguardFadeoutAnimation = anim;
            mKeyguardFadeoutAnimation = anim;
        }
        }
        if (mWakingUpFromAodInProgress) {
            mWakingUpFromAodAnimationRunning = true;
        }
        if (mSkipFirstFrame) {
        if (mSkipFirstFrame) {
            anim.setCurrentPlayTime(16);
            anim.setCurrentPlayTime(16);
        }
        }
Loading