summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Shawn Lin <shawnlin@google.com> 2024-04-23 02:05:39 +0000
committer Shawn Lin <shawnlin@google.com> 2024-04-30 02:12:37 +0000
commitb51b01417bbfa251036fbf01577246e2a9f7f4ad (patch)
tree9c8b75406f2a78a641cc6103afd59071cf812963
parent0e2a08779ffc1808b5e2c7c3df4e6061d76d5540 (diff)
Fix the ring animation not showing while unfolding device
Starting state: Device is unfolded so SysUI runs face aythentication for request #1 1. The camera changes shortly afterwards, so SystemUIDeviceEntryFaceAuthInteractor calls repository.cancel()(cancel request #1) and then runFaceAuth()(request #2) when the camera changes in order to restart face auth with new camera.(Refer to runFaceAuth with uiEvent:FACE_AUTH_CAMERA_AVAILABLE_CHANGED) 2. On repository.cancel (request #1) cancellationInProgress becomes true. 3. On runFaceAuth, a pending face auth request (request #2) is queued(and won't run until cancellationInProgress becomes false, see processPendingAuthRequests()) 4. SysUI receives the callback from FingerprintManager indicating that request #1's lifecycle is done. In the onFaceAuthRequestCompleted method, cancellationInProgress is set to false which immediately allows face auth request #2 to start running. The bug here is that if within onFaceAuthRequestCompleted: cancellationInProgress is set to false before isAuthRunning is set to false, so we end up in wrong isAuthRunning state(false instead of true). Therefore, cancellationInProgress should be updated AFTER isAuthRunning. Bug: 331306919 Test: atest DeviceEntryFaceAuthRepositoryTest Flag: NONE Change-Id: Idcb9495790cf8f8bcf5528c337bfd5ecfa915c29 (cherry picked from commit 2f2a52eb77434c477fb4a9805c2e910c0264e487)
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/deviceentry/data/repository/DeviceEntryFaceAuthRepositoryTest.kt19
-rw-r--r--packages/SystemUI/src/com/android/systemui/deviceentry/data/repository/DeviceEntryFaceAuthRepository.kt5
2 files changed, 23 insertions, 1 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/deviceentry/data/repository/DeviceEntryFaceAuthRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/deviceentry/data/repository/DeviceEntryFaceAuthRepositoryTest.kt
index 44e312d20142..ddde6815a7d4 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/deviceentry/data/repository/DeviceEntryFaceAuthRepositoryTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/deviceentry/data/repository/DeviceEntryFaceAuthRepositoryTest.kt
@@ -1070,6 +1070,25 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
faceAuthenticateIsCalled()
}
+ @Test
+ fun retryFaceAuthAfterCancel() =
+ testScope.runTest {
+ initCollectors()
+ allPreconditionsToRunFaceAuthAreTrue()
+ val isAuthRunning by collectLastValue(underTest.isAuthRunning)
+
+ underTest.requestAuthenticate(FaceAuthUiEvent.FACE_AUTH_CAMERA_AVAILABLE_CHANGED)
+ underTest.cancel()
+ clearInvocations(faceManager)
+ underTest.requestAuthenticate(FaceAuthUiEvent.FACE_AUTH_CAMERA_AVAILABLE_CHANGED)
+
+ advanceTimeBy(DeviceEntryFaceAuthRepositoryImpl.DEFAULT_CANCEL_SIGNAL_TIMEOUT)
+ runCurrent()
+
+ assertThat(isAuthRunning).isEqualTo(true)
+ faceAuthenticateIsCalled()
+ }
+
private suspend fun TestScope.testGatingCheckForFaceAuth(
gatingCheckModifier: suspend () -> Unit
) {
diff --git a/packages/SystemUI/src/com/android/systemui/deviceentry/data/repository/DeviceEntryFaceAuthRepository.kt b/packages/SystemUI/src/com/android/systemui/deviceentry/data/repository/DeviceEntryFaceAuthRepository.kt
index 8a25e4106751..52027db893b5 100644
--- a/packages/SystemUI/src/com/android/systemui/deviceentry/data/repository/DeviceEntryFaceAuthRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/deviceentry/data/repository/DeviceEntryFaceAuthRepository.kt
@@ -517,9 +517,12 @@ constructor(
private fun onFaceAuthRequestCompleted() {
cancelNotReceivedHandlerJob?.cancel()
- cancellationInProgress.value = false
_isAuthRunning.value = false
authCancellationSignal = null
+ // Updates to "cancellationInProgress" may re-trigger face auth
+ // (see processPendingAuthRequests()), so we must update this after setting _isAuthRunning
+ // to false.
+ cancellationInProgress.value = false
}
private val detectionCallback =