diff options
| author | 2023-06-23 17:32:55 -0700 | |
|---|---|---|
| committer | 2023-06-27 13:38:47 +0530 | |
| commit | 12d35805d321cd330966f8250ff564352ff4701e (patch) | |
| tree | 4caa202bd4ad3f180697fa6b545c8ab36f0f1fac | |
| parent | 15d98dc30608fbde77b93dd86151802e5eb5e82f (diff) | |
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
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 82c5fb1f24e7..3d8f6fd40e6b 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 86684696a88e..9ca6dce165e0 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 @@ -626,6 +626,27 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() { } @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 { featureFlags.set(FACE_AUTH_REFACTOR, false) |