diff options
| -rw-r--r-- | packages/SystemUI/src/com/android/keyguard/KeyguardConstants.java | 1 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java | 4 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/keyguard/logging/BiometricMessageDeferralLogger.kt | 4 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/keyguard/logging/BiometricUnlockLogger.kt | 174 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/keyguard/logging/KeyguardUpdateMonitorLogger.kt | 7 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/log/dagger/BiometricLog.java (renamed from packages/SystemUI/src/com/android/systemui/log/dagger/BiometricMessagesLog.java) | 2 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java | 6 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java | 113 | ||||
| -rw-r--r-- | packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java | 10 |
9 files changed, 279 insertions, 42 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardConstants.java b/packages/SystemUI/src/com/android/keyguard/KeyguardConstants.java index b2658c9f9bdb..a5b62b6e7c64 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardConstants.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardConstants.java @@ -29,5 +29,4 @@ public class KeyguardConstants { */ public static final boolean DEBUG = Log.isLoggable("Keyguard", Log.DEBUG); public static final boolean DEBUG_SIM_STATES = true; - public static final boolean DEBUG_BIOMETRIC_WAKELOCK = true; } diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index 88477aaa03de..331497e4bf85 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -845,6 +845,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab + " triggered while waiting for cancellation, removing watchdog"); mHandler.removeCallbacks(mFpCancelNotReceived); } + mLogger.d("handleFingerprintAuthFailed"); for (int i = 0; i < mCallbacks.size(); i++) { KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); if (cb != null) { @@ -974,6 +975,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab stopListeningForFace(FACE_AUTH_STOPPED_FP_LOCKED_OUT); } + mLogger.logFingerprintError(msgId, errString); for (int i = 0; i < mCallbacks.size(); i++) { KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get(); if (cb != null) { @@ -3900,6 +3902,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab pw.println(" listening: actual=" + mFaceRunningState + " expected=(" + (shouldListenForFace() ? 1 : 0)); pw.println(" strongAuthFlags=" + Integer.toHexString(strongAuthFlags)); + pw.println(" isNonStrongBiometricAllowedAfterIdleTimeout=" + + mStrongAuthTracker.isNonStrongBiometricAllowedAfterIdleTimeout(userId)); pw.println(" trustManaged=" + getUserTrustIsManaged(userId)); pw.println(" mFaceLockedOutPermanent=" + mFaceLockedOutPermanent); pw.println(" enabledByUser=" + mBiometricEnabledForUser.get(userId)); diff --git a/packages/SystemUI/src/com/android/keyguard/logging/BiometricMessageDeferralLogger.kt b/packages/SystemUI/src/com/android/keyguard/logging/BiometricMessageDeferralLogger.kt index 6264ce7273f1..2bb75aa34c6a 100644 --- a/packages/SystemUI/src/com/android/keyguard/logging/BiometricMessageDeferralLogger.kt +++ b/packages/SystemUI/src/com/android/keyguard/logging/BiometricMessageDeferralLogger.kt @@ -17,7 +17,7 @@ package com.android.keyguard.logging import com.android.systemui.dagger.SysUISingleton -import com.android.systemui.log.dagger.BiometricMessagesLog +import com.android.systemui.log.dagger.BiometricLog import com.android.systemui.plugins.log.LogBuffer import com.android.systemui.plugins.log.LogLevel.DEBUG import javax.inject.Inject @@ -26,7 +26,7 @@ import javax.inject.Inject @SysUISingleton class FaceMessageDeferralLogger @Inject -constructor(@BiometricMessagesLog private val logBuffer: LogBuffer) : +constructor(@BiometricLog private val logBuffer: LogBuffer) : BiometricMessageDeferralLogger(logBuffer, "FaceMessageDeferralLogger") open class BiometricMessageDeferralLogger( diff --git a/packages/SystemUI/src/com/android/keyguard/logging/BiometricUnlockLogger.kt b/packages/SystemUI/src/com/android/keyguard/logging/BiometricUnlockLogger.kt new file mode 100644 index 000000000000..bc0bd8c53d26 --- /dev/null +++ b/packages/SystemUI/src/com/android/keyguard/logging/BiometricUnlockLogger.kt @@ -0,0 +1,174 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.keyguard.logging + +import com.android.systemui.dagger.SysUISingleton +import com.android.systemui.log.dagger.BiometricLog +import com.android.systemui.plugins.log.LogBuffer +import com.android.systemui.plugins.log.LogLevel +import com.android.systemui.plugins.log.LogLevel.DEBUG +import com.android.systemui.plugins.log.LogLevel.INFO +import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_DISMISS_BOUNCER +import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_NONE +import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_ONLY_WAKE +import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_SHOW_BOUNCER +import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_UNLOCK_COLLAPSING +import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_WAKE_AND_UNLOCK +import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_WAKE_AND_UNLOCK_FROM_DREAM +import com.android.systemui.statusbar.phone.BiometricUnlockController.MODE_WAKE_AND_UNLOCK_PULSING +import com.google.errorprone.annotations.CompileTimeConstant +import javax.inject.Inject + +private const val TAG = "BiometricUnlockLogger" + +/** Helper class for logging for [com.android.systemui.statusbar.phone.BiometricUnlockController] */ +@SysUISingleton +class BiometricUnlockLogger @Inject constructor(@BiometricLog private val logBuffer: LogBuffer) { + fun i(@CompileTimeConstant msg: String) = log(msg, INFO) + fun d(@CompileTimeConstant msg: String) = log(msg, DEBUG) + fun log(@CompileTimeConstant msg: String, level: LogLevel) = logBuffer.log(TAG, level, msg) + + fun logStartWakeAndUnlock(mode: Int) { + logBuffer.log( + TAG, + DEBUG, + { int1 = mode }, + { "startWakeAndUnlock(${wakeAndUnlockModeToString(int1)})" } + ) + } + + fun logUdfpsAttemptThresholdMet(consecutiveFailedAttempts: Int) { + logBuffer.log( + TAG, + DEBUG, + { int1 = consecutiveFailedAttempts }, + { "udfpsAttemptThresholdMet consecutiveFailedAttempts=$int1" } + ) + } + + fun logCalculateModeForFingerprintUnlockingAllowed( + deviceInteractive: Boolean, + keyguardShowing: Boolean, + deviceDreaming: Boolean + ) { + logBuffer.log( + TAG, + DEBUG, + { + bool1 = deviceInteractive + bool2 = keyguardShowing + bool3 = deviceDreaming + }, + { + "calculateModeForFingerprint unlockingAllowed=true" + + " deviceInteractive=$bool1 isKeyguardShowing=$bool2" + + " deviceDreaming=$bool3" + } + ) + } + + fun logCalculateModeForFingerprintUnlockingNotAllowed( + strongBiometric: Boolean, + strongAuthFlags: Int, + nonStrongBiometricAllowed: Boolean, + deviceInteractive: Boolean, + keyguardShowing: Boolean + ) { + logBuffer.log( + TAG, + DEBUG, + { + int1 = strongAuthFlags + bool1 = strongBiometric + bool2 = nonStrongBiometricAllowed + bool3 = deviceInteractive + bool4 = keyguardShowing + }, + { + "calculateModeForFingerprint unlockingAllowed=false" + + " strongBiometric=$bool1 strongAuthFlags=$int1" + + " nonStrongBiometricAllowed=$bool2" + + " deviceInteractive=$bool3 isKeyguardShowing=$bool4" + } + ) + } + + fun logCalculateModeForPassiveAuthUnlockingAllowed( + deviceInteractive: Boolean, + keyguardShowing: Boolean, + deviceDreaming: Boolean, + bypass: Boolean + ) { + logBuffer.log( + TAG, + DEBUG, + { + bool1 = deviceInteractive + bool2 = keyguardShowing + bool3 = deviceDreaming + bool4 = bypass + }, + { + "calculateModeForPassiveAuth unlockingAllowed=true" + + " deviceInteractive=$bool1 isKeyguardShowing=$bool2" + + " deviceDreaming=$bool3 bypass=$bool4" + } + ) + } + + fun logCalculateModeForPassiveAuthUnlockingNotAllowed( + strongBiometric: Boolean, + strongAuthFlags: Int, + nonStrongBiometricAllowed: Boolean, + deviceInteractive: Boolean, + keyguardShowing: Boolean, + bypass: Boolean + ) { + logBuffer.log( + TAG, + DEBUG, + { + int1 = if (strongBiometric) 1 else 0 + int2 = strongAuthFlags + bool1 = nonStrongBiometricAllowed + bool2 = deviceInteractive + bool3 = keyguardShowing + bool4 = bypass + }, + { + "calculateModeForPassiveAuth unlockingAllowed=false" + + " strongBiometric=${int1 == 1}" + + " strongAuthFlags=$int2 nonStrongBiometricAllowed=$bool1" + + " deviceInteractive=$bool2 isKeyguardShowing=$bool3 bypass=$bool4" + } + ) + } +} + +private fun wakeAndUnlockModeToString(mode: Int): String { + return when (mode) { + MODE_NONE -> "MODE_NONE" + MODE_WAKE_AND_UNLOCK -> "MODE_WAKE_AND_UNLOCK" + MODE_WAKE_AND_UNLOCK_PULSING -> "MODE_WAKE_AND_UNLOCK_PULSING" + MODE_SHOW_BOUNCER -> "MODE_SHOW_BOUNCER" + MODE_ONLY_WAKE -> "MODE_ONLY_WAKE" + MODE_UNLOCK_COLLAPSING -> "MODE_UNLOCK_COLLAPSING" + MODE_WAKE_AND_UNLOCK_FROM_DREAM -> "MODE_WAKE_AND_UNLOCK_FROM_DREAM" + MODE_DISMISS_BOUNCER -> "MODE_DISMISS_BOUNCER" + else -> "UNKNOWN{$mode}" + } +} diff --git a/packages/SystemUI/src/com/android/keyguard/logging/KeyguardUpdateMonitorLogger.kt b/packages/SystemUI/src/com/android/keyguard/logging/KeyguardUpdateMonitorLogger.kt index 676370093aee..1f6441a47092 100644 --- a/packages/SystemUI/src/com/android/keyguard/logging/KeyguardUpdateMonitorLogger.kt +++ b/packages/SystemUI/src/com/android/keyguard/logging/KeyguardUpdateMonitorLogger.kt @@ -161,6 +161,13 @@ class KeyguardUpdateMonitorLogger @Inject constructor( }, {"Fingerprint auth successful: userId: $int1, isStrongBiometric: $bool1"}) } + fun logFingerprintError(msgId: Int, originalErrMsg: String) { + logBuffer.log(TAG, DEBUG, { + str1 = originalErrMsg + int1 = msgId + }, { "Fingerprint error received: $str1 msgId= $int1" }) + } + fun logInvalidSubId(subId: Int) { logBuffer.log(TAG, INFO, { int1 = subId }, diff --git a/packages/SystemUI/src/com/android/systemui/log/dagger/BiometricMessagesLog.java b/packages/SystemUI/src/com/android/systemui/log/dagger/BiometricLog.java index eeadf406060d..4b774d3b2192 100644 --- a/packages/SystemUI/src/com/android/systemui/log/dagger/BiometricMessagesLog.java +++ b/packages/SystemUI/src/com/android/systemui/log/dagger/BiometricLog.java @@ -29,5 +29,5 @@ import javax.inject.Qualifier; @Qualifier @Documented @Retention(RetentionPolicy.RUNTIME) -public @interface BiometricMessagesLog { +public @interface BiometricLog { } diff --git a/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java b/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java index 9adb855d66ac..74d50433b9a7 100644 --- a/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java +++ b/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java @@ -300,9 +300,9 @@ public class LogModule { */ @Provides @SysUISingleton - @BiometricMessagesLog - public static LogBuffer provideBiometricMessagesLogBuffer(LogBufferFactory factory) { - return factory.create("BiometricMessagesLog", 150); + @BiometricLog + public static LogBuffer provideBiometricLogBuffer(LogBufferFactory factory) { + return factory.create("BiometricLog", 200); } /** diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java index 182d39705ed6..679bcea00f74 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/BiometricUnlockController.java @@ -29,7 +29,6 @@ import android.os.Handler; import android.os.PowerManager; import android.os.SystemClock; import android.os.Trace; -import android.util.Log; import androidx.annotation.Nullable; @@ -41,10 +40,10 @@ import com.android.internal.logging.UiEventLogger; import com.android.internal.logging.UiEventLoggerImpl; import com.android.internal.logging.nano.MetricsProto.MetricsEvent; import com.android.internal.util.LatencyTracker; -import com.android.keyguard.KeyguardConstants; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; import com.android.keyguard.KeyguardViewController; +import com.android.keyguard.logging.BiometricUnlockLogger; import com.android.systemui.Dumpable; import com.android.systemui.R; import com.android.systemui.biometrics.AuthController; @@ -79,9 +78,6 @@ import javax.inject.Inject; */ @SysUISingleton public class BiometricUnlockController extends KeyguardUpdateMonitorCallback implements Dumpable { - - private static final String TAG = "BiometricUnlockCtrl"; - private static final boolean DEBUG_BIO_WAKELOCK = KeyguardConstants.DEBUG_BIOMETRIC_WAKELOCK; private static final long BIOMETRIC_WAKELOCK_TIMEOUT_MS = 15 * 1000; private static final String BIOMETRIC_WAKE_LOCK_NAME = "wake-and-unlock:wakelock"; private static final UiEventLogger UI_EVENT_LOGGER = new UiEventLoggerImpl(); @@ -176,6 +172,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp private final StatusBarStateController mStatusBarStateController; private final LatencyTracker mLatencyTracker; private final VibratorHelper mVibratorHelper; + private final BiometricUnlockLogger mLogger; private long mLastFpFailureUptimeMillis; private int mNumConsecutiveFpFailures; @@ -262,7 +259,8 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp private final ScreenOffAnimationController mScreenOffAnimationController; @Inject - public BiometricUnlockController(DozeScrimController dozeScrimController, + public BiometricUnlockController( + DozeScrimController dozeScrimController, KeyguardViewMediator keyguardViewMediator, ScrimController scrimController, ShadeController shadeController, NotificationShadeWindowController notificationShadeWindowController, @@ -272,6 +270,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp KeyguardBypassController keyguardBypassController, MetricsLogger metricsLogger, DumpManager dumpManager, PowerManager powerManager, + BiometricUnlockLogger biometricUnlockLogger, NotificationMediaManager notificationMediaManager, WakefulnessLifecycle wakefulnessLifecycle, ScreenLifecycle screenLifecycle, @@ -308,6 +307,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp mSessionTracker = sessionTracker; mScreenOffAnimationController = screenOffAnimationController; mVibratorHelper = vibrator; + mLogger = biometricUnlockLogger; dumpManager.registerDumpable(getClass().getName(), this); } @@ -329,9 +329,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp private final Runnable mReleaseBiometricWakeLockRunnable = new Runnable() { @Override public void run() { - if (DEBUG_BIO_WAKELOCK) { - Log.i(TAG, "biometric wakelock: TIMEOUT!!"); - } + mLogger.i("biometric wakelock: TIMEOUT!!"); releaseBiometricWakeLock(); } }; @@ -339,9 +337,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp private void releaseBiometricWakeLock() { if (mWakeLock != null) { mHandler.removeCallbacks(mReleaseBiometricWakeLockRunnable); - if (DEBUG_BIO_WAKELOCK) { - Log.i(TAG, "releasing biometric wakelock"); - } + mLogger.i("releasing biometric wakelock"); mWakeLock.release(); mWakeLock = null; } @@ -372,9 +368,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp Trace.beginSection("acquiring wake-and-unlock"); mWakeLock.acquire(); Trace.endSection(); - if (DEBUG_BIO_WAKELOCK) { - Log.i(TAG, "biometric acquired, grabbing biometric wakelock"); - } + mLogger.i("biometric acquired, grabbing biometric wakelock"); mHandler.postDelayed(mReleaseBiometricWakeLockRunnable, BIOMETRIC_WAKELOCK_TIMEOUT_MS); } @@ -411,7 +405,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp mKeyguardViewMediator.userActivity(); startWakeAndUnlock(biometricSourceType, isStrongBiometric); } else { - Log.d(TAG, "onBiometricAuthenticated aborted by bypass controller"); + mLogger.d("onBiometricAuthenticated aborted by bypass controller"); } } @@ -427,7 +421,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp } public void startWakeAndUnlock(@WakeAndUnlockMode int mode) { - Log.v(TAG, "startWakeAndUnlock(" + mode + ")"); + mLogger.logStartWakeAndUnlock(mode); boolean wasDeviceInteractive = mUpdateMonitor.isDeviceInteractive(); mMode = mode; mHasScreenTurnedOnSinceAuthenticating = false; @@ -442,9 +436,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp // brightness changes due to display state transitions. Runnable wakeUp = ()-> { if (!wasDeviceInteractive || mUpdateMonitor.isDreaming()) { - if (DEBUG_BIO_WAKELOCK) { - Log.i(TAG, "bio wakelock: Authenticated, waking up..."); - } + mLogger.i("bio wakelock: Authenticated, waking up..."); mPowerManager.wakeUp(SystemClock.uptimeMillis(), PowerManager.WAKE_REASON_GESTURE, "android.policy:BIOMETRIC"); } @@ -537,13 +529,16 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp } private @WakeAndUnlockMode int calculateModeForFingerprint(boolean isStrongBiometric) { - boolean unlockingAllowed = + final boolean unlockingAllowed = mUpdateMonitor.isUnlockingWithBiometricAllowed(isStrongBiometric); - boolean deviceDreaming = mUpdateMonitor.isDreaming(); - - if (!mUpdateMonitor.isDeviceInteractive()) { - if (!mKeyguardStateController.isShowing() - && !mScreenOffAnimationController.isKeyguardShowDelayed()) { + final boolean deviceInteractive = mUpdateMonitor.isDeviceInteractive(); + final boolean keyguardShowing = mKeyguardStateController.isShowing(); + final boolean deviceDreaming = mUpdateMonitor.isDreaming(); + + logCalculateModeForFingerprint(unlockingAllowed, deviceInteractive, + keyguardShowing, deviceDreaming, isStrongBiometric); + if (!deviceInteractive) { + if (!keyguardShowing && !mScreenOffAnimationController.isKeyguardShowDelayed()) { if (mKeyguardStateController.isUnlocked()) { return MODE_WAKE_AND_UNLOCK; } @@ -559,7 +554,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp if (unlockingAllowed && deviceDreaming) { return MODE_WAKE_AND_UNLOCK_FROM_DREAM; } - if (mKeyguardStateController.isShowing()) { + if (keyguardShowing) { if (mKeyguardViewController.primaryBouncerIsOrWillBeShowing() && unlockingAllowed) { return MODE_DISMISS_BOUNCER; } else if (unlockingAllowed) { @@ -571,14 +566,39 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp return MODE_NONE; } + private void logCalculateModeForFingerprint(boolean unlockingAllowed, boolean deviceInteractive, + boolean keyguardShowing, boolean deviceDreaming, boolean strongBiometric) { + if (unlockingAllowed) { + mLogger.logCalculateModeForFingerprintUnlockingAllowed(deviceInteractive, + keyguardShowing, deviceDreaming); + } else { + // if unlocking isn't allowed, log more information about why unlocking may not + // have been allowed + final int strongAuthFlags = mUpdateMonitor.getStrongAuthTracker().getStrongAuthForUser( + KeyguardUpdateMonitor.getCurrentUser()); + final boolean nonStrongBiometricAllowed = + mUpdateMonitor.getStrongAuthTracker() + .isNonStrongBiometricAllowedAfterIdleTimeout( + KeyguardUpdateMonitor.getCurrentUser()); + + mLogger.logCalculateModeForFingerprintUnlockingNotAllowed(strongBiometric, + strongAuthFlags, nonStrongBiometricAllowed, deviceInteractive, keyguardShowing); + } + } + private @WakeAndUnlockMode int calculateModeForPassiveAuth(boolean isStrongBiometric) { - boolean unlockingAllowed = + final boolean deviceInteractive = mUpdateMonitor.isDeviceInteractive(); + final boolean isKeyguardShowing = mKeyguardStateController.isShowing(); + final boolean unlockingAllowed = mUpdateMonitor.isUnlockingWithBiometricAllowed(isStrongBiometric); - boolean deviceDreaming = mUpdateMonitor.isDreaming(); - boolean bypass = mKeyguardBypassController.getBypassEnabled() + final boolean deviceDreaming = mUpdateMonitor.isDreaming(); + final boolean bypass = mKeyguardBypassController.getBypassEnabled() || mAuthController.isUdfpsFingerDown(); - if (!mUpdateMonitor.isDeviceInteractive()) { - if (!mKeyguardStateController.isShowing()) { + + logCalculateModeForPassiveAuth(unlockingAllowed, deviceInteractive, isKeyguardShowing, + deviceDreaming, bypass, isStrongBiometric); + if (!deviceInteractive) { + if (!isKeyguardShowing) { return bypass ? MODE_WAKE_AND_UNLOCK : MODE_ONLY_WAKE; } else if (!unlockingAllowed) { return bypass ? MODE_SHOW_BOUNCER : MODE_NONE; @@ -602,11 +622,11 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp if (unlockingAllowed && mKeyguardStateController.isOccluded()) { return MODE_UNLOCK_COLLAPSING; } - if (mKeyguardStateController.isShowing()) { + if (isKeyguardShowing) { if ((mKeyguardViewController.primaryBouncerIsOrWillBeShowing() || mKeyguardBypassController.getAltBouncerShowing()) && unlockingAllowed) { return MODE_DISMISS_BOUNCER; - } else if (unlockingAllowed && (bypass || mAuthController.isUdfpsFingerDown())) { + } else if (unlockingAllowed && bypass) { return MODE_UNLOCK_COLLAPSING; } else { return bypass ? MODE_SHOW_BOUNCER : MODE_NONE; @@ -615,6 +635,28 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp return MODE_NONE; } + private void logCalculateModeForPassiveAuth(boolean unlockingAllowed, + boolean deviceInteractive, boolean keyguardShowing, boolean deviceDreaming, + boolean bypass, boolean strongBiometric) { + if (unlockingAllowed) { + mLogger.logCalculateModeForPassiveAuthUnlockingAllowed( + deviceInteractive, keyguardShowing, deviceDreaming, bypass); + } else { + // if unlocking isn't allowed, log more information about why unlocking may not + // have been allowed + final int strongAuthFlags = mUpdateMonitor.getStrongAuthTracker().getStrongAuthForUser( + KeyguardUpdateMonitor.getCurrentUser()); + final boolean nonStrongBiometricAllowed = + mUpdateMonitor.getStrongAuthTracker() + .isNonStrongBiometricAllowedAfterIdleTimeout( + KeyguardUpdateMonitor.getCurrentUser()); + + mLogger.logCalculateModeForPassiveAuthUnlockingNotAllowed( + strongBiometric, strongAuthFlags, nonStrongBiometricAllowed, + deviceInteractive, keyguardShowing, bypass); + } + } + @Override public void onBiometricAuthFailed(BiometricSourceType biometricSourceType) { mMetricsLogger.write(new LogMaker(MetricsEvent.BIOMETRIC_AUTH) @@ -632,6 +674,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp if (!mVibratorHelper.hasVibrator() && (!mUpdateMonitor.isDeviceInteractive() || mUpdateMonitor.isDreaming())) { + mLogger.d("wakeup device on authentication failure (device doesn't have a vibrator)"); startWakeAndUnlock(MODE_ONLY_WAKE); } else if (biometricSourceType == BiometricSourceType.FINGERPRINT && mUpdateMonitor.isUdfpsSupported()) { @@ -644,6 +687,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp mLastFpFailureUptimeMillis = currUptimeMillis; if (mNumConsecutiveFpFailures >= UDFPS_ATTEMPTS_BEFORE_SHOW_BOUNCER) { + mLogger.logUdfpsAttemptThresholdMet(mNumConsecutiveFpFailures); startWakeAndUnlock(MODE_SHOW_BOUNCER); UI_EVENT_LOGGER.log(BiometricUiEvent.BIOMETRIC_BOUNCER_SHOWN, getSessionId()); mNumConsecutiveFpFailures = 0; @@ -674,6 +718,7 @@ public class BiometricUnlockController extends KeyguardUpdateMonitorCallback imp && (msgId == FingerprintManager.FINGERPRINT_ERROR_LOCKOUT || msgId == FingerprintManager.FINGERPRINT_ERROR_LOCKOUT_PERMANENT); if (fingerprintLockout) { + mLogger.d("fingerprint locked out"); startWakeAndUnlock(MODE_SHOW_BOUNCER); UI_EVENT_LOGGER.log(BiometricUiEvent.BIOMETRIC_BOUNCER_SHOWN, getSessionId()); } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java index 75a3b21724ef..d1957acb9fd5 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/BiometricsUnlockControllerTest.java @@ -42,6 +42,7 @@ import android.testing.TestableResources; import com.android.internal.logging.MetricsLogger; import com.android.internal.util.LatencyTracker; import com.android.keyguard.KeyguardUpdateMonitor; +import com.android.keyguard.logging.BiometricUnlockLogger; import com.android.systemui.SysuiTestCase; import com.android.systemui.biometrics.AuthController; import com.android.systemui.dump.DumpManager; @@ -78,6 +79,8 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase { @Mock private KeyguardUpdateMonitor mUpdateMonitor; @Mock + private KeyguardUpdateMonitor.StrongAuthTracker mStrongAuthTracker; + @Mock private StatusBarKeyguardViewManager mStatusBarKeyguardViewManager; @Mock private NotificationShadeWindowController mNotificationShadeWindowController; @@ -119,6 +122,8 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase { private ScreenOffAnimationController mScreenOffAnimationController; @Mock private VibratorHelper mVibratorHelper; + @Mock + private BiometricUnlockLogger mLogger; private BiometricUnlockController mBiometricUnlockController; @Before @@ -138,12 +143,13 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase { mKeyguardViewMediator, mScrimController, mShadeController, mNotificationShadeWindowController, mKeyguardStateController, mHandler, mUpdateMonitor, res.getResources(), mKeyguardBypassController, - mMetricsLogger, mDumpManager, mPowerManager, + mMetricsLogger, mDumpManager, mPowerManager, mLogger, mNotificationMediaManager, mWakefulnessLifecycle, mScreenLifecycle, mAuthController, mStatusBarStateController, mKeyguardUnlockAnimationController, mSessionTracker, mLatencyTracker, mScreenOffAnimationController, mVibratorHelper); mBiometricUnlockController.setKeyguardViewController(mStatusBarKeyguardViewManager); mBiometricUnlockController.addBiometricModeListener(mBiometricModeListener); + when(mUpdateMonitor.getStrongAuthTracker()).thenReturn(mStrongAuthTracker); } @Test @@ -285,6 +291,7 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase { @Test public void onBiometricAuthenticated_whenFace_andBypass_encrypted_showPrimaryBouncer() { reset(mUpdateMonitor); + when(mUpdateMonitor.getStrongAuthTracker()).thenReturn(mStrongAuthTracker); when(mKeyguardBypassController.getBypassEnabled()).thenReturn(true); mBiometricUnlockController.setKeyguardViewController(mStatusBarKeyguardViewManager); @@ -322,6 +329,7 @@ public class BiometricsUnlockControllerTest extends SysuiTestCase { @Test public void onBiometricAuthenticated_whenFace_noBypass_encrypted_doNothing() { reset(mUpdateMonitor); + when(mUpdateMonitor.getStrongAuthTracker()).thenReturn(mStrongAuthTracker); mBiometricUnlockController.setKeyguardViewController(mStatusBarKeyguardViewManager); when(mUpdateMonitor.isUnlockingWithBiometricAllowed(anyBoolean())).thenReturn(false); |