From 614b9ce887ee7223d4af65c9a6d9a846b5dc10f1 Mon Sep 17 00:00:00 2001 From: Lucas Dupin Date: Mon, 2 Jul 2018 11:17:14 -0700 Subject: [PATCH] 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 --- .../phone/FingerprintUnlockController.java | 33 ++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/FingerprintUnlockController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/FingerprintUnlockController.java index f0b1a82cfc2fe..7cb6a192c64ac 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/FingerprintUnlockController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/FingerprintUnlockController.java @@ -210,15 +210,28 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback { // until the clock and the notifications are faded out. mStatusBarWindowManager.setForceDozeBrightness(true); } - if (!wasDeviceInteractive) { - if (DEBUG_FP_WAKELOCK) { - Log.i(TAG, "fp wakelock: Authenticated, waking up..."); + // 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"); } - mPowerManager.wakeUp(SystemClock.uptimeMillis(), "android.policy:FINGERPRINT"); + if (delayWakeUp) { + mKeyguardViewMediator.onWakeAndUnlocking(); + } + Trace.beginSection("release wake-and-unlock"); + releaseFingerprintWakeLock(); + Trace.endSection(); + }; + + if (!delayWakeUp) { + wakeUp.run(); } - Trace.beginSection("release wake-and-unlock"); - releaseFingerprintWakeLock(); - Trace.endSection(); switch (mMode) { case MODE_DISMISS_BOUNCER: Trace.beginSection("MODE_DISMISS"); @@ -251,7 +264,11 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback { mUpdateMonitor.awakenFromDream(); } mStatusBarWindowManager.setStatusBarFocusable(false); - mKeyguardViewMediator.onWakeAndUnlocking(); + if (delayWakeUp) { + mHandler.postDelayed(wakeUp, 50); + } else { + mKeyguardViewMediator.onWakeAndUnlocking(); + } if (mStatusBar.getNavigationBarView() != null) { mStatusBar.getNavigationBarView().setWakeAndUnlocking(true); }