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

Commit 6507228c authored by Adrian Roos's avatar Adrian Roos
Browse files

AOD: Fix janky pulse out animation

Fixes an issue where during the pulse out animation, the fully
black frame did not hit the framebuffer before setting the power
state, causing visible jank in the ON -> DOZE transition.

To work around this, we now delay finishing the pulse and thus
setting the power state until the frame had time flush.

Change-Id: Ic1a04920fed516170d6803327cc9d46ed07e8b49
Fixes: 64277193
Test: Recieve notification on AOD, swipe away, verify no flicker (before fix reproduced ca 1/10)
parent 273bb516
Loading
Loading
Loading
Loading
+16 −6
Original line number Diff line number Diff line
@@ -23,14 +23,11 @@ import android.annotation.NonNull;
import android.content.Context;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.view.animation.Interpolator;

import com.android.keyguard.KeyguardStatusView;
import com.android.systemui.Interpolators;
import com.android.systemui.doze.DozeHost;
import com.android.systemui.doze.DozeLog;
import com.android.systemui.doze.DozeTriggers;

/**
 * Controller which handles all the doze animations of the scrims.
@@ -324,18 +321,31 @@ public class DozeScrimController {
            if (!mDozing) return;
            startScrimAnimation(true /* inFront */, 1,
                    mDozeParameters.getPulseOutDuration(),
                    Interpolators.ALPHA_IN, mPulseOutFinished);
                    Interpolators.ALPHA_IN, mPulseOutFinishing);
        }
    };

    private final Runnable mPulseOutFinished = new Runnable() {
    private final Runnable mPulseOutFinishing = new Runnable() {
        @Override
        public void run() {
            if (DEBUG) Log.d(TAG, "Pulse out finished");
            DozeLog.tracePulseFinish();
            if (mDozeParameters.getAlwaysOn() && mDozing) {
                // Setting power states can block rendering. For AOD, delay finishing the pulse and
                // setting the power state until the fully black scrim had time to hit the
                // framebuffer.
                mHandler.postDelayed(mPulseOutFinished, 30);
            } else {
                mPulseOutFinished.run();
            }
        }
    };

    private final Runnable mPulseOutFinished = new Runnable() {
        @Override
        public void run() {
            // Signal that the pulse is all finished so we can turn the screen off now.
            pulseFinished();
            DozeScrimController.this.pulseFinished();
            if (mDozeParameters.getAlwaysOn()) {
                mScrimController.setDozeInFrontAlpha(0);
            }