blob: f0b1a82cfc2fed7688fb7d16e0340c8af9c4987d [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 }
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700213 if (!wasDeviceInteractive) {
214 if (DEBUG_FP_WAKELOCK) {
215 Log.i(TAG, "fp wakelock: Authenticated, waking up...");
216 }
Adam Lesinski5bcb8bb2015-11-03 16:31:25 -0800217 mPowerManager.wakeUp(SystemClock.uptimeMillis(), "android.policy:FINGERPRINT");
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700218 }
Nick Desaulniers1d396752016-07-25 15:05:33 -0700219 Trace.beginSection("release wake-and-unlock");
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700220 releaseFingerprintWakeLock();
Nick Desaulniers1d396752016-07-25 15:05:33 -0700221 Trace.endSection();
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700222 switch (mMode) {
223 case MODE_DISMISS_BOUNCER:
Nick Desaulniers1d396752016-07-25 15:05:33 -0700224 Trace.beginSection("MODE_DISMISS");
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700225 mStatusBarKeyguardViewManager.notifyKeyguardAuthenticated(
226 false /* strongAuth */);
Nick Desaulniers1d396752016-07-25 15:05:33 -0700227 Trace.endSection();
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700228 break;
229 case MODE_UNLOCK:
230 case MODE_SHOW_BOUNCER:
Nick Desaulniers1d396752016-07-25 15:05:33 -0700231 Trace.beginSection("MODE_UNLOCK or MODE_SHOW_BOUNCER");
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700232 if (!wasDeviceInteractive) {
233 mStatusBarKeyguardViewManager.notifyDeviceWakeUpRequested();
Adrian Roos58ba6852017-07-18 17:10:29 +0200234 mPendingShowBouncer = true;
235 } else {
236 showBouncer();
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700237 }
Nick Desaulniers1d396752016-07-25 15:05:33 -0700238 Trace.endSection();
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700239 break;
Kevin Chyn36778ff2017-09-07 19:55:38 -0700240 case MODE_WAKE_AND_UNLOCK_FROM_DREAM:
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700241 case MODE_WAKE_AND_UNLOCK_PULSING:
Jorim Jaggid94d3a22015-08-21 16:52:55 -0700242 case MODE_WAKE_AND_UNLOCK:
Adrian Roos88e61aa2017-05-23 16:16:50 -0700243 if (mMode == MODE_WAKE_AND_UNLOCK_PULSING) {
244 Trace.beginSection("MODE_WAKE_AND_UNLOCK_PULSING");
245 mStatusBar.updateMediaMetaData(false /* metaDataChanged */,
246 true /* allowEnterAnimation */);
Kevin Chyn36778ff2017-09-07 19:55:38 -0700247 } else if (mMode == MODE_WAKE_AND_UNLOCK){
Adrian Roos88e61aa2017-05-23 16:16:50 -0700248 Trace.beginSection("MODE_WAKE_AND_UNLOCK");
Kevin Chyn36778ff2017-09-07 19:55:38 -0700249 } else {
250 Trace.beginSection("MODE_WAKE_AND_UNLOCK_FROM_DREAM");
251 mUpdateMonitor.awakenFromDream();
Adrian Roos88e61aa2017-05-23 16:16:50 -0700252 }
Jorim Jaggid94d3a22015-08-21 16:52:55 -0700253 mStatusBarWindowManager.setStatusBarFocusable(false);
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700254 mKeyguardViewMediator.onWakeAndUnlocking();
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500255 if (mStatusBar.getNavigationBarView() != null) {
256 mStatusBar.getNavigationBarView().setWakeAndUnlocking(true);
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700257 }
Nick Desaulniers1d396752016-07-25 15:05:33 -0700258 Trace.endSection();
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700259 break;
260 case MODE_ONLY_WAKE:
261 case MODE_NONE:
262 break;
263 }
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500264 mStatusBar.notifyFpAuthModeChanged();
Nick Desaulniers1d396752016-07-25 15:05:33 -0700265 Trace.endSection();
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700266 }
267
Adrian Roos58ba6852017-07-18 17:10:29 +0200268 private void showBouncer() {
felkachangefebbc2f72018-05-14 12:22:40 +0800269 if (calculateMode() == MODE_SHOW_BOUNCER) {
270 mStatusBarKeyguardViewManager.showBouncer(false);
271 }
Adrian Roos58ba6852017-07-18 17:10:29 +0200272 mStatusBarKeyguardViewManager.animateCollapsePanels(
273 FINGERPRINT_COLLAPSE_SPEEDUP_FACTOR);
274 mPendingShowBouncer = false;
275 }
276
Jorim Jaggi95e40382015-09-16 15:53:42 -0700277 @Override
278 public void onStartedGoingToSleep(int why) {
Adrian Roosba7ca592017-08-15 17:48:05 +0200279 resetMode();
Jorim Jaggi95e40382015-09-16 15:53:42 -0700280 mPendingAuthenticatedUserId = -1;
281 }
282
283 @Override
284 public void onFinishedGoingToSleep(int why) {
Nick Desaulniers1d396752016-07-25 15:05:33 -0700285 Trace.beginSection("FingerprintUnlockController#onFinishedGoingToSleep");
Jorim Jaggi95e40382015-09-16 15:53:42 -0700286 if (mPendingAuthenticatedUserId != -1) {
287
288 // Post this to make sure it's executed after the device is fully locked.
289 mHandler.post(new Runnable() {
290 @Override
291 public void run() {
292 onFingerprintAuthenticated(mPendingAuthenticatedUserId);
293 }
294 });
295 }
296 mPendingAuthenticatedUserId = -1;
Nick Desaulniers1d396752016-07-25 15:05:33 -0700297 Trace.endSection();
Jorim Jaggi95e40382015-09-16 15:53:42 -0700298 }
299
Adrian Roos710a0b12017-07-07 19:02:34 +0200300 public boolean hasPendingAuthentication() {
301 return mPendingAuthenticatedUserId != -1
302 && mUpdateMonitor.isUnlockingWithFingerprintAllowed()
303 && mPendingAuthenticatedUserId == KeyguardUpdateMonitor.getCurrentUser();
304 }
305
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700306 public int getMode() {
307 return mMode;
308 }
309
310 private int calculateMode() {
311 boolean unlockingAllowed = mUpdateMonitor.isUnlockingWithFingerprintAllowed();
Kevin Chyn36778ff2017-09-07 19:55:38 -0700312 boolean deviceDreaming = mUpdateMonitor.isDreaming();
Adrian Roos02626662017-07-06 18:22:17 +0200313
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700314 if (!mUpdateMonitor.isDeviceInteractive()) {
315 if (!mStatusBarKeyguardViewManager.isShowing()) {
316 return MODE_ONLY_WAKE;
Adrian Roose4cb6c8a2017-07-19 18:08:07 +0200317 } else if (mDozeScrimController.isPulsing() && unlockingAllowed) {
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700318 return MODE_WAKE_AND_UNLOCK_PULSING;
Jorim Jaggi8adb30c2016-09-13 15:02:22 -0700319 } else if (unlockingAllowed || !mUnlockMethodCache.isMethodSecure()) {
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700320 return MODE_WAKE_AND_UNLOCK;
321 } else {
322 return MODE_SHOW_BOUNCER;
323 }
324 }
Kevin Chyn36778ff2017-09-07 19:55:38 -0700325 if (unlockingAllowed && deviceDreaming) {
326 return MODE_WAKE_AND_UNLOCK_FROM_DREAM;
327 }
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700328 if (mStatusBarKeyguardViewManager.isShowing()) {
329 if (mStatusBarKeyguardViewManager.isBouncerShowing() && unlockingAllowed) {
330 return MODE_DISMISS_BOUNCER;
331 } else if (unlockingAllowed) {
332 return MODE_UNLOCK;
Jorim Jaggibf04cf52015-09-02 11:53:02 -0700333 } else if (!mStatusBarKeyguardViewManager.isBouncerShowing()) {
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700334 return MODE_SHOW_BOUNCER;
335 }
336 }
337 return MODE_NONE;
338 }
339
340 @Override
341 public void onFingerprintAuthFailed() {
342 cleanup();
343 }
344
345 @Override
346 public void onFingerprintError(int msgId, String errString) {
347 cleanup();
348 }
349
350 private void cleanup() {
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700351 releaseFingerprintWakeLock();
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700352 }
353
354 public void startKeyguardFadingAway() {
355
356 // Disable brightness override when the ambient contents are fully invisible.
357 mHandler.postDelayed(new Runnable() {
358 @Override
359 public void run() {
360 mStatusBarWindowManager.setForceDozeBrightness(false);
361 }
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500362 }, StatusBar.FADE_KEYGUARD_DURATION_PULSING);
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700363 }
364
365 public void finishKeyguardFadingAway() {
Adrian Roosba7ca592017-08-15 17:48:05 +0200366 resetMode();
367 }
368
369 private void resetMode() {
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700370 mMode = MODE_NONE;
Adrian Roos88e61aa2017-05-23 16:16:50 -0700371 mStatusBarWindowManager.setForceDozeBrightness(false);
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500372 if (mStatusBar.getNavigationBarView() != null) {
373 mStatusBar.getNavigationBarView().setWakeAndUnlocking(false);
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700374 }
Jason Monk2a6ea9c2017-01-26 11:14:51 -0500375 mStatusBar.notifyFpAuthModeChanged();
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700376 }
Adrian Roos58ba6852017-07-18 17:10:29 +0200377
378 private final WakefulnessLifecycle.Observer mWakefulnessObserver =
379 new WakefulnessLifecycle.Observer() {
380 @Override
381 public void onFinishedWakingUp() {
382 if (mPendingShowBouncer) {
383 FingerprintUnlockController.this.showBouncer();
384 }
385 }
386 };
Adrian Roos7a5e4c92017-07-31 16:40:19 +0200387
388 private final ScreenLifecycle.Observer mScreenObserver =
389 new ScreenLifecycle.Observer() {
390 @Override
391 public void onScreenTurnedOn() {
392 mHasScreenTurnedOnSinceAuthenticating = true;
393 }
394 };
395
396 public boolean hasScreenTurnedOnSinceAuthenticating() {
397 return mHasScreenTurnedOnSinceAuthenticating;
398 }
Adrian Roosba7ca592017-08-15 17:48:05 +0200399
400 public void dump(PrintWriter pw) {
401 pw.println(" FingerprintUnlockController:");
402 pw.print(" mMode="); pw.println(mMode);
403 pw.print(" mWakeLock="); pw.println(mWakeLock);
404 }
Lucas Dupin067136c2018-03-27 18:03:25 -0700405
Lucas Dupin52c21c82018-06-04 19:03:20 -0700406 /**
407 * Successful authentication with fingerprint that wakes up the device.
408 */
Lucas Dupin067136c2018-03-27 18:03:25 -0700409 public boolean isWakeAndUnlock() {
Lucas Dupin52c21c82018-06-04 19:03:20 -0700410 return mMode == MODE_WAKE_AND_UNLOCK
Lucas Dupin067136c2018-03-27 18:03:25 -0700411 || mMode == MODE_WAKE_AND_UNLOCK_PULSING
412 || mMode == MODE_WAKE_AND_UNLOCK_FROM_DREAM;
413 }
Lucas Dupin52c21c82018-06-04 19:03:20 -0700414
415 /**
416 * Successful authentication with fingerprint when the screen was either on or off.
417 */
418 public boolean isFingerprintUnlock() {
419 return isWakeAndUnlock() || mMode == MODE_UNLOCK;
420 }
Jorim Jaggi83eb6bb2015-08-17 17:38:58 -0700421}