Merge "Minor face auth fixes" into udc-dev

This commit is contained in:
Chandru S
2023-04-18 16:24:03 +00:00
committed by Android (Google) Code Review
7 changed files with 92 additions and 9 deletions

View File

@@ -178,6 +178,7 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
@Override
public void onUserInput() {
mKeyguardFaceAuthInteractor.onPrimaryBouncerUserInput();
mUpdateMonitor.cancelFaceAuth();
}

View File

@@ -225,10 +225,17 @@ constructor(
}
private fun observeFaceAuthResettingConditions() {
// Clear auth status when keyguard is going away or when the user is switching.
merge(keyguardRepository.isKeyguardGoingAway, userRepository.userSwitchingInProgress)
.onEach { goingAwayOrUserSwitchingInProgress ->
if (goingAwayOrUserSwitchingInProgress) {
// Clear auth status when keyguard is going away or when the user is switching or device
// starts going to sleep.
merge(
keyguardRepository.wakefulness.map {
WakefulnessModel.isSleepingOrStartingToSleep(it)
},
keyguardRepository.isKeyguardGoingAway,
userRepository.userSwitchingInProgress
)
.onEach { anyOfThemIsTrue ->
if (anyOfThemIsTrue) {
_isAuthenticated.value = false
retryCount = 0
halErrorRetryJob?.cancel()
@@ -248,8 +255,8 @@ constructor(
"nonStrongBiometricIsNotAllowed",
faceDetectLog
),
// We don't want to run face detect if it's not possible to authenticate with FP
// from the bouncer. UDFPS is the only fp sensor type that won't support this.
// We don't want to run face detect if fingerprint can be used to unlock the device
// but it's not possible to authenticate with FP from the bouncer (UDFPS)
logAndObserve(
and(isUdfps(), deviceEntryFingerprintAuthRepository.isRunning).isFalse(),
"udfpsAuthIsNotPossibleAnymore",
@@ -306,7 +313,7 @@ constructor(
logAndObserve(
combine(
keyguardInteractor.isSecureCameraActive,
alternateBouncerInteractor.isVisible,
alternateBouncerInteractor.isVisible
) { a, b ->
!a || b
},
@@ -334,12 +341,12 @@ constructor(
logAndObserve(isLockedOut.isFalse(), "isNotInLockOutState", faceAuthLog),
logAndObserve(
deviceEntryFingerprintAuthRepository.isLockedOut.isFalse(),
"fpLockedOut",
"fpIsNotLockedOut",
faceAuthLog
),
logAndObserve(
trustRepository.isCurrentUserTrusted.isFalse(),
"currentUserTrusted",
"currentUserIsNotTrusted",
faceAuthLog
),
logAndObserve(

View File

@@ -59,6 +59,7 @@ interface KeyguardFaceAuthInteractor {
fun onQsExpansionStared()
fun onNotificationPanelClicked()
fun onSwipeUpOnBouncer()
fun onPrimaryBouncerUserInput()
}
/**

View File

@@ -59,4 +59,5 @@ class NoopKeyguardFaceAuthInteractor @Inject constructor() : KeyguardFaceAuthInt
override fun onNotificationPanelClicked() {}
override fun onSwipeUpOnBouncer() {}
override fun onPrimaryBouncerUserInput() {}
}

View File

@@ -151,6 +151,10 @@ constructor(
return featureFlags.isEnabled(Flags.FACE_AUTH_REFACTOR)
}
override fun onPrimaryBouncerUserInput() {
repository.cancel()
}
/** Provide the status of face authentication */
override val authenticationStatus = repository.authenticationStatus

View File

@@ -643,6 +643,58 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
assertThat(authenticated()).isFalse()
}
@Test
fun isAuthenticatedIsResetToFalseWhenDeviceStartsGoingToSleep() =
testScope.runTest {
initCollectors()
allPreconditionsToRunFaceAuthAreTrue()
triggerFaceAuth(false)
authenticationCallback.value.onAuthenticationSucceeded(
mock(FaceManager.AuthenticationResult::class.java)
)
assertThat(authenticated()).isTrue()
keyguardRepository.setWakefulnessModel(
WakefulnessModel(
WakefulnessState.STARTING_TO_SLEEP,
isWakingUpOrAwake = false,
lastWakeReason = WakeSleepReason.POWER_BUTTON,
lastSleepReason = WakeSleepReason.POWER_BUTTON
)
)
assertThat(authenticated()).isFalse()
}
@Test
fun isAuthenticatedIsResetToFalseWhenDeviceGoesToSleep() =
testScope.runTest {
initCollectors()
allPreconditionsToRunFaceAuthAreTrue()
triggerFaceAuth(false)
authenticationCallback.value.onAuthenticationSucceeded(
mock(FaceManager.AuthenticationResult::class.java)
)
assertThat(authenticated()).isTrue()
keyguardRepository.setWakefulnessModel(
WakefulnessModel(
WakefulnessState.ASLEEP,
isWakingUpOrAwake = false,
lastWakeReason = WakeSleepReason.POWER_BUTTON,
lastSleepReason = WakeSleepReason.POWER_BUTTON
)
)
assertThat(authenticated()).isFalse()
}
@Test
fun isAuthenticatedIsResetToFalseWhenUserIsSwitching() =
testScope.runTest {

View File

@@ -278,6 +278,23 @@ class KeyguardFaceAuthInteractorTest : SysuiTestCase() {
)
}
@Test
fun faceAuthIsCancelledWhenUserInputOnPrimaryBouncer() =
testScope.runTest {
underTest.start()
underTest.onSwipeUpOnBouncer()
runCurrent()
assertThat(faceAuthRepository.isAuthRunning.value).isTrue()
underTest.onPrimaryBouncerUserInput()
runCurrent()
assertThat(faceAuthRepository.isAuthRunning.value).isFalse()
}
@Test
fun faceAuthIsRequestedWhenSwipeUpOnBouncer() =
testScope.runTest {