diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java index 9573913e5e2f3..1c321ef3508d0 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java @@ -4379,9 +4379,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab */ public void startBiometricWatchdog() { if (mFaceManager != null && !isFaceAuthInteractorEnabled()) { + mLogger.scheduleWatchdog("face"); mFaceManager.scheduleWatchdog(); } if (mFpm != null) { + mLogger.scheduleWatchdog("fingerprint"); mFpm.scheduleWatchdog(); } } diff --git a/packages/SystemUI/src/com/android/keyguard/logging/KeyguardUpdateMonitorLogger.kt b/packages/SystemUI/src/com/android/keyguard/logging/KeyguardUpdateMonitorLogger.kt index 16618064f249e..4974f797d59ad 100644 --- a/packages/SystemUI/src/com/android/keyguard/logging/KeyguardUpdateMonitorLogger.kt +++ b/packages/SystemUI/src/com/android/keyguard/logging/KeyguardUpdateMonitorLogger.kt @@ -67,8 +67,10 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) { "ActiveUnlock", DEBUG, { int1 = wakeReason }, - { "Skip requesting active unlock from wake reason that doesn't trigger face auth" + - " reason=${PowerManager.wakeReasonToString(int1)}" } + { + "Skip requesting active unlock from wake reason that doesn't trigger face auth" + + " reason=${PowerManager.wakeReasonToString(int1)}" + } ) } @@ -207,17 +209,27 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) { } fun logFaceDetected(userId: Int, isStrongBiometric: Boolean) { - logBuffer.log(TAG, DEBUG, { - int1 = userId - bool1 = isStrongBiometric - }, {"Face detected: userId: $int1, isStrongBiometric: $bool1"}) + logBuffer.log( + TAG, + DEBUG, + { + int1 = userId + bool1 = isStrongBiometric + }, + { "Face detected: userId: $int1, isStrongBiometric: $bool1" } + ) } fun logFingerprintDetected(userId: Int, isStrongBiometric: Boolean) { - logBuffer.log(TAG, DEBUG, { - int1 = userId - bool1 = isStrongBiometric - }, {"Fingerprint detected: userId: $int1, isStrongBiometric: $bool1"}) + logBuffer.log( + TAG, + DEBUG, + { + int1 = userId + bool1 = isStrongBiometric + }, + { "Fingerprint detected: userId: $int1, isStrongBiometric: $bool1" } + ) } fun logFingerprintError(msgId: Int, originalErrMsg: String) { @@ -669,13 +681,10 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) { } fun logHandleBatteryUpdate(isInteresting: Boolean) { - logBuffer.log( - TAG, - DEBUG, - { - bool1 = isInteresting - }, - { "handleBatteryUpdate: $bool1" } - ) + logBuffer.log(TAG, DEBUG, { bool1 = isInteresting }, { "handleBatteryUpdate: $bool1" }) + } + + fun scheduleWatchdog(@CompileTimeConstant watchdogType: String) { + logBuffer.log(TAG, DEBUG, "Scheduling biometric watchdog for $watchdogType") } } diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepository.kt b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepository.kt index 5f2178df43463..5b71a2ed19915 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepository.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepository.kt @@ -32,6 +32,8 @@ import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Application import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.dump.DumpManager +import com.android.systemui.flags.FeatureFlags +import com.android.systemui.flags.Flags import com.android.systemui.keyguard.domain.interactor.AlternateBouncerInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor @@ -42,6 +44,7 @@ import com.android.systemui.keyguard.shared.model.ErrorAuthenticationStatus import com.android.systemui.keyguard.shared.model.FailedAuthenticationStatus import com.android.systemui.keyguard.shared.model.HelpAuthenticationStatus import com.android.systemui.keyguard.shared.model.SuccessAuthenticationStatus +import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.keyguard.shared.model.WakefulnessModel import com.android.systemui.log.FaceAuthenticationLogger import com.android.systemui.log.SessionTracker @@ -63,6 +66,7 @@ import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged +import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.filterNotNull import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.flow.launchIn @@ -135,6 +139,7 @@ constructor( @FaceDetectTableLog private val faceDetectLog: TableLogBuffer, @FaceAuthTableLog private val faceAuthLog: TableLogBuffer, private val keyguardTransitionInteractor: KeyguardTransitionInteractor, + private val featureFlags: FeatureFlags, dumpManager: DumpManager, ) : DeviceEntryFaceAuthRepository, Dumpable { private var authCancellationSignal: CancellationSignal? = null @@ -212,15 +217,21 @@ constructor( .collect(Collectors.toSet()) dumpManager.registerCriticalDumpable("DeviceEntryFaceAuthRepositoryImpl", this) - observeFaceAuthGatingChecks() - observeFaceDetectGatingChecks() - observeFaceAuthResettingConditions() - listenForSchedulingWatchdog() + if (featureFlags.isEnabled(Flags.FACE_AUTH_REFACTOR)) { + observeFaceAuthGatingChecks() + observeFaceDetectGatingChecks() + observeFaceAuthResettingConditions() + listenForSchedulingWatchdog() + } } private fun listenForSchedulingWatchdog() { keyguardTransitionInteractor.anyStateToGoneTransition - .onEach { faceManager?.scheduleWatchdog() } + .filter { it.transitionState == TransitionState.FINISHED } + .onEach { + faceAuthLogger.watchdogScheduled() + faceManager?.scheduleWatchdog() + } .launchIn(applicationScope) } diff --git a/packages/SystemUI/src/com/android/systemui/log/FaceAuthenticationLogger.kt b/packages/SystemUI/src/com/android/systemui/log/FaceAuthenticationLogger.kt index efd3ad620de01..8e9328117e382 100644 --- a/packages/SystemUI/src/com/android/systemui/log/FaceAuthenticationLogger.kt +++ b/packages/SystemUI/src/com/android/systemui/log/FaceAuthenticationLogger.kt @@ -261,4 +261,8 @@ constructor( { "Attempting face auth again because of HW error: retry attempt $int1" } ) } + + fun watchdogScheduled() { + logBuffer.log(TAG, DEBUG, "FaceManager Biometric watchdog scheduled.") + } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepositoryTest.kt index 1d0b58a8e0f44..d73c2c76272e4 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepositoryTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepositoryTest.kt @@ -54,6 +54,7 @@ import com.android.systemui.keyguard.shared.model.ErrorAuthenticationStatus import com.android.systemui.keyguard.shared.model.HelpAuthenticationStatus import com.android.systemui.keyguard.shared.model.KeyguardState import com.android.systemui.keyguard.shared.model.SuccessAuthenticationStatus +import com.android.systemui.keyguard.shared.model.TransitionState import com.android.systemui.keyguard.shared.model.TransitionStep import com.android.systemui.keyguard.shared.model.WakeSleepReason import com.android.systemui.keyguard.shared.model.WakefulnessModel @@ -234,6 +235,7 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() { faceDetectBuffer, faceAuthBuffer, keyguardTransitionInteractor, + featureFlags, dumpManager, ) } @@ -612,6 +614,7 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() { authStatus() detectStatus() authRunning() + bypassEnabled() lockedOut() canFaceAuthRun() authenticated() @@ -847,7 +850,11 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() { fun schedulesFaceManagerWatchdogWhenKeyguardIsGoneFromDozing() = testScope.runTest { keyguardTransitionRepository.sendTransitionStep( - TransitionStep(from = KeyguardState.DOZING, to = KeyguardState.GONE) + TransitionStep( + from = KeyguardState.DOZING, + to = KeyguardState.GONE, + transitionState = TransitionState.FINISHED + ) ) runCurrent() @@ -858,7 +865,11 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() { fun schedulesFaceManagerWatchdogWhenKeyguardIsGoneFromAod() = testScope.runTest { keyguardTransitionRepository.sendTransitionStep( - TransitionStep(from = KeyguardState.AOD, to = KeyguardState.GONE) + TransitionStep( + from = KeyguardState.AOD, + to = KeyguardState.GONE, + transitionState = TransitionState.FINISHED + ) ) runCurrent() @@ -869,7 +880,11 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() { fun schedulesFaceManagerWatchdogWhenKeyguardIsGoneFromLockscreen() = testScope.runTest { keyguardTransitionRepository.sendTransitionStep( - TransitionStep(from = KeyguardState.LOCKSCREEN, to = KeyguardState.GONE) + TransitionStep( + from = KeyguardState.LOCKSCREEN, + to = KeyguardState.GONE, + transitionState = TransitionState.FINISHED + ) ) runCurrent() @@ -880,7 +895,11 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() { fun schedulesFaceManagerWatchdogWhenKeyguardIsGoneFromBouncer() = testScope.runTest { keyguardTransitionRepository.sendTransitionStep( - TransitionStep(from = KeyguardState.PRIMARY_BOUNCER, to = KeyguardState.GONE) + TransitionStep( + from = KeyguardState.PRIMARY_BOUNCER, + to = KeyguardState.GONE, + transitionState = TransitionState.FINISHED + ) ) runCurrent()