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

Commit a393ad6d authored by Joanne Chung's avatar Joanne Chung
Browse files

Fix the state cannot transition to DOZE_PULSING while docking.

If the next ScrimState is requested in a short time (Scrim state changes
from KEYGUARD -> AOD -> PULSING), it has chance mCallback will be reset
to null due to the cancel of previous animator.

Bug: 122943655
Test: Manual.
Change-Id: I1e7c3266021b066ed864b0a867522d69735d2241
parent c1fdb099
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -612,9 +612,11 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
        anim.setStartDelay(mAnimationDelay);
        anim.setDuration(mAnimationDuration);
        anim.addListener(new AnimatorListenerAdapter() {
            private Callback lastCallback = mCallback;

            @Override
            public void onAnimationEnd(Animator animation) {
                onFinished();
                onFinished(lastCallback);

                scrim.setTag(TAG_KEY_ANIM, null);
                dispatchScrimsVisible();
@@ -672,14 +674,23 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
    }

    private void onFinished() {
        onFinished(mCallback);
    }

    private void onFinished(Callback callback) {
        if (mWakeLockHeld) {
            mWakeLock.release();
            mWakeLockHeld = false;
        }
        if (mCallback != null) {
            mCallback.onFinished();

        if (callback != null) {
            callback.onFinished();

            if (callback == mCallback) {
                mCallback = null;
            }
        }

        // When unlocking with fingerprint, we'll fade the scrims from black to transparent.
        // At the end of the animation we need to remove the tint.
        if (mState == ScrimState.UNLOCKED) {