Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e00163a2 authored by Chandru S's avatar Chandru S Committed by Android (Google) Code Review
Browse files

Merge "Revert "Move all flows to the background dispatcher"" into main

parents 145259a2 88438887
Loading
Loading
Loading
Loading
+30 −15
Original line number Diff line number Diff line
@@ -187,7 +187,8 @@ constructor(
        faceManager?.sensorPropertiesInternal?.firstOrNull()?.supportsFaceDetection ?: false

    private val _isAuthRunning = MutableStateFlow(false)
    override val isAuthRunning: StateFlow<Boolean> = _isAuthRunning
    override val isAuthRunning: StateFlow<Boolean>
        get() = _isAuthRunning

    private val keyguardSessionId: InstanceId?
        get() = sessionTracker.getSessionId(StatusBarManager.SESSION_KEYGUARD)
@@ -253,13 +254,6 @@ 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
@@ -287,12 +281,9 @@ constructor(
                )
                .andAllFlows("canFaceDetectRun", faceDetectLog)
                .flowOn(backgroundDispatcher)
                .onEach {
                    if (!it) {
                        cancelDetection()
                    }
                }
                .stateIn(applicationScope, SharingStarted.Eagerly, false)
        observeFaceAuthGatingChecks()
        observeFaceDetectGatingChecks()
        observeFaceAuthResettingConditions()
        listenForSchedulingWatchdog()
        processPendingAuthRequests()
@@ -347,6 +338,17 @@ 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
@@ -405,6 +407,20 @@ 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() {
@@ -539,7 +555,7 @@ constructor(
                    authenticate(it.uiEvent, it.fallbackToDetection)
                }
            }
            .flowOn(backgroundDispatcher)
            .flowOn(mainDispatcher)
            .launchIn(applicationScope)
    }

@@ -635,7 +651,6 @@ constructor(
    override fun cancel() {
        if (authCancellationSignal == null) return

        faceAuthLogger.cancellingFaceAuth()
        authCancellationSignal?.cancel()
        cancelNotReceivedHandlerJob?.cancel()
        cancelNotReceivedHandlerJob =
+0 −8
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ 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
@@ -72,7 +71,6 @@ 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,
@@ -109,7 +107,6 @@ constructor(
                    fallbackToDetect = false
                )
            }
            .flowOn(backgroundDispatcher)
            .launchIn(applicationScope)

        alternateBouncerInteractor.isVisible
@@ -121,7 +118,6 @@ constructor(
                    fallbackToDetect = false
                )
            }
            .flowOn(backgroundDispatcher)
            .launchIn(applicationScope)

        merge(
@@ -150,7 +146,6 @@ constructor(
                    fallbackToDetect = true
                )
            }
            .flowOn(backgroundDispatcher)
            .launchIn(applicationScope)

        deviceEntryFingerprintAuthRepository.isLockedOut
@@ -163,7 +158,6 @@ constructor(
                    }
                }
            }
            .flowOn(backgroundDispatcher)
            .launchIn(applicationScope)

        // User switching should stop face auth and then when it is complete we should trigger face
@@ -187,7 +181,6 @@ constructor(
                    )
                }
            }
            .flowOn(backgroundDispatcher)
            .launchIn(applicationScope)
    }

@@ -302,7 +295,6 @@ constructor(
                    trustManager.clearAllBiometricRecognized(BiometricSourceType.FACE, userInfo.id)
                }
            }
            .flowOn(backgroundDispatcher)
            .onEach { (isAuthenticated, _) ->
                listeners.forEach { it.onAuthenticatedChanged(isAuthenticated) }
            }
+0 −1
Original line number Diff line number Diff line
@@ -137,7 +137,6 @@ class KeyguardFaceAuthInteractorTest : SysuiTestCase() {
                mContext,
                testScope.backgroundScope,
                dispatcher,
                dispatcher,
                faceAuthRepository,
                {
                    PrimaryBouncerInteractor(