Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.systemui.statusbar.phone; |
| 18 | |
| 19 | import android.content.Context; |
Gus Prevas | ab33679 | 2018-11-14 13:52:20 -0500 | [diff] [blame] | 20 | import android.hardware.biometrics.BiometricSourceType; |
Steven Wu | e442acf | 2019-03-14 13:31:12 -0400 | [diff] [blame] | 21 | import android.metrics.LogMaker; |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 22 | import android.os.Handler; |
| 23 | import android.os.PowerManager; |
| 24 | import android.os.SystemClock; |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 25 | import android.os.Trace; |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 26 | import android.util.Log; |
| 27 | |
Lucas Dupin | c94963f | 2019-03-07 14:54:05 -0800 | [diff] [blame] | 28 | import com.android.internal.annotations.VisibleForTesting; |
Steven Wu | e442acf | 2019-03-14 13:31:12 -0400 | [diff] [blame] | 29 | import com.android.internal.logging.MetricsLogger; |
| 30 | import com.android.internal.logging.nano.MetricsProto.MetricsEvent; |
Gus Prevas | ab33679 | 2018-11-14 13:52:20 -0500 | [diff] [blame] | 31 | import com.android.internal.util.LatencyTracker; |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 32 | import com.android.keyguard.KeyguardConstants; |
| 33 | import com.android.keyguard.KeyguardUpdateMonitor; |
| 34 | import com.android.keyguard.KeyguardUpdateMonitorCallback; |
Jason Monk | 421a941 | 2017-02-06 09:15:21 -0800 | [diff] [blame] | 35 | import com.android.systemui.Dependency; |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 36 | import com.android.systemui.keyguard.KeyguardViewMediator; |
Adrian Roos | 7a5e4c9 | 2017-07-31 16:40:19 +0200 | [diff] [blame] | 37 | import com.android.systemui.keyguard.ScreenLifecycle; |
Adrian Roos | 58ba685 | 2017-07-18 17:10:29 +0200 | [diff] [blame] | 38 | import com.android.systemui.keyguard.WakefulnessLifecycle; |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 39 | import com.android.systemui.statusbar.NotificationMediaManager; |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 40 | |
Adrian Roos | ba7ca59 | 2017-08-15 17:48:05 +0200 | [diff] [blame] | 41 | import java.io.PrintWriter; |
| 42 | |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 43 | /** |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 44 | * Controller which coordinates all the biometric unlocking actions with the UI. |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 45 | */ |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 46 | public class BiometricUnlockController extends KeyguardUpdateMonitorCallback { |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 47 | |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 48 | private static final String TAG = "BiometricUnlockController"; |
| 49 | private static final boolean DEBUG_BIO_WAKELOCK = KeyguardConstants.DEBUG_BIOMETRIC_WAKELOCK; |
| 50 | private static final long BIOMETRIC_WAKELOCK_TIMEOUT_MS = 15 * 1000; |
| 51 | private static final String BIOMETRIC_WAKE_LOCK_NAME = "wake-and-unlock wakelock"; |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 52 | |
| 53 | /** |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 54 | * Mode in which we don't need to wake up the device when we authenticate. |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 55 | */ |
| 56 | public static final int MODE_NONE = 0; |
| 57 | |
| 58 | /** |
| 59 | * Mode in which we wake up the device, and directly dismiss Keyguard. Active when we acquire |
| 60 | * a fingerprint while the screen is off and the device was sleeping. |
| 61 | */ |
| 62 | public static final int MODE_WAKE_AND_UNLOCK = 1; |
| 63 | |
| 64 | /** |
| 65 | * Mode in which we wake the device up, and fade out the Keyguard contents because they were |
| 66 | * already visible while pulsing in doze mode. |
| 67 | */ |
| 68 | public static final int MODE_WAKE_AND_UNLOCK_PULSING = 2; |
| 69 | |
| 70 | /** |
| 71 | * Mode in which we wake up the device, but play the normal dismiss animation. Active when we |
| 72 | * acquire a fingerprint pulsing in doze mode. |
| 73 | */ |
| 74 | public static final int MODE_SHOW_BOUNCER = 3; |
| 75 | |
| 76 | /** |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 77 | * Mode in which we only wake up the device, and keyguard was not showing when we authenticated. |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 78 | * */ |
| 79 | public static final int MODE_ONLY_WAKE = 4; |
| 80 | |
| 81 | /** |
| 82 | * Mode in which fingerprint unlocks the device. |
| 83 | */ |
| 84 | public static final int MODE_UNLOCK = 5; |
| 85 | |
| 86 | /** |
Kevin Chyn | 36778ff | 2017-09-07 19:55:38 -0700 | [diff] [blame] | 87 | * Mode in which fingerprint wakes and unlocks the device from a dream. |
| 88 | */ |
Lucas Dupin | e78794c | 2019-06-18 11:55:37 -0700 | [diff] [blame] | 89 | public static final int MODE_WAKE_AND_UNLOCK_FROM_DREAM = 6; |
Kevin Chyn | 36778ff | 2017-09-07 19:55:38 -0700 | [diff] [blame] | 90 | |
| 91 | /** |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 92 | * How much faster we collapse the lockscreen when authenticating with biometric. |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 93 | */ |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 94 | private static final float BIOMETRIC_COLLAPSE_SPEEDUP_FACTOR = 1.1f; |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 95 | |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 96 | private final NotificationMediaManager mMediaManager; |
| 97 | private final PowerManager mPowerManager; |
| 98 | private final Handler mHandler; |
Selim Cinek | 2c890ee | 2019-05-20 19:16:43 -0700 | [diff] [blame] | 99 | private final KeyguardBypassController mKeyguardBypassController; |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 100 | private PowerManager.WakeLock mWakeLock; |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 101 | private final KeyguardUpdateMonitor mUpdateMonitor; |
| 102 | private final UnlockMethodCache mUnlockMethodCache; |
| 103 | private final StatusBarWindowController mStatusBarWindowController; |
| 104 | private final Context mContext; |
| 105 | private final int mWakeUpDelay; |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 106 | private int mMode; |
| 107 | private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 108 | private DozeScrimController mDozeScrimController; |
| 109 | private KeyguardViewMediator mKeyguardViewMediator; |
| 110 | private ScrimController mScrimController; |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 111 | private StatusBar mStatusBar; |
Jorim Jaggi | 95e4038 | 2015-09-16 15:53:42 -0700 | [diff] [blame] | 112 | private int mPendingAuthenticatedUserId = -1; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 113 | private BiometricSourceType mPendingAuthenticatedBioSourceType = null; |
Adrian Roos | 58ba685 | 2017-07-18 17:10:29 +0200 | [diff] [blame] | 114 | private boolean mPendingShowBouncer; |
Adrian Roos | 7a5e4c9 | 2017-07-31 16:40:19 +0200 | [diff] [blame] | 115 | private boolean mHasScreenTurnedOnSinceAuthenticating; |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 116 | |
Steven Wu | e442acf | 2019-03-14 13:31:12 -0400 | [diff] [blame] | 117 | private final MetricsLogger mMetricsLogger = Dependency.get(MetricsLogger.class); |
| 118 | |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 119 | public BiometricUnlockController(Context context, |
Lucas Dupin | c94963f | 2019-03-07 14:54:05 -0800 | [diff] [blame] | 120 | DozeScrimController dozeScrimController, |
| 121 | KeyguardViewMediator keyguardViewMediator, |
| 122 | ScrimController scrimController, |
| 123 | StatusBar statusBar, |
| 124 | UnlockMethodCache unlockMethodCache, Handler handler, |
| 125 | KeyguardUpdateMonitor keyguardUpdateMonitor, |
Selim Cinek | 2c890ee | 2019-05-20 19:16:43 -0700 | [diff] [blame] | 126 | KeyguardBypassController keyguardBypassController) { |
Lucas Dupin | c94963f | 2019-03-07 14:54:05 -0800 | [diff] [blame] | 127 | this(context, dozeScrimController, keyguardViewMediator, scrimController, statusBar, |
Selim Cinek | 2c890ee | 2019-05-20 19:16:43 -0700 | [diff] [blame] | 128 | unlockMethodCache, handler, keyguardUpdateMonitor, |
Lucas Dupin | c94963f | 2019-03-07 14:54:05 -0800 | [diff] [blame] | 129 | context.getResources() |
| 130 | .getInteger(com.android.internal.R.integer.config_wakeUpDelayDoze), |
Selim Cinek | 2c890ee | 2019-05-20 19:16:43 -0700 | [diff] [blame] | 131 | keyguardBypassController); |
Lucas Dupin | c94963f | 2019-03-07 14:54:05 -0800 | [diff] [blame] | 132 | } |
| 133 | |
| 134 | @VisibleForTesting |
| 135 | protected BiometricUnlockController(Context context, |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 136 | DozeScrimController dozeScrimController, |
| 137 | KeyguardViewMediator keyguardViewMediator, |
| 138 | ScrimController scrimController, |
| 139 | StatusBar statusBar, |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 140 | UnlockMethodCache unlockMethodCache, Handler handler, |
| 141 | KeyguardUpdateMonitor keyguardUpdateMonitor, |
Lucas Dupin | c94963f | 2019-03-07 14:54:05 -0800 | [diff] [blame] | 142 | int wakeUpDelay, |
Selim Cinek | 2c890ee | 2019-05-20 19:16:43 -0700 | [diff] [blame] | 143 | KeyguardBypassController keyguardBypassController) { |
Jorim Jaggi | 8adb30c | 2016-09-13 15:02:22 -0700 | [diff] [blame] | 144 | mContext = context; |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 145 | mPowerManager = context.getSystemService(PowerManager.class); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 146 | mUpdateMonitor = keyguardUpdateMonitor; |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 147 | mUpdateMonitor.registerCallback(this); |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 148 | mMediaManager = Dependency.get(NotificationMediaManager.class); |
Adrian Roos | 58ba685 | 2017-07-18 17:10:29 +0200 | [diff] [blame] | 149 | Dependency.get(WakefulnessLifecycle.class).addObserver(mWakefulnessObserver); |
Adrian Roos | 7a5e4c9 | 2017-07-31 16:40:19 +0200 | [diff] [blame] | 150 | Dependency.get(ScreenLifecycle.class).addObserver(mScreenObserver); |
Lucas Dupin | 1a8588d | 2018-08-21 12:18:47 -0700 | [diff] [blame] | 151 | mStatusBarWindowController = Dependency.get(StatusBarWindowController.class); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 152 | mDozeScrimController = dozeScrimController; |
| 153 | mKeyguardViewMediator = keyguardViewMediator; |
| 154 | mScrimController = scrimController; |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 155 | mStatusBar = statusBar; |
Jorim Jaggi | 8adb30c | 2016-09-13 15:02:22 -0700 | [diff] [blame] | 156 | mUnlockMethodCache = unlockMethodCache; |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 157 | mHandler = handler; |
| 158 | mWakeUpDelay = wakeUpDelay; |
Selim Cinek | 2c890ee | 2019-05-20 19:16:43 -0700 | [diff] [blame] | 159 | mKeyguardBypassController = keyguardBypassController; |
Selim Cinek | bd84c16 | 2019-06-11 16:23:23 -0700 | [diff] [blame] | 160 | mKeyguardBypassController.setUnlockController(this); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | public void setStatusBarKeyguardViewManager( |
| 164 | StatusBarKeyguardViewManager statusBarKeyguardViewManager) { |
| 165 | mStatusBarKeyguardViewManager = statusBarKeyguardViewManager; |
| 166 | } |
| 167 | |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 168 | private final Runnable mReleaseBiometricWakeLockRunnable = new Runnable() { |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 169 | @Override |
| 170 | public void run() { |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 171 | if (DEBUG_BIO_WAKELOCK) { |
| 172 | Log.i(TAG, "biometric wakelock: TIMEOUT!!"); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 173 | } |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 174 | releaseBiometricWakeLock(); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 175 | } |
| 176 | }; |
| 177 | |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 178 | private void releaseBiometricWakeLock() { |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 179 | if (mWakeLock != null) { |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 180 | mHandler.removeCallbacks(mReleaseBiometricWakeLockRunnable); |
| 181 | if (DEBUG_BIO_WAKELOCK) { |
| 182 | Log.i(TAG, "releasing biometric wakelock"); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 183 | } |
| 184 | mWakeLock.release(); |
| 185 | mWakeLock = null; |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | @Override |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 190 | public void onBiometricAcquired(BiometricSourceType biometricSourceType) { |
| 191 | Trace.beginSection("BiometricUnlockController#onBiometricAcquired"); |
| 192 | releaseBiometricWakeLock(); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 193 | if (!mUpdateMonitor.isDeviceInteractive()) { |
Jorim Jaggi | 8adb30c | 2016-09-13 15:02:22 -0700 | [diff] [blame] | 194 | if (LatencyTracker.isEnabled(mContext)) { |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 195 | int action = LatencyTracker.ACTION_FINGERPRINT_WAKE_AND_UNLOCK; |
| 196 | if (biometricSourceType == BiometricSourceType.FACE) { |
| 197 | action = LatencyTracker.ACTION_FACE_WAKE_AND_UNLOCK; |
| 198 | } |
| 199 | LatencyTracker.getInstance(mContext).onActionStart(action); |
Jorim Jaggi | 8adb30c | 2016-09-13 15:02:22 -0700 | [diff] [blame] | 200 | } |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 201 | mWakeLock = mPowerManager.newWakeLock( |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 202 | PowerManager.PARTIAL_WAKE_LOCK, BIOMETRIC_WAKE_LOCK_NAME); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 203 | Trace.beginSection("acquiring wake-and-unlock"); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 204 | mWakeLock.acquire(); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 205 | Trace.endSection(); |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 206 | if (DEBUG_BIO_WAKELOCK) { |
| 207 | Log.i(TAG, "biometric acquired, grabbing biometric wakelock"); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 208 | } |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 209 | mHandler.postDelayed(mReleaseBiometricWakeLockRunnable, |
| 210 | BIOMETRIC_WAKELOCK_TIMEOUT_MS); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 211 | } |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 212 | Trace.endSection(); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 213 | } |
| 214 | |
Adrian Roos | 3e23eb5 | 2017-07-07 15:58:57 +0200 | [diff] [blame] | 215 | private boolean pulsingOrAod() { |
Lucas Dupin | 9e3fa10 | 2017-11-08 17:16:55 -0800 | [diff] [blame] | 216 | final ScrimState scrimState = mScrimController.getState(); |
| 217 | return scrimState == ScrimState.AOD |
| 218 | || scrimState == ScrimState.PULSING; |
Adrian Roos | 3e23eb5 | 2017-07-07 15:58:57 +0200 | [diff] [blame] | 219 | } |
| 220 | |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 221 | @Override |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 222 | public void onBiometricAuthenticated(int userId, BiometricSourceType biometricSourceType) { |
| 223 | Trace.beginSection("BiometricUnlockController#onBiometricAuthenticated"); |
Jorim Jaggi | 95e4038 | 2015-09-16 15:53:42 -0700 | [diff] [blame] | 224 | if (mUpdateMonitor.isGoingToSleep()) { |
| 225 | mPendingAuthenticatedUserId = userId; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 226 | mPendingAuthenticatedBioSourceType = biometricSourceType; |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 227 | Trace.endSection(); |
Jorim Jaggi | 95e4038 | 2015-09-16 15:53:42 -0700 | [diff] [blame] | 228 | return; |
| 229 | } |
Steven Wu | e442acf | 2019-03-14 13:31:12 -0400 | [diff] [blame] | 230 | mMetricsLogger.write(new LogMaker(MetricsEvent.BIOMETRIC_AUTH) |
| 231 | .setType(MetricsEvent.TYPE_SUCCESS).setSubtype(toSubtype(biometricSourceType))); |
Selim Cinek | bd84c16 | 2019-06-11 16:23:23 -0700 | [diff] [blame] | 232 | boolean unlockAllowed = mKeyguardBypassController.onBiometricAuthenticated( |
| 233 | biometricSourceType); |
| 234 | if (unlockAllowed) { |
| 235 | startWakeAndUnlock(biometricSourceType); |
| 236 | } |
| 237 | } |
| 238 | |
Selim Cinek | b8cc6ef | 2019-06-14 16:37:53 -0700 | [diff] [blame] | 239 | public void startWakeAndUnlock(BiometricSourceType biometricSourceType) { |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 240 | startWakeAndUnlock(calculateMode(biometricSourceType)); |
Adrian Roos | 6d5ebb7 | 2017-08-03 15:10:22 +0200 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | public void startWakeAndUnlock(int mode) { |
Kevin Chyn | 0b508b4 | 2017-09-11 17:34:33 -0700 | [diff] [blame] | 244 | // TODO(b/62444020): remove when this bug is fixed |
| 245 | Log.v(TAG, "startWakeAndUnlock(" + mode + ")"); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 246 | boolean wasDeviceInteractive = mUpdateMonitor.isDeviceInteractive(); |
Adrian Roos | 6d5ebb7 | 2017-08-03 15:10:22 +0200 | [diff] [blame] | 247 | mMode = mode; |
Adrian Roos | 7a5e4c9 | 2017-07-31 16:40:19 +0200 | [diff] [blame] | 248 | mHasScreenTurnedOnSinceAuthenticating = false; |
Adrian Roos | b880afe7 | 2017-07-25 17:02:46 +0200 | [diff] [blame] | 249 | if (mMode == MODE_WAKE_AND_UNLOCK_PULSING && pulsingOrAod()) { |
| 250 | // If we are waking the device up while we are pulsing the clock and the |
| 251 | // notifications would light up first, creating an unpleasant animation. |
| 252 | // Defer changing the screen brightness by forcing doze brightness on our window |
| 253 | // until the clock and the notifications are faded out. |
Lucas Dupin | 1a8588d | 2018-08-21 12:18:47 -0700 | [diff] [blame] | 254 | mStatusBarWindowController.setForceDozeBrightness(true); |
Adrian Roos | b880afe7 | 2017-07-25 17:02:46 +0200 | [diff] [blame] | 255 | } |
Lucas Dupin | e63abf7 | 2018-07-02 11:17:14 -0700 | [diff] [blame] | 256 | // During wake and unlock, we need to draw black before waking up to avoid abrupt |
| 257 | // brightness changes due to display state transitions. |
| 258 | boolean alwaysOnEnabled = DozeParameters.getInstance(mContext).getAlwaysOn(); |
Lucas Dupin | 2920eea | 2018-08-29 13:13:40 -0700 | [diff] [blame] | 259 | boolean delayWakeUp = mode == MODE_WAKE_AND_UNLOCK && alwaysOnEnabled && mWakeUpDelay > 0; |
Lucas Dupin | e63abf7 | 2018-07-02 11:17:14 -0700 | [diff] [blame] | 260 | Runnable wakeUp = ()-> { |
| 261 | if (!wasDeviceInteractive) { |
| 262 | if (DEBUG_BIO_WAKELOCK) { |
| 263 | Log.i(TAG, "bio wakelock: Authenticated, waking up..."); |
| 264 | } |
Michael Wright | e300104 | 2019-02-05 00:13:14 +0000 | [diff] [blame] | 265 | mPowerManager.wakeUp(SystemClock.uptimeMillis(), PowerManager.WAKE_REASON_GESTURE, |
| 266 | "android.policy:BIOMETRIC"); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 267 | } |
Lucas Dupin | e63abf7 | 2018-07-02 11:17:14 -0700 | [diff] [blame] | 268 | if (delayWakeUp) { |
| 269 | mKeyguardViewMediator.onWakeAndUnlocking(); |
| 270 | } |
| 271 | Trace.beginSection("release wake-and-unlock"); |
| 272 | releaseBiometricWakeLock(); |
| 273 | Trace.endSection(); |
| 274 | }; |
| 275 | |
Lucas Dupin | 4108a9b | 2019-05-28 20:41:51 -0700 | [diff] [blame] | 276 | if (!delayWakeUp && mMode != MODE_NONE) { |
Lucas Dupin | e63abf7 | 2018-07-02 11:17:14 -0700 | [diff] [blame] | 277 | wakeUp.run(); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 278 | } |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 279 | switch (mMode) { |
Lucas Dupin | e78794c | 2019-06-18 11:55:37 -0700 | [diff] [blame] | 280 | case MODE_UNLOCK: |
| 281 | Trace.beginSection("MODE_UNLOCK"); |
| 282 | if (!wasDeviceInteractive) { |
| 283 | mPendingShowBouncer = true; |
| 284 | } else { |
| 285 | mStatusBarKeyguardViewManager.notifyKeyguardAuthenticated( |
| 286 | false /* strongAuth */); |
| 287 | } |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 288 | Trace.endSection(); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 289 | break; |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 290 | case MODE_SHOW_BOUNCER: |
Lucas Dupin | e78794c | 2019-06-18 11:55:37 -0700 | [diff] [blame] | 291 | Trace.beginSection("MODE_SHOW_BOUNCER"); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 292 | if (!wasDeviceInteractive) { |
Adrian Roos | 58ba685 | 2017-07-18 17:10:29 +0200 | [diff] [blame] | 293 | mPendingShowBouncer = true; |
| 294 | } else { |
| 295 | showBouncer(); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 296 | } |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 297 | Trace.endSection(); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 298 | break; |
Kevin Chyn | 36778ff | 2017-09-07 19:55:38 -0700 | [diff] [blame] | 299 | case MODE_WAKE_AND_UNLOCK_FROM_DREAM: |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 300 | case MODE_WAKE_AND_UNLOCK_PULSING: |
Jorim Jaggi | d94d3a2 | 2015-08-21 16:52:55 -0700 | [diff] [blame] | 301 | case MODE_WAKE_AND_UNLOCK: |
Adrian Roos | 88e61aa | 2017-05-23 16:16:50 -0700 | [diff] [blame] | 302 | if (mMode == MODE_WAKE_AND_UNLOCK_PULSING) { |
| 303 | Trace.beginSection("MODE_WAKE_AND_UNLOCK_PULSING"); |
Jason Monk | 297c04e | 2018-08-23 17:16:59 -0400 | [diff] [blame] | 304 | mMediaManager.updateMediaMetaData(false /* metaDataChanged */, |
Adrian Roos | 88e61aa | 2017-05-23 16:16:50 -0700 | [diff] [blame] | 305 | true /* allowEnterAnimation */); |
Kevin Chyn | 36778ff | 2017-09-07 19:55:38 -0700 | [diff] [blame] | 306 | } else if (mMode == MODE_WAKE_AND_UNLOCK){ |
Adrian Roos | 88e61aa | 2017-05-23 16:16:50 -0700 | [diff] [blame] | 307 | Trace.beginSection("MODE_WAKE_AND_UNLOCK"); |
Kevin Chyn | 36778ff | 2017-09-07 19:55:38 -0700 | [diff] [blame] | 308 | } else { |
| 309 | Trace.beginSection("MODE_WAKE_AND_UNLOCK_FROM_DREAM"); |
| 310 | mUpdateMonitor.awakenFromDream(); |
Adrian Roos | 88e61aa | 2017-05-23 16:16:50 -0700 | [diff] [blame] | 311 | } |
Lucas Dupin | 1a8588d | 2018-08-21 12:18:47 -0700 | [diff] [blame] | 312 | mStatusBarWindowController.setStatusBarFocusable(false); |
Lucas Dupin | e63abf7 | 2018-07-02 11:17:14 -0700 | [diff] [blame] | 313 | if (delayWakeUp) { |
Lucas Dupin | 2920eea | 2018-08-29 13:13:40 -0700 | [diff] [blame] | 314 | mHandler.postDelayed(wakeUp, mWakeUpDelay); |
Lucas Dupin | e63abf7 | 2018-07-02 11:17:14 -0700 | [diff] [blame] | 315 | } else { |
| 316 | mKeyguardViewMediator.onWakeAndUnlocking(); |
| 317 | } |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 318 | if (mStatusBar.getNavigationBarView() != null) { |
| 319 | mStatusBar.getNavigationBarView().setWakeAndUnlocking(true); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 320 | } |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 321 | Trace.endSection(); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 322 | break; |
| 323 | case MODE_ONLY_WAKE: |
| 324 | case MODE_NONE: |
| 325 | break; |
| 326 | } |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 327 | mStatusBar.notifyBiometricAuthModeChanged(); |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 328 | Trace.endSection(); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 329 | } |
| 330 | |
Adrian Roos | 58ba685 | 2017-07-18 17:10:29 +0200 | [diff] [blame] | 331 | private void showBouncer() { |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 332 | if (mMode == MODE_SHOW_BOUNCER) { |
felkachang | efebbc2f7 | 2018-05-14 12:22:40 +0800 | [diff] [blame] | 333 | mStatusBarKeyguardViewManager.showBouncer(false); |
| 334 | } |
Adrian Roos | 58ba685 | 2017-07-18 17:10:29 +0200 | [diff] [blame] | 335 | mStatusBarKeyguardViewManager.animateCollapsePanels( |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 336 | BIOMETRIC_COLLAPSE_SPEEDUP_FACTOR); |
Adrian Roos | 58ba685 | 2017-07-18 17:10:29 +0200 | [diff] [blame] | 337 | mPendingShowBouncer = false; |
| 338 | } |
| 339 | |
Jorim Jaggi | 95e4038 | 2015-09-16 15:53:42 -0700 | [diff] [blame] | 340 | @Override |
| 341 | public void onStartedGoingToSleep(int why) { |
Adrian Roos | ba7ca59 | 2017-08-15 17:48:05 +0200 | [diff] [blame] | 342 | resetMode(); |
Jorim Jaggi | 95e4038 | 2015-09-16 15:53:42 -0700 | [diff] [blame] | 343 | mPendingAuthenticatedUserId = -1; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 344 | mPendingAuthenticatedBioSourceType = null; |
Jorim Jaggi | 95e4038 | 2015-09-16 15:53:42 -0700 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | @Override |
| 348 | public void onFinishedGoingToSleep(int why) { |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 349 | Trace.beginSection("BiometricUnlockController#onFinishedGoingToSleep"); |
Lucas Dupin | 45142ba | 2019-04-10 13:13:20 -0700 | [diff] [blame] | 350 | BiometricSourceType pendingType = mPendingAuthenticatedBioSourceType; |
| 351 | int pendingUserId = mPendingAuthenticatedUserId; |
| 352 | if (pendingUserId != -1 && pendingType != null) { |
Jorim Jaggi | 95e4038 | 2015-09-16 15:53:42 -0700 | [diff] [blame] | 353 | // Post this to make sure it's executed after the device is fully locked. |
Lucas Dupin | 45142ba | 2019-04-10 13:13:20 -0700 | [diff] [blame] | 354 | mHandler.post(() -> onBiometricAuthenticated(pendingUserId, pendingType)); |
Jorim Jaggi | 95e4038 | 2015-09-16 15:53:42 -0700 | [diff] [blame] | 355 | } |
| 356 | mPendingAuthenticatedUserId = -1; |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 357 | mPendingAuthenticatedBioSourceType = null; |
Nick Desaulniers | 1d39675 | 2016-07-25 15:05:33 -0700 | [diff] [blame] | 358 | Trace.endSection(); |
Jorim Jaggi | 95e4038 | 2015-09-16 15:53:42 -0700 | [diff] [blame] | 359 | } |
| 360 | |
Adrian Roos | 710a0b1 | 2017-07-07 19:02:34 +0200 | [diff] [blame] | 361 | public boolean hasPendingAuthentication() { |
| 362 | return mPendingAuthenticatedUserId != -1 |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 363 | && mUpdateMonitor.isUnlockingWithBiometricAllowed() |
Adrian Roos | 710a0b1 | 2017-07-07 19:02:34 +0200 | [diff] [blame] | 364 | && mPendingAuthenticatedUserId == KeyguardUpdateMonitor.getCurrentUser(); |
| 365 | } |
| 366 | |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 367 | public int getMode() { |
| 368 | return mMode; |
| 369 | } |
| 370 | |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 371 | private int calculateMode(BiometricSourceType biometricSourceType) { |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 372 | boolean unlockingAllowed = mUpdateMonitor.isUnlockingWithBiometricAllowed(); |
Kevin Chyn | 36778ff | 2017-09-07 19:55:38 -0700 | [diff] [blame] | 373 | boolean deviceDreaming = mUpdateMonitor.isDreaming(); |
Lucas Dupin | 9bae9c2 | 2019-06-04 16:37:40 -0700 | [diff] [blame] | 374 | boolean face = biometricSourceType == BiometricSourceType.FACE; |
| 375 | boolean faceStayingOnKeyguard = face && !mKeyguardBypassController.getBypassEnabled(); |
Adrian Roos | 0262666 | 2017-07-06 18:22:17 +0200 | [diff] [blame] | 376 | |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 377 | if (!mUpdateMonitor.isDeviceInteractive()) { |
| 378 | if (!mStatusBarKeyguardViewManager.isShowing()) { |
| 379 | return MODE_ONLY_WAKE; |
Adrian Roos | e4cb6c8a | 2017-07-19 18:08:07 +0200 | [diff] [blame] | 380 | } else if (mDozeScrimController.isPulsing() && unlockingAllowed) { |
Lucas Dupin | e78794c | 2019-06-18 11:55:37 -0700 | [diff] [blame] | 381 | // Let's not wake-up to lock screen when not bypassing, otherwise the notification |
| 382 | // would move as the user tried to tap it. |
Lucas Dupin | c94963f | 2019-03-07 14:54:05 -0800 | [diff] [blame] | 383 | return faceStayingOnKeyguard ? MODE_NONE : MODE_WAKE_AND_UNLOCK_PULSING; |
Lucas Dupin | 9bae9c2 | 2019-06-04 16:37:40 -0700 | [diff] [blame] | 384 | } else if (!face && (unlockingAllowed || !mUnlockMethodCache.isMethodSecure())) { |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 385 | return MODE_WAKE_AND_UNLOCK; |
Lucas Dupin | 9bae9c2 | 2019-06-04 16:37:40 -0700 | [diff] [blame] | 386 | } else if (face) { |
| 387 | if (!(mDozeScrimController.isPulsing() && !unlockingAllowed)) { |
| 388 | Log.wtf(TAG, "Face somehow arrived when the device was not interactive"); |
| 389 | } |
Lucas Dupin | e78794c | 2019-06-18 11:55:37 -0700 | [diff] [blame] | 390 | if (faceStayingOnKeyguard) { |
| 391 | // We could theoretically return MODE_NONE, but this means that the device |
| 392 | // would be not interactive, unlocked, and the user would not see the device |
| 393 | // state. |
| 394 | return MODE_ONLY_WAKE; |
| 395 | } else { |
| 396 | // Wake-up fading out nicely |
| 397 | return MODE_WAKE_AND_UNLOCK_PULSING; |
| 398 | } |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 399 | } else { |
| 400 | return MODE_SHOW_BOUNCER; |
| 401 | } |
| 402 | } |
Lucas Dupin | c94963f | 2019-03-07 14:54:05 -0800 | [diff] [blame] | 403 | if (unlockingAllowed && deviceDreaming && !faceStayingOnKeyguard) { |
Kevin Chyn | 36778ff | 2017-09-07 19:55:38 -0700 | [diff] [blame] | 404 | return MODE_WAKE_AND_UNLOCK_FROM_DREAM; |
| 405 | } |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 406 | if (mStatusBarKeyguardViewManager.isShowing()) { |
Lucas Dupin | e78794c | 2019-06-18 11:55:37 -0700 | [diff] [blame] | 407 | if ((mStatusBarKeyguardViewManager.isBouncerShowing()) |
Lucas Dupin | d61974d | 2019-03-29 16:09:26 -0700 | [diff] [blame] | 408 | && unlockingAllowed) { |
Lucas Dupin | e78794c | 2019-06-18 11:55:37 -0700 | [diff] [blame] | 409 | return MODE_UNLOCK; |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 410 | } else if (unlockingAllowed) { |
Lucas Dupin | c94963f | 2019-03-07 14:54:05 -0800 | [diff] [blame] | 411 | return faceStayingOnKeyguard ? MODE_ONLY_WAKE : MODE_UNLOCK; |
Lucas Dupin | 9bae9c2 | 2019-06-04 16:37:40 -0700 | [diff] [blame] | 412 | } else if (face) { |
| 413 | return MODE_NONE; |
Jorim Jaggi | bf04cf5 | 2015-09-02 11:53:02 -0700 | [diff] [blame] | 414 | } else if (!mStatusBarKeyguardViewManager.isBouncerShowing()) { |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 415 | return MODE_SHOW_BOUNCER; |
| 416 | } |
| 417 | } |
| 418 | return MODE_NONE; |
| 419 | } |
| 420 | |
| 421 | @Override |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 422 | public void onBiometricAuthFailed(BiometricSourceType biometricSourceType) { |
Steven Wu | e442acf | 2019-03-14 13:31:12 -0400 | [diff] [blame] | 423 | mMetricsLogger.write(new LogMaker(MetricsEvent.BIOMETRIC_AUTH) |
| 424 | .setType(MetricsEvent.TYPE_FAILURE).setSubtype(toSubtype(biometricSourceType))); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 425 | cleanup(); |
| 426 | } |
| 427 | |
| 428 | @Override |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 429 | public void onBiometricError(int msgId, String errString, |
| 430 | BiometricSourceType biometricSourceType) { |
Steven Wu | e442acf | 2019-03-14 13:31:12 -0400 | [diff] [blame] | 431 | mMetricsLogger.write(new LogMaker(MetricsEvent.BIOMETRIC_AUTH) |
Steven Wu | 40cbada | 2019-05-16 10:56:40 -0400 | [diff] [blame] | 432 | .setType(MetricsEvent.TYPE_ERROR).setSubtype(toSubtype(biometricSourceType)) |
| 433 | .addTaggedData(MetricsEvent.FIELD_BIOMETRIC_AUTH_ERROR, msgId)); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 434 | cleanup(); |
| 435 | } |
| 436 | |
| 437 | private void cleanup() { |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 438 | releaseBiometricWakeLock(); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 439 | } |
| 440 | |
| 441 | public void startKeyguardFadingAway() { |
| 442 | |
| 443 | // Disable brightness override when the ambient contents are fully invisible. |
| 444 | mHandler.postDelayed(new Runnable() { |
| 445 | @Override |
| 446 | public void run() { |
Lucas Dupin | 1a8588d | 2018-08-21 12:18:47 -0700 | [diff] [blame] | 447 | mStatusBarWindowController.setForceDozeBrightness(false); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 448 | } |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 449 | }, StatusBar.FADE_KEYGUARD_DURATION_PULSING); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 450 | } |
| 451 | |
| 452 | public void finishKeyguardFadingAway() { |
Adrian Roos | ba7ca59 | 2017-08-15 17:48:05 +0200 | [diff] [blame] | 453 | resetMode(); |
| 454 | } |
| 455 | |
| 456 | private void resetMode() { |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 457 | mMode = MODE_NONE; |
Lucas Dupin | 1a8588d | 2018-08-21 12:18:47 -0700 | [diff] [blame] | 458 | mStatusBarWindowController.setForceDozeBrightness(false); |
Jason Monk | 2a6ea9c | 2017-01-26 11:14:51 -0500 | [diff] [blame] | 459 | if (mStatusBar.getNavigationBarView() != null) { |
| 460 | mStatusBar.getNavigationBarView().setWakeAndUnlocking(false); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 461 | } |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 462 | mStatusBar.notifyBiometricAuthModeChanged(); |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 463 | } |
Adrian Roos | 58ba685 | 2017-07-18 17:10:29 +0200 | [diff] [blame] | 464 | |
| 465 | private final WakefulnessLifecycle.Observer mWakefulnessObserver = |
| 466 | new WakefulnessLifecycle.Observer() { |
| 467 | @Override |
| 468 | public void onFinishedWakingUp() { |
| 469 | if (mPendingShowBouncer) { |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 470 | BiometricUnlockController.this.showBouncer(); |
Adrian Roos | 58ba685 | 2017-07-18 17:10:29 +0200 | [diff] [blame] | 471 | } |
| 472 | } |
| 473 | }; |
Adrian Roos | 7a5e4c9 | 2017-07-31 16:40:19 +0200 | [diff] [blame] | 474 | |
| 475 | private final ScreenLifecycle.Observer mScreenObserver = |
| 476 | new ScreenLifecycle.Observer() { |
| 477 | @Override |
| 478 | public void onScreenTurnedOn() { |
| 479 | mHasScreenTurnedOnSinceAuthenticating = true; |
| 480 | } |
| 481 | }; |
| 482 | |
| 483 | public boolean hasScreenTurnedOnSinceAuthenticating() { |
| 484 | return mHasScreenTurnedOnSinceAuthenticating; |
| 485 | } |
Adrian Roos | ba7ca59 | 2017-08-15 17:48:05 +0200 | [diff] [blame] | 486 | |
| 487 | public void dump(PrintWriter pw) { |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 488 | pw.println(" BiometricUnlockController:"); |
Adrian Roos | ba7ca59 | 2017-08-15 17:48:05 +0200 | [diff] [blame] | 489 | pw.print(" mMode="); pw.println(mMode); |
| 490 | pw.print(" mWakeLock="); pw.println(mWakeLock); |
| 491 | } |
Lucas Dupin | 067136c | 2018-03-27 18:03:25 -0700 | [diff] [blame] | 492 | |
Lucas Dupin | 52c21c8 | 2018-06-04 19:03:20 -0700 | [diff] [blame] | 493 | /** |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 494 | * Successful authentication with fingerprint, face, or iris that wakes up the device. |
Lucas Dupin | 52c21c8 | 2018-06-04 19:03:20 -0700 | [diff] [blame] | 495 | */ |
Lucas Dupin | 067136c | 2018-03-27 18:03:25 -0700 | [diff] [blame] | 496 | public boolean isWakeAndUnlock() { |
Lucas Dupin | 52c21c8 | 2018-06-04 19:03:20 -0700 | [diff] [blame] | 497 | return mMode == MODE_WAKE_AND_UNLOCK |
Lucas Dupin | 067136c | 2018-03-27 18:03:25 -0700 | [diff] [blame] | 498 | || mMode == MODE_WAKE_AND_UNLOCK_PULSING |
| 499 | || mMode == MODE_WAKE_AND_UNLOCK_FROM_DREAM; |
| 500 | } |
Lucas Dupin | 52c21c8 | 2018-06-04 19:03:20 -0700 | [diff] [blame] | 501 | |
| 502 | /** |
Lucas Dupin | 3d05353 | 2019-01-29 12:35:22 -0800 | [diff] [blame] | 503 | * Successful authentication with fingerprint, face, or iris when the screen was either |
| 504 | * on or off. |
Lucas Dupin | 52c21c8 | 2018-06-04 19:03:20 -0700 | [diff] [blame] | 505 | */ |
Gilad Bretter | cb51b8b | 2018-03-22 17:04:51 +0200 | [diff] [blame] | 506 | public boolean isBiometricUnlock() { |
Lucas Dupin | 52c21c8 | 2018-06-04 19:03:20 -0700 | [diff] [blame] | 507 | return isWakeAndUnlock() || mMode == MODE_UNLOCK; |
| 508 | } |
Steven Wu | e442acf | 2019-03-14 13:31:12 -0400 | [diff] [blame] | 509 | |
| 510 | /** |
| 511 | * Translates biometric source type for logging purpose. |
| 512 | */ |
| 513 | private int toSubtype(BiometricSourceType biometricSourceType) { |
| 514 | switch (biometricSourceType) { |
| 515 | case FINGERPRINT: |
| 516 | return 0; |
| 517 | case FACE: |
| 518 | return 1; |
| 519 | case IRIS: |
| 520 | return 2; |
| 521 | default: |
| 522 | return 3; |
| 523 | } |
| 524 | } |
Jorim Jaggi | 83eb6bb | 2015-08-17 17:38:58 -0700 | [diff] [blame] | 525 | } |