blob: 7cb6a192c64ac1b4c618b816fad1c24d75107ba4 [file] [log] [blame]
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -07001/*
2 * Copyright (C) 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License
15 */
16
17package com.android.systemui.statusbar.phone;
18
19import android.content.Context;
20import android.os.Handler;
21import android.os.PowerManager;
22import android.os.SystemClock;
Nick Desaulniers1d396752016-07-25 15:05:33 -070023import android.os.Trace;
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -070024import android.util.Log;
25
26import com.android.keyguard.KeyguardConstants;
27import com.android.keyguard.KeyguardUpdateMonitor;
28import com.android.keyguard.KeyguardUpdateMonitorCallback;
Jason Monk453e7c12017-12-04 11:08:41 -050029import com.android.internal.util.LatencyTracker;
Jason Monk421a9412017-02-06 09:15:21 -080030import com.android.systemui.Dependency;
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -070031import com.android.systemui.keyguard.KeyguardViewMediator;
Adrian Roos7a5e4c92017-07-31 16:40:19 +020032import com.android.systemui.keyguard.ScreenLifecycle;
Adrian Roos58ba6852017-07-18 17:10:29 +020033import com.android.systemui.keyguard.WakefulnessLifecycle;
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -070034
Adrian Roosba7ca592017-08-15 17:48:05 +020035import java.io.PrintWriter;
36
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -070037/**
38 * Controller which coordinates all the fingerprint unlocking actions with the UI.
39 */
40public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback {
41
42 private static final String TAG = "FingerprintController";
43 private static final boolean DEBUG_FP_WAKELOCK = KeyguardConstants.DEBUG_FP_WAKELOCK;
44 private static final long FINGERPRINT_WAKELOCK_TIMEOUT_MS = 15 * 1000;
45 private static final String FINGERPRINT_WAKE_LOCK_NAME = "wake-and-unlock wakelock";
46
47 /**
48 * Mode in which we don't need to wake up the device when we get a fingerprint.
49 */
50 public static final int MODE_NONE = 0;
51
52 /**
53 * Mode in which we wake up the device, and directly dismiss Keyguard. Active when we acquire
54 * a fingerprint while the screen is off and the device was sleeping.
55 */
56 public static final int MODE_WAKE_AND_UNLOCK = 1;
57
58 /**
59 * Mode in which we wake the device up, and fade out the Keyguard contents because they were
60 * already visible while pulsing in doze mode.
61 */
62 public static final int MODE_WAKE_AND_UNLOCK_PULSING = 2;
63
64 /**
65 * Mode in which we wake up the device, but play the normal dismiss animation. Active when we
66 * acquire a fingerprint pulsing in doze mode.
67 */
68 public static final int MODE_SHOW_BOUNCER = 3;
69
70 /**
71 * Mode in which we only wake up the device, and keyguard was not showing when we acquired a
72 * fingerprint.
73 * */
74 public static final int MODE_ONLY_WAKE = 4;
75
76 /**
77 * Mode in which fingerprint unlocks the device.
78 */
79 public static final int MODE_UNLOCK = 5;
80
81 /**
82 * Mode in which fingerprint brings up the bouncer because fingerprint unlocking is currently
83 * not allowed.
84 */
85 public static final int MODE_DISMISS_BOUNCER = 6;
86
87 /**
Kevin Chyn36778ff2017-09-07 19:55:38 -070088 * Mode in which fingerprint wakes and unlocks the device from a dream.
89 */
90 public static final int MODE_WAKE_AND_UNLOCK_FROM_DREAM = 7;
91
92 /**
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -070093 * How much faster we collapse the lockscreen when authenticating with fingerprint.
94 */
Selim Cinekdf5501b2017-04-14 20:01:27 -070095 private static final float FINGERPRINT_COLLAPSE_SPEEDUP_FACTOR = 1.1f;
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -070096
97 private PowerManager mPowerManager;
98 private Handler mHandler = new Handler();
99 private PowerManager.WakeLock mWakeLock;
100 private KeyguardUpdateMonitor mUpdateMonitor;
101 private int mMode;
102 private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager;
103 private StatusBarWindowManager mStatusBarWindowManager;
104 private DozeScrimController mDozeScrimController;
105 private KeyguardViewMediator mKeyguardViewMediator;
106 private ScrimController mScrimController;
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500107 private StatusBar mStatusBar;
Jorim Jaggi8adb30c2016-09-13 15:02:22 -0700108 private final UnlockMethodCache mUnlockMethodCache;
109 private final Context mContext;
Jorim Jaggi95e40382015-09-16 15:53:42 -0700110 private int mPendingAuthenticatedUserId = -1;
Adrian Roos58ba6852017-07-18 17:10:29 +0200111 private boolean mPendingShowBouncer;
Adrian Roos7a5e4c92017-07-31 16:40:19 +0200112 private boolean mHasScreenTurnedOnSinceAuthenticating;
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700113
114 public FingerprintUnlockController(Context context,
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700115 DozeScrimController dozeScrimController,
116 KeyguardViewMediator keyguardViewMediator,
117 ScrimController scrimController,
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500118 StatusBar statusBar,
Jorim Jaggi8adb30c2016-09-13 15:02:22 -0700119 UnlockMethodCache unlockMethodCache) {
120 mContext = context;
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700121 mPowerManager = context.getSystemService(PowerManager.class);
122 mUpdateMonitor = KeyguardUpdateMonitor.getInstance(context);
123 mUpdateMonitor.registerCallback(this);
Adrian Roos58ba6852017-07-18 17:10:29 +0200124 Dependency.get(WakefulnessLifecycle.class).addObserver(mWakefulnessObserver);
Adrian Roos7a5e4c92017-07-31 16:40:19 +0200125 Dependency.get(ScreenLifecycle.class).addObserver(mScreenObserver);
Jason Monk421a9412017-02-06 09:15:21 -0800126 mStatusBarWindowManager = Dependency.get(StatusBarWindowManager.class);
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700127 mDozeScrimController = dozeScrimController;
128 mKeyguardViewMediator = keyguardViewMediator;
129 mScrimController = scrimController;
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500130 mStatusBar = statusBar;
Jorim Jaggi8adb30c2016-09-13 15:02:22 -0700131 mUnlockMethodCache = unlockMethodCache;
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700132 }
133
134 public void setStatusBarKeyguardViewManager(
135 StatusBarKeyguardViewManager statusBarKeyguardViewManager) {
136 mStatusBarKeyguardViewManager = statusBarKeyguardViewManager;
137 }
138
139 private final Runnable mReleaseFingerprintWakeLockRunnable = new Runnable() {
140 @Override
141 public void run() {
142 if (DEBUG_FP_WAKELOCK) {
143 Log.i(TAG, "fp wakelock: TIMEOUT!!");
144 }
145 releaseFingerprintWakeLock();
146 }
147 };
148
149 private void releaseFingerprintWakeLock() {
150 if (mWakeLock != null) {
151 mHandler.removeCallbacks(mReleaseFingerprintWakeLockRunnable);
152 if (DEBUG_FP_WAKELOCK) {
153 Log.i(TAG, "releasing fp wakelock");
154 }
155 mWakeLock.release();
156 mWakeLock = null;
157 }
158 }
159
160 @Override
161 public void onFingerprintAcquired() {
Nick Desaulniers1d396752016-07-25 15:05:33 -0700162 Trace.beginSection("FingerprintUnlockController#onFingerprintAcquired");
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700163 releaseFingerprintWakeLock();
164 if (!mUpdateMonitor.isDeviceInteractive()) {
Jorim Jaggi8adb30c2016-09-13 15:02:22 -0700165 if (LatencyTracker.isEnabled(mContext)) {
166 LatencyTracker.getInstance(mContext).onActionStart(
167 LatencyTracker.ACTION_FINGERPRINT_WAKE_AND_UNLOCK);
168 }
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700169 mWakeLock = mPowerManager.newWakeLock(
170 PowerManager.PARTIAL_WAKE_LOCK, FINGERPRINT_WAKE_LOCK_NAME);
Nick Desaulniers1d396752016-07-25 15:05:33 -0700171 Trace.beginSection("acquiring wake-and-unlock");
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700172 mWakeLock.acquire();
Nick Desaulniers1d396752016-07-25 15:05:33 -0700173 Trace.endSection();
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700174 if (DEBUG_FP_WAKELOCK) {
175 Log.i(TAG, "fingerprint acquired, grabbing fp wakelock");
176 }
177 mHandler.postDelayed(mReleaseFingerprintWakeLockRunnable,
178 FINGERPRINT_WAKELOCK_TIMEOUT_MS);
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700179 }
Nick Desaulniers1d396752016-07-25 15:05:33 -0700180 Trace.endSection();
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700181 }
182
Adrian Roos3e23eb52017-07-07 15:58:57 +0200183 private boolean pulsingOrAod() {
Lucas Dupin9e3fa102017-11-08 17:16:55 -0800184 final ScrimState scrimState = mScrimController.getState();
185 return scrimState == ScrimState.AOD
186 || scrimState == ScrimState.PULSING;
Adrian Roos3e23eb52017-07-07 15:58:57 +0200187 }
188
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700189 @Override
190 public void onFingerprintAuthenticated(int userId) {
Nick Desaulniers1d396752016-07-25 15:05:33 -0700191 Trace.beginSection("FingerprintUnlockController#onFingerprintAuthenticated");
Jorim Jaggi95e40382015-09-16 15:53:42 -0700192 if (mUpdateMonitor.isGoingToSleep()) {
193 mPendingAuthenticatedUserId = userId;
Nick Desaulniers1d396752016-07-25 15:05:33 -0700194 Trace.endSection();
Jorim Jaggi95e40382015-09-16 15:53:42 -0700195 return;
196 }
Adrian Roos6d5ebb72017-08-03 15:10:22 +0200197 startWakeAndUnlock(calculateMode());
198 }
199
200 public void startWakeAndUnlock(int mode) {
Kevin Chyn0b508b42017-09-11 17:34:33 -0700201 // TODO(b/62444020): remove when this bug is fixed
202 Log.v(TAG, "startWakeAndUnlock(" + mode + ")");
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700203 boolean wasDeviceInteractive = mUpdateMonitor.isDeviceInteractive();
Adrian Roos6d5ebb72017-08-03 15:10:22 +0200204 mMode = mode;
Adrian Roos7a5e4c92017-07-31 16:40:19 +0200205 mHasScreenTurnedOnSinceAuthenticating = false;
Adrian Roosb880afe72017-07-25 17:02:46 +0200206 if (mMode == MODE_WAKE_AND_UNLOCK_PULSING && pulsingOrAod()) {
207 // If we are waking the device up while we are pulsing the clock and the
208 // notifications would light up first, creating an unpleasant animation.
209 // Defer changing the screen brightness by forcing doze brightness on our window
210 // until the clock and the notifications are faded out.
211 mStatusBarWindowManager.setForceDozeBrightness(true);
212 }
Lucas Dupin614b9ce2018-07-02 11:17:14 -0700213 // During wake and unlock, we need to draw black before waking up to avoid abrupt
214 // brightness changes due to display state transitions.
215 boolean alwaysOnEnabled = DozeParameters.getInstance(mContext).getAlwaysOn();
216 boolean delayWakeUp = mode == MODE_WAKE_AND_UNLOCK && alwaysOnEnabled;
217 Runnable wakeUp = ()-> {
218 if (!wasDeviceInteractive) {
219 if (DEBUG_FP_WAKELOCK) {
220 Log.i(TAG, "fp wakelock: Authenticated, waking up...");
221 }
222 mPowerManager.wakeUp(SystemClock.uptimeMillis(), "android.policy:FINGERPRINT");
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700223 }
Lucas Dupin614b9ce2018-07-02 11:17:14 -0700224 if (delayWakeUp) {
225 mKeyguardViewMediator.onWakeAndUnlocking();
226 }
227 Trace.beginSection("release wake-and-unlock");
228 releaseFingerprintWakeLock();
229 Trace.endSection();
230 };
231
232 if (!delayWakeUp) {
233 wakeUp.run();
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700234 }
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700235 switch (mMode) {
236 case MODE_DISMISS_BOUNCER:
Nick Desaulniers1d396752016-07-25 15:05:33 -0700237 Trace.beginSection("MODE_DISMISS");
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700238 mStatusBarKeyguardViewManager.notifyKeyguardAuthenticated(
239 false /* strongAuth */);
Nick Desaulniers1d396752016-07-25 15:05:33 -0700240 Trace.endSection();
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700241 break;
242 case MODE_UNLOCK:
243 case MODE_SHOW_BOUNCER:
Nick Desaulniers1d396752016-07-25 15:05:33 -0700244 Trace.beginSection("MODE_UNLOCK or MODE_SHOW_BOUNCER");
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700245 if (!wasDeviceInteractive) {
246 mStatusBarKeyguardViewManager.notifyDeviceWakeUpRequested();
Adrian Roos58ba6852017-07-18 17:10:29 +0200247 mPendingShowBouncer = true;
248 } else {
249 showBouncer();
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700250 }
Nick Desaulniers1d396752016-07-25 15:05:33 -0700251 Trace.endSection();
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700252 break;
Kevin Chyn36778ff2017-09-07 19:55:38 -0700253 case MODE_WAKE_AND_UNLOCK_FROM_DREAM:
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700254 case MODE_WAKE_AND_UNLOCK_PULSING:
Jorim Jaggid94d3a22015-08-21 16:52:55 -0700255 case MODE_WAKE_AND_UNLOCK:
Adrian Roos88e61aa2017-05-23 16:16:50 -0700256 if (mMode == MODE_WAKE_AND_UNLOCK_PULSING) {
257 Trace.beginSection("MODE_WAKE_AND_UNLOCK_PULSING");
258 mStatusBar.updateMediaMetaData(false /* metaDataChanged */,
259 true /* allowEnterAnimation */);
Kevin Chyn36778ff2017-09-07 19:55:38 -0700260 } else if (mMode == MODE_WAKE_AND_UNLOCK){
Adrian Roos88e61aa2017-05-23 16:16:50 -0700261 Trace.beginSection("MODE_WAKE_AND_UNLOCK");
Kevin Chyn36778ff2017-09-07 19:55:38 -0700262 } else {
263 Trace.beginSection("MODE_WAKE_AND_UNLOCK_FROM_DREAM");
264 mUpdateMonitor.awakenFromDream();
Adrian Roos88e61aa2017-05-23 16:16:50 -0700265 }
Jorim Jaggid94d3a22015-08-21 16:52:55 -0700266 mStatusBarWindowManager.setStatusBarFocusable(false);
Lucas Dupin614b9ce2018-07-02 11:17:14 -0700267 if (delayWakeUp) {
268 mHandler.postDelayed(wakeUp, 50);
269 } else {
270 mKeyguardViewMediator.onWakeAndUnlocking();
271 }
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500272 if (mStatusBar.getNavigationBarView() != null) {
273 mStatusBar.getNavigationBarView().setWakeAndUnlocking(true);
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700274 }
Nick Desaulniers1d396752016-07-25 15:05:33 -0700275 Trace.endSection();
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700276 break;
277 case MODE_ONLY_WAKE:
278 case MODE_NONE:
279 break;
280 }
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500281 mStatusBar.notifyFpAuthModeChanged();
Nick Desaulniers1d396752016-07-25 15:05:33 -0700282 Trace.endSection();
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700283 }
284
Adrian Roos58ba6852017-07-18 17:10:29 +0200285 private void showBouncer() {
felkachangefebbc2f72018-05-14 12:22:40 +0800286 if (calculateMode() == MODE_SHOW_BOUNCER) {
287 mStatusBarKeyguardViewManager.showBouncer(false);
288 }
Adrian Roos58ba6852017-07-18 17:10:29 +0200289 mStatusBarKeyguardViewManager.animateCollapsePanels(
290 FINGERPRINT_COLLAPSE_SPEEDUP_FACTOR);
291 mPendingShowBouncer = false;
292 }
293
Jorim Jaggi95e40382015-09-16 15:53:42 -0700294 @Override
295 public void onStartedGoingToSleep(int why) {
Adrian Roosba7ca592017-08-15 17:48:05 +0200296 resetMode();
Jorim Jaggi95e40382015-09-16 15:53:42 -0700297 mPendingAuthenticatedUserId = -1;
298 }
299
300 @Override
301 public void onFinishedGoingToSleep(int why) {
Nick Desaulniers1d396752016-07-25 15:05:33 -0700302 Trace.beginSection("FingerprintUnlockController#onFinishedGoingToSleep");
Jorim Jaggi95e40382015-09-16 15:53:42 -0700303 if (mPendingAuthenticatedUserId != -1) {
304
305 // Post this to make sure it's executed after the device is fully locked.
306 mHandler.post(new Runnable() {
307 @Override
308 public void run() {
309 onFingerprintAuthenticated(mPendingAuthenticatedUserId);
310 }
311 });
312 }
313 mPendingAuthenticatedUserId = -1;
Nick Desaulniers1d396752016-07-25 15:05:33 -0700314 Trace.endSection();
Jorim Jaggi95e40382015-09-16 15:53:42 -0700315 }
316
Adrian Roos710a0b12017-07-07 19:02:34 +0200317 public boolean hasPendingAuthentication() {
318 return mPendingAuthenticatedUserId != -1
319 && mUpdateMonitor.isUnlockingWithFingerprintAllowed()
320 && mPendingAuthenticatedUserId == KeyguardUpdateMonitor.getCurrentUser();
321 }
322
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700323 public int getMode() {
324 return mMode;
325 }
326
327 private int calculateMode() {
328 boolean unlockingAllowed = mUpdateMonitor.isUnlockingWithFingerprintAllowed();
Kevin Chyn36778ff2017-09-07 19:55:38 -0700329 boolean deviceDreaming = mUpdateMonitor.isDreaming();
Adrian Roos02626662017-07-06 18:22:17 +0200330
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700331 if (!mUpdateMonitor.isDeviceInteractive()) {
332 if (!mStatusBarKeyguardViewManager.isShowing()) {
333 return MODE_ONLY_WAKE;
Adrian Roose4cb6c8a2017-07-19 18:08:07 +0200334 } else if (mDozeScrimController.isPulsing() && unlockingAllowed) {
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700335 return MODE_WAKE_AND_UNLOCK_PULSING;
Jorim Jaggi8adb30c2016-09-13 15:02:22 -0700336 } else if (unlockingAllowed || !mUnlockMethodCache.isMethodSecure()) {
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700337 return MODE_WAKE_AND_UNLOCK;
338 } else {
339 return MODE_SHOW_BOUNCER;
340 }
341 }
Kevin Chyn36778ff2017-09-07 19:55:38 -0700342 if (unlockingAllowed && deviceDreaming) {
343 return MODE_WAKE_AND_UNLOCK_FROM_DREAM;
344 }
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700345 if (mStatusBarKeyguardViewManager.isShowing()) {
346 if (mStatusBarKeyguardViewManager.isBouncerShowing() && unlockingAllowed) {
347 return MODE_DISMISS_BOUNCER;
348 } else if (unlockingAllowed) {
349 return MODE_UNLOCK;
Jorim Jaggibf04cf52015-09-02 11:53:02 -0700350 } else if (!mStatusBarKeyguardViewManager.isBouncerShowing()) {
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700351 return MODE_SHOW_BOUNCER;
352 }
353 }
354 return MODE_NONE;
355 }
356
357 @Override
358 public void onFingerprintAuthFailed() {
359 cleanup();
360 }
361
362 @Override
363 public void onFingerprintError(int msgId, String errString) {
364 cleanup();
365 }
366
367 private void cleanup() {
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700368 releaseFingerprintWakeLock();
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700369 }
370
371 public void startKeyguardFadingAway() {
372
373 // Disable brightness override when the ambient contents are fully invisible.
374 mHandler.postDelayed(new Runnable() {
375 @Override
376 public void run() {
377 mStatusBarWindowManager.setForceDozeBrightness(false);
378 }
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500379 }, StatusBar.FADE_KEYGUARD_DURATION_PULSING);
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700380 }
381
382 public void finishKeyguardFadingAway() {
Adrian Roosba7ca592017-08-15 17:48:05 +0200383 resetMode();
384 }
385
386 private void resetMode() {
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700387 mMode = MODE_NONE;
Adrian Roos88e61aa2017-05-23 16:16:50 -0700388 mStatusBarWindowManager.setForceDozeBrightness(false);
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500389 if (mStatusBar.getNavigationBarView() != null) {
390 mStatusBar.getNavigationBarView().setWakeAndUnlocking(false);
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700391 }
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500392 mStatusBar.notifyFpAuthModeChanged();
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700393 }
Adrian Roos58ba6852017-07-18 17:10:29 +0200394
395 private final WakefulnessLifecycle.Observer mWakefulnessObserver =
396 new WakefulnessLifecycle.Observer() {
397 @Override
398 public void onFinishedWakingUp() {
399 if (mPendingShowBouncer) {
400 FingerprintUnlockController.this.showBouncer();
401 }
402 }
403 };
Adrian Roos7a5e4c92017-07-31 16:40:19 +0200404
405 private final ScreenLifecycle.Observer mScreenObserver =
406 new ScreenLifecycle.Observer() {
407 @Override
408 public void onScreenTurnedOn() {
409 mHasScreenTurnedOnSinceAuthenticating = true;
410 }
411 };
412
413 public boolean hasScreenTurnedOnSinceAuthenticating() {
414 return mHasScreenTurnedOnSinceAuthenticating;
415 }
Adrian Roosba7ca592017-08-15 17:48:05 +0200416
417 public void dump(PrintWriter pw) {
418 pw.println(" FingerprintUnlockController:");
419 pw.print(" mMode="); pw.println(mMode);
420 pw.print(" mWakeLock="); pw.println(mWakeLock);
421 }
Lucas Dupin067136c2018-03-27 18:03:25 -0700422
Lucas Dupin52c21c82018-06-04 19:03:20 -0700423 /**
424 * Successful authentication with fingerprint that wakes up the device.
425 */
Lucas Dupin067136c2018-03-27 18:03:25 -0700426 public boolean isWakeAndUnlock() {
Lucas Dupin52c21c82018-06-04 19:03:20 -0700427 return mMode == MODE_WAKE_AND_UNLOCK
Lucas Dupin067136c2018-03-27 18:03:25 -0700428 || mMode == MODE_WAKE_AND_UNLOCK_PULSING
429 || mMode == MODE_WAKE_AND_UNLOCK_FROM_DREAM;
430 }
Lucas Dupin52c21c82018-06-04 19:03:20 -0700431
432 /**
433 * Successful authentication with fingerprint when the screen was either on or off.
434 */
435 public boolean isFingerprintUnlock() {
436 return isWakeAndUnlock() || mMode == MODE_UNLOCK;
437 }
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700438}