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
This commit is contained in:
Chandru S
2023-06-23 17:32:55 -07:00
parent 15d98dc306
commit 12d35805d3
2 changed files with 28 additions and 3 deletions

View File

@@ -254,13 +254,17 @@ constructor(
private fun observeFaceDetectGatingChecks() { private fun observeFaceDetectGatingChecks() {
// Face detection can run only when lockscreen bypass is enabled // 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( listOf(
canFaceAuthOrDetectRun(faceDetectLog), canFaceAuthOrDetectRun(faceDetectLog),
logAndObserve(isBypassEnabled, "isBypassEnabled", faceDetectLog), logAndObserve(isBypassEnabled, "isBypassEnabled", faceDetectLog),
logAndObserve( logAndObserve(
biometricSettingsRepository.isNonStrongBiometricAllowed.isFalse(), biometricSettingsRepository.isNonStrongBiometricAllowed
"nonStrongBiometricIsNotAllowed", .isFalse()
.or(trustRepository.isCurrentUserTrusted),
"nonStrongBiometricIsNotAllowedOrCurrentUserIsTrusted",
faceDetectLog faceDetectLog
), ),
// We don't want to run face detect if fingerprint can be used to unlock the device // We don't want to run face detect if fingerprint can be used to unlock the device

View File

@@ -625,6 +625,27 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
faceDetectIsCalled() 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 @Test
fun everythingWorksWithFaceAuthRefactorFlagDisabled() = fun everythingWorksWithFaceAuthRefactorFlagDisabled() =
testScope.runTest { testScope.runTest {