summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chandru S <chandruis@google.com> 2023-12-01 08:32:18 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-12-01 08:32:18 +0000
commit24b64e6496730fe0e3c36aeb39d10d5798d44eb5 (patch)
treef8833be72f5e566e1106c03e2155135861bde75e
parent97d3a6b19592e54b2629943d285e1efac588972c (diff)
parent3f22a8b97d8a7c2c63acfeb75cb0d8206be77586 (diff)
Merge "Move all flows to the background dispatcher" into main
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/data/repository/DeviceEntryFaceAuthRepository.kt46
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/SystemUIKeyguardFaceAuthInteractor.kt7
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardFaceAuthInteractorTest.kt1
3 files changed, 24 insertions, 30 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 36412e31e7c0..e47c44863980 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
@@ -187,8 +187,7 @@ constructor(
faceManager?.sensorPropertiesInternal?.firstOrNull()?.supportsFaceDetection ?: false
private val _isAuthRunning = MutableStateFlow(false)
- override val isAuthRunning: StateFlow<Boolean>
- get() = _isAuthRunning
+ override val isAuthRunning: StateFlow<Boolean> = _isAuthRunning
private val keyguardSessionId: InstanceId?
get() = sessionTracker.getSessionId(StatusBarManager.SESSION_KEYGUARD)
@@ -254,6 +253,13 @@ constructor(
)
.andAllFlows("canFaceAuthRun", faceAuthLog)
.flowOn(backgroundDispatcher)
+ .onEach {
+ faceAuthLogger.canFaceAuthRunChanged(it)
+ if (!it) {
+ // Cancel currently running auth if any of the gating checks are false.
+ cancel()
+ }
+ }
.stateIn(applicationScope, SharingStarted.Eagerly, false)
// Face detection can run only when lockscreen bypass is enabled
@@ -281,9 +287,12 @@ constructor(
)
.andAllFlows("canFaceDetectRun", faceDetectLog)
.flowOn(backgroundDispatcher)
+ .onEach {
+ if (!it) {
+ cancelDetection()
+ }
+ }
.stateIn(applicationScope, SharingStarted.Eagerly, false)
- observeFaceAuthGatingChecks()
- observeFaceDetectGatingChecks()
observeFaceAuthResettingConditions()
listenForSchedulingWatchdog()
processPendingAuthRequests()
@@ -317,6 +326,7 @@ constructor(
it.selectionStatus == SelectionStatus.SELECTION_IN_PROGRESS
},
)
+ .flowOn(backgroundDispatcher)
.onEach { anyOfThemIsTrue ->
if (anyOfThemIsTrue) {
clearPendingAuthRequest("Resetting auth status")
@@ -337,17 +347,6 @@ constructor(
pendingAuthenticateRequest.value = null
}
- private fun observeFaceDetectGatingChecks() {
- canRunDetection
- .onEach {
- if (!it) {
- cancelDetection()
- }
- }
- .flowOn(mainDispatcher)
- .launchIn(applicationScope)
- }
-
private fun isUdfps() =
deviceEntryFingerprintAuthRepository.availableFpSensorType.map {
it == BiometricType.UNDER_DISPLAY_FINGERPRINT
@@ -406,20 +405,6 @@ constructor(
)
}
- private fun observeFaceAuthGatingChecks() {
- canRunFaceAuth
- .onEach {
- faceAuthLogger.canFaceAuthRunChanged(it)
- if (!it) {
- // Cancel currently running auth if any of the gating checks are false.
- faceAuthLogger.cancellingFaceAuth()
- cancel()
- }
- }
- .flowOn(mainDispatcher)
- .launchIn(applicationScope)
- }
-
private val faceAuthCallback =
object : FaceManager.AuthenticationCallback() {
override fun onAuthenticationFailed() {
@@ -554,7 +539,7 @@ constructor(
authenticate(it.uiEvent, it.fallbackToDetection)
}
}
- .flowOn(mainDispatcher)
+ .flowOn(backgroundDispatcher)
.launchIn(applicationScope)
}
@@ -650,6 +635,7 @@ constructor(
override fun cancel() {
if (authCancellationSignal == null) return
+ faceAuthLogger.cancellingFaceAuth()
authCancellationSignal?.cancel()
cancelNotReceivedHandlerJob?.cancel()
cancelNotReceivedHandlerJob =
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/SystemUIKeyguardFaceAuthInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/SystemUIKeyguardFaceAuthInteractor.kt
index ae356cd94350..532df4afebf7 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/SystemUIKeyguardFaceAuthInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/SystemUIKeyguardFaceAuthInteractor.kt
@@ -29,6 +29,7 @@ import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor
import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerInteractor
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
+import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.keyguard.data.repository.BiometricSettingsRepository
import com.android.systemui.keyguard.data.repository.DeviceEntryFaceAuthRepository
@@ -69,6 +70,7 @@ constructor(
private val context: Context,
@Application private val applicationScope: CoroutineScope,
@Main private val mainDispatcher: CoroutineDispatcher,
+ @Background private val backgroundDispatcher: CoroutineDispatcher,
private val repository: DeviceEntryFaceAuthRepository,
private val primaryBouncerInteractor: Lazy<PrimaryBouncerInteractor>,
private val alternateBouncerInteractor: AlternateBouncerInteractor,
@@ -104,6 +106,7 @@ constructor(
fallbackToDetect = false
)
}
+ .flowOn(backgroundDispatcher)
.launchIn(applicationScope)
alternateBouncerInteractor.isVisible
@@ -115,6 +118,7 @@ constructor(
fallbackToDetect = false
)
}
+ .flowOn(backgroundDispatcher)
.launchIn(applicationScope)
merge(
@@ -143,6 +147,7 @@ constructor(
fallbackToDetect = true
)
}
+ .flowOn(backgroundDispatcher)
.launchIn(applicationScope)
deviceEntryFingerprintAuthRepository.isLockedOut
@@ -155,6 +160,7 @@ constructor(
}
}
}
+ .flowOn(backgroundDispatcher)
.launchIn(applicationScope)
// User switching should stop face auth and then when it is complete we should trigger face
@@ -178,6 +184,7 @@ constructor(
)
}
}
+ .flowOn(backgroundDispatcher)
.launchIn(applicationScope)
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardFaceAuthInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardFaceAuthInteractorTest.kt
index b3e8fed24c3b..de12b8f91d20 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardFaceAuthInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardFaceAuthInteractorTest.kt
@@ -130,6 +130,7 @@ class KeyguardFaceAuthInteractorTest : SysuiTestCase() {
mContext,
testScope.backgroundScope,
dispatcher,
+ dispatcher,
faceAuthRepository,
{
PrimaryBouncerInteractor(