Run face detection if bypass is enabled and the user is already trusted. am: 12d35805d3

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23782496

Change-Id: I8cf63cf44970036b7b5a4290cef71b3f3bf9e6eb
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Chandru S
2023-06-27 08:37:36 +00:00
committed by Automerger Merge Worker
2 changed files with 28 additions and 3 deletions

View File

@@ -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

View File

@@ -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 {