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

Commit 614b9ce8 authored by Lucas Dupin's avatar Lucas Dupin
Browse files

DO NOT MERGE: Delay brightness change

During a fingerprint wake-up, the display state changes bumping up
the display brightness. This means that the screen will flash
bright if the scrims couldn't draw and blank the screen yet.

The fix updates the state of the keyguard, waits for the frame to be
pushed to the display (can take up to 2 frames since we're using
triple buffers), when then asks PowerManager to wake-up the device.

Fixes: 80415238
Test: fp unlock with AOD on and off on devices with displays from
      multiple vendors
Change-Id: I60f0e265c4af87cc1cb4fcf31e89558a330a4b71
Merged-In: I752f9bd5ffd754166ffee7dc15960909dd3f1a81
parent d7b59466
Loading
Loading
Loading
Loading
+25 −8
Original line number Diff line number Diff line
@@ -210,15 +210,28 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback {
            // until the clock and the notifications are faded out.
            mStatusBarWindowManager.setForceDozeBrightness(true);
        }
        // During wake and unlock, we need to draw black before waking up to avoid abrupt
        // brightness changes due to display state transitions.
        boolean alwaysOnEnabled = DozeParameters.getInstance(mContext).getAlwaysOn();
        boolean delayWakeUp = mode == MODE_WAKE_AND_UNLOCK && alwaysOnEnabled;
        Runnable wakeUp = ()-> {
            if (!wasDeviceInteractive) {
                if (DEBUG_FP_WAKELOCK) {
                    Log.i(TAG, "fp wakelock: Authenticated, waking up...");
                }
                mPowerManager.wakeUp(SystemClock.uptimeMillis(), "android.policy:FINGERPRINT");
            }
            if (delayWakeUp) {
                mKeyguardViewMediator.onWakeAndUnlocking();
            }
            Trace.beginSection("release wake-and-unlock");
            releaseFingerprintWakeLock();
            Trace.endSection();
        };

        if (!delayWakeUp) {
            wakeUp.run();
        }
        switch (mMode) {
            case MODE_DISMISS_BOUNCER:
                Trace.beginSection("MODE_DISMISS");
@@ -251,7 +264,11 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback {
                    mUpdateMonitor.awakenFromDream();
                }
                mStatusBarWindowManager.setStatusBarFocusable(false);
                if (delayWakeUp) {
                    mHandler.postDelayed(wakeUp, 50);
                } else {
                    mKeyguardViewMediator.onWakeAndUnlocking();
                }
                if (mStatusBar.getNavigationBarView() != null) {
                    mStatusBar.getNavigationBarView().setWakeAndUnlocking(true);
                }