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

Commit f400080a authored by Chandru S's avatar Chandru S Committed by Automerger Merge Worker
Browse files

Merge "Launch coroutines in the repository only if the refactor flag is...

Merge "Launch coroutines in the repository only if the refactor flag is enabled" into udc-dev am: 756f4231

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



Change-Id: I27cf097570c807fe0b09f93b61d1c64f9fce3882
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 1de837fd 756f4231
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -4379,9 +4379,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
     */
    public void startBiometricWatchdog() {
        if (mFaceManager != null && !isFaceAuthInteractorEnabled()) {
            mLogger.scheduleWatchdog("face");
            mFaceManager.scheduleWatchdog();
        }
        if (mFpm != null) {
            mLogger.scheduleWatchdog("fingerprint");
            mFpm.scheduleWatchdog();
        }
    }
+27 −18
Original line number Diff line number Diff line
@@ -67,8 +67,10 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
            "ActiveUnlock",
            DEBUG,
            { int1 = wakeReason },
            { "Skip requesting active unlock from wake reason that doesn't trigger face auth" +
                    " reason=${PowerManager.wakeReasonToString(int1)}" }
            {
                "Skip requesting active unlock from wake reason that doesn't trigger face auth" +
                    " reason=${PowerManager.wakeReasonToString(int1)}"
            }
        )
    }

@@ -207,17 +209,27 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
    }

    fun logFaceDetected(userId: Int, isStrongBiometric: Boolean) {
        logBuffer.log(TAG, DEBUG, {
        logBuffer.log(
            TAG,
            DEBUG,
            {
                int1 = userId
                bool1 = isStrongBiometric
        }, {"Face detected: userId: $int1, isStrongBiometric: $bool1"})
            },
            { "Face detected: userId: $int1, isStrongBiometric: $bool1" }
        )
    }

    fun logFingerprintDetected(userId: Int, isStrongBiometric: Boolean) {
        logBuffer.log(TAG, DEBUG, {
        logBuffer.log(
            TAG,
            DEBUG,
            {
                int1 = userId
                bool1 = isStrongBiometric
        }, {"Fingerprint detected: userId: $int1, isStrongBiometric: $bool1"})
            },
            { "Fingerprint detected: userId: $int1, isStrongBiometric: $bool1" }
        )
    }

    fun logFingerprintError(msgId: Int, originalErrMsg: String) {
@@ -669,13 +681,10 @@ constructor(@KeyguardUpdateMonitorLog private val logBuffer: LogBuffer) {
    }

    fun logHandleBatteryUpdate(isInteresting: Boolean) {
        logBuffer.log(
            TAG,
            DEBUG,
            {
                bool1 = isInteresting
            },
            { "handleBatteryUpdate: $bool1" }
        )
        logBuffer.log(TAG, DEBUG, { bool1 = isInteresting }, { "handleBatteryUpdate: $bool1" })
    }

    fun scheduleWatchdog(@CompileTimeConstant watchdogType: String) {
        logBuffer.log(TAG, DEBUG, "Scheduling biometric watchdog for $watchdogType")
    }
}
+16 −5
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@ import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.dump.DumpManager
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
import com.android.systemui.keyguard.domain.interactor.AlternateBouncerInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
@@ -42,6 +44,7 @@ import com.android.systemui.keyguard.shared.model.ErrorAuthenticationStatus
import com.android.systemui.keyguard.shared.model.FailedAuthenticationStatus
import com.android.systemui.keyguard.shared.model.HelpAuthenticationStatus
import com.android.systemui.keyguard.shared.model.SuccessAuthenticationStatus
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.keyguard.shared.model.WakefulnessModel
import com.android.systemui.log.FaceAuthenticationLogger
import com.android.systemui.log.SessionTracker
@@ -63,6 +66,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.launchIn
@@ -135,6 +139,7 @@ constructor(
    @FaceDetectTableLog private val faceDetectLog: TableLogBuffer,
    @FaceAuthTableLog private val faceAuthLog: TableLogBuffer,
    private val keyguardTransitionInteractor: KeyguardTransitionInteractor,
    private val featureFlags: FeatureFlags,
    dumpManager: DumpManager,
) : DeviceEntryFaceAuthRepository, Dumpable {
    private var authCancellationSignal: CancellationSignal? = null
@@ -212,15 +217,21 @@ constructor(
                .collect(Collectors.toSet())
        dumpManager.registerCriticalDumpable("DeviceEntryFaceAuthRepositoryImpl", this)

        if (featureFlags.isEnabled(Flags.FACE_AUTH_REFACTOR)) {
            observeFaceAuthGatingChecks()
            observeFaceDetectGatingChecks()
            observeFaceAuthResettingConditions()
            listenForSchedulingWatchdog()
        }
    }

    private fun listenForSchedulingWatchdog() {
        keyguardTransitionInteractor.anyStateToGoneTransition
            .onEach { faceManager?.scheduleWatchdog() }
            .filter { it.transitionState == TransitionState.FINISHED }
            .onEach {
                faceAuthLogger.watchdogScheduled()
                faceManager?.scheduleWatchdog()
            }
            .launchIn(applicationScope)
    }

+4 −0
Original line number Diff line number Diff line
@@ -261,4 +261,8 @@ constructor(
            { "Attempting face auth again because of HW error: retry attempt $int1" }
        )
    }

    fun watchdogScheduled() {
        logBuffer.log(TAG, DEBUG, "FaceManager Biometric watchdog scheduled.")
    }
}
+23 −4
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import com.android.systemui.keyguard.shared.model.ErrorAuthenticationStatus
import com.android.systemui.keyguard.shared.model.HelpAuthenticationStatus
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.keyguard.shared.model.SuccessAuthenticationStatus
import com.android.systemui.keyguard.shared.model.TransitionState
import com.android.systemui.keyguard.shared.model.TransitionStep
import com.android.systemui.keyguard.shared.model.WakeSleepReason
import com.android.systemui.keyguard.shared.model.WakefulnessModel
@@ -234,6 +235,7 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
            faceDetectBuffer,
            faceAuthBuffer,
            keyguardTransitionInteractor,
            featureFlags,
            dumpManager,
        )
    }
@@ -612,6 +614,7 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
            authStatus()
            detectStatus()
            authRunning()
            bypassEnabled()
            lockedOut()
            canFaceAuthRun()
            authenticated()
@@ -847,7 +850,11 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
    fun schedulesFaceManagerWatchdogWhenKeyguardIsGoneFromDozing() =
        testScope.runTest {
            keyguardTransitionRepository.sendTransitionStep(
                TransitionStep(from = KeyguardState.DOZING, to = KeyguardState.GONE)
                TransitionStep(
                    from = KeyguardState.DOZING,
                    to = KeyguardState.GONE,
                    transitionState = TransitionState.FINISHED
                )
            )

            runCurrent()
@@ -858,7 +865,11 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
    fun schedulesFaceManagerWatchdogWhenKeyguardIsGoneFromAod() =
        testScope.runTest {
            keyguardTransitionRepository.sendTransitionStep(
                TransitionStep(from = KeyguardState.AOD, to = KeyguardState.GONE)
                TransitionStep(
                    from = KeyguardState.AOD,
                    to = KeyguardState.GONE,
                    transitionState = TransitionState.FINISHED
                )
            )

            runCurrent()
@@ -869,7 +880,11 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
    fun schedulesFaceManagerWatchdogWhenKeyguardIsGoneFromLockscreen() =
        testScope.runTest {
            keyguardTransitionRepository.sendTransitionStep(
                TransitionStep(from = KeyguardState.LOCKSCREEN, to = KeyguardState.GONE)
                TransitionStep(
                    from = KeyguardState.LOCKSCREEN,
                    to = KeyguardState.GONE,
                    transitionState = TransitionState.FINISHED
                )
            )

            runCurrent()
@@ -880,7 +895,11 @@ class DeviceEntryFaceAuthRepositoryTest : SysuiTestCase() {
    fun schedulesFaceManagerWatchdogWhenKeyguardIsGoneFromBouncer() =
        testScope.runTest {
            keyguardTransitionRepository.sendTransitionStep(
                TransitionStep(from = KeyguardState.PRIMARY_BOUNCER, to = KeyguardState.GONE)
                TransitionStep(
                    from = KeyguardState.PRIMARY_BOUNCER,
                    to = KeyguardState.GONE,
                    transitionState = TransitionState.FINISHED
                )
            )

            runCurrent()