From 12d35805d321cd330966f8250ff564352ff4701e Mon Sep 17 00:00:00 2001 From: Chandru S Date: Fri, 23 Jun 2023 17:32:55 -0700 Subject: [PATCH] Run face detection if bypass is enabled and the user is already trusted. - If the device is already unlocked using smart lock, we should run face detection to auto-dismiss the lock screen. Fixes: 285526875 Test: DeviceEntryFaceAuthRepositoryTest Change-Id: I3dc4eaf6fdf5668fa7c156832b9ab27ce87ef2fc --- .../DeviceEntryFaceAuthRepository.kt | 10 ++++++--- .../DeviceEntryFaceAuthRepositoryTest.kt | 21 +++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) 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 82c5fb1f24e70..3d8f6fd40e6b4 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 @@ -254,13 +254,17 @@ constructor( private fun observeFaceDetectGatingChecks() { // Face detection can run only when lockscreen bypass is enabled - // & detection is supported & biometric unlock is not allowed. + // & detection is supported + // & biometric unlock is not allowed + // or user is trusted by trust manager & we want to run face detect to dismiss keyguard listOf( canFaceAuthOrDetectRun(faceDetectLog), logAndObserve(isBypassEnabled, "isBypassEnabled", faceDetectLog), logAndObserve( - biometricSettingsRepository.isNonStrongBiometricAllowed.isFalse(), - "nonStrongBiometricIsNotAllowed", + biometricSettingsRepository.isNonStrongBiometricAllowed + .isFalse() + .or(trustRepository.isCurrentUserTrusted), + "nonStrongBiometricIsNotAllowedOrCurrentUserIsTrusted", faceDetectLog ), // We don't want to run face detect if fingerprint can be used to unlock the device 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 86684696a88e2..9ca6dce165e03 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 @@ -625,6 +625,27 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() { faceDetectIsCalled() } + @Test + fun authenticateFallbacksToDetectionWhenUserIsAlreadyTrustedByTrustManager() = + testScope.runTest { + whenever(faceManager.sensorPropertiesInternal) + .thenReturn(listOf(createFaceSensorProperties(supportsFaceDetection = true))) + whenever(bypassController.bypassEnabled).thenReturn(true) + underTest = createDeviceEntryFaceAuthRepositoryImpl() + initCollectors() + allPreconditionsToRunFaceAuthAreTrue() + + trustRepository.setCurrentUserTrusted(true) + assertThat(canFaceAuthRun()).isFalse() + underTest.authenticate( + FACE_AUTH_TRIGGERED_SWIPE_UP_ON_BOUNCER, + fallbackToDetection = true + ) + faceAuthenticateIsNotCalled() + + faceDetectIsCalled() + } + @Test fun everythingWorksWithFaceAuthRefactorFlagDisabled() = testScope.runTest {