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

Commit a381768b authored by Chandru S's avatar Chandru S
Browse files

Minor cleanup: move logic that locks face whenever fingerprint is locked to the interactor

1. This is domain logic that belongs in the face auth interactor
2. When fingerprint state is moved out of KeyguardUpdateMonitor, fingperint interactor would depend on DeviceFaceAuthRepository.isLockedOut if face is class3

Bug: 275788040
Test: atest KeyguardFaceAuthInteractorTest
Test: atest DeviceEntryFaceAuthRepositoryTest
Change-Id: Iede9a41d0ee11fd0f419276efa992b05cba6d3ab
parent eae7134d
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -102,6 +102,9 @@ interface DeviceEntryFaceAuthRepository {
    /** Whether bypass is currently enabled */
    val isBypassEnabled: Flow<Boolean>

    /** Set whether face authentication should be locked out or not */
    fun lockoutFaceAuth()

    /**
     * Trigger face authentication.
     *
@@ -199,6 +202,10 @@ constructor(
        }
            ?: flowOf(false)

    override fun lockoutFaceAuth() {
        _isLockedOut.value = true
    }

    private val faceLockoutResetCallback =
        object : FaceManager.LockoutResetCallback() {
            override fun onLockoutReset(sensorId: Int) {
@@ -396,7 +403,7 @@ constructor(
    private val faceAuthCallback =
        object : FaceManager.AuthenticationCallback() {
            override fun onAuthenticationFailed() {
                _authenticationStatus.value = FailedFaceAuthenticationStatus
                _authenticationStatus.value = FailedFaceAuthenticationStatus()
                _isAuthenticated.value = false
                faceAuthLogger.authenticationFailed()
                onFaceAuthRequestCompleted()
+2 −0
Original line number Diff line number Diff line
@@ -55,6 +55,8 @@ class NoopDeviceEntryFaceAuthRepository @Inject constructor() : DeviceEntryFaceA
    override val isBypassEnabled: Flow<Boolean>
        get() = emptyFlow()

    override fun lockoutFaceAuth() = Unit

    /**
     * Trigger face authentication.
     *
+11 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags
import com.android.systemui.keyguard.data.repository.DeviceEntryFaceAuthRepository
import com.android.systemui.keyguard.data.repository.DeviceEntryFingerprintAuthRepository
import com.android.systemui.keyguard.shared.model.ErrorFaceAuthenticationStatus
import com.android.systemui.keyguard.shared.model.FaceAuthenticationStatus
import com.android.systemui.keyguard.shared.model.TransitionState
@@ -67,6 +68,7 @@ constructor(
    private val featureFlags: FeatureFlags,
    private val faceAuthenticationLogger: FaceAuthenticationLogger,
    private val keyguardUpdateMonitor: KeyguardUpdateMonitor,
    private val deviceEntryFingerprintAuthRepository: DeviceEntryFingerprintAuthRepository,
) : CoreStartable, KeyguardFaceAuthInteractor {

    private val listeners: MutableList<FaceAuthenticationListener> = mutableListOf()
@@ -117,6 +119,15 @@ constructor(
                )
            }
            .launchIn(applicationScope)

        deviceEntryFingerprintAuthRepository.isLockedOut
            .onEach {
                if (it) {
                    faceAuthenticationLogger.faceLockedOut("Fingerprint locked out")
                    repository.lockoutFaceAuth()
                }
            }
            .launchIn(applicationScope)
    }

    override fun onSwipeUpOnBouncer() {
+22 −11
Original line number Diff line number Diff line
@@ -23,29 +23,40 @@ import android.os.SystemClock.elapsedRealtime
 * Authentication status provided by
 * [com.android.systemui.keyguard.data.repository.DeviceEntryFaceAuthRepository]
 */
sealed class FaceAuthenticationStatus(
    // present to break equality check if the same error occurs repeatedly.
    val createdAt: Long = elapsedRealtime()
)
sealed class FaceAuthenticationStatus

/** Success authentication status. */
data class SuccessFaceAuthenticationStatus(val successResult: FaceManager.AuthenticationResult) :
    FaceAuthenticationStatus()
data class SuccessFaceAuthenticationStatus(
    val successResult: FaceManager.AuthenticationResult,
    // present to break equality check if the same error occurs repeatedly.
    @JvmField val createdAt: Long = elapsedRealtime()
) : FaceAuthenticationStatus()

/** Face authentication help message. */
data class HelpFaceAuthenticationStatus(val msgId: Int, val msg: String?) :
    FaceAuthenticationStatus()
data class HelpFaceAuthenticationStatus(
    val msgId: Int,
    val msg: String?, // present to break equality check if the same error occurs repeatedly.
    @JvmField val createdAt: Long = elapsedRealtime()
) : FaceAuthenticationStatus()

/** Face acquired message. */
data class AcquiredFaceAuthenticationStatus(val acquiredInfo: Int) : FaceAuthenticationStatus()
data class AcquiredFaceAuthenticationStatus(
    val acquiredInfo: Int, // present to break equality check if the same error occurs repeatedly.
    @JvmField val createdAt: Long = elapsedRealtime()
) : FaceAuthenticationStatus()

/** Face authentication failed message. */
object FailedFaceAuthenticationStatus : FaceAuthenticationStatus()
data class FailedFaceAuthenticationStatus(
    // present to break equality check if the same error occurs repeatedly.
    @JvmField val createdAt: Long = elapsedRealtime()
) : FaceAuthenticationStatus()

/** Face authentication error message */
data class ErrorFaceAuthenticationStatus(
    val msgId: Int,
    val msg: String? = null,
    // present to break equality check if the same error occurs repeatedly.
    @JvmField val createdAt: Long = elapsedRealtime()
) : FaceAuthenticationStatus() {
    /**
     * Method that checks if [msgId] is a lockout error. A lockout error means that face
@@ -80,5 +91,5 @@ data class FaceDetectionStatus(
    val userId: Int,
    val isStrongBiometric: Boolean,
    // present to break equality check if the same error occurs repeatedly.
    val createdAt: Long = elapsedRealtime()
    @JvmField val createdAt: Long = elapsedRealtime()
)
+5 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ import com.android.systemui.keyguard.shared.model.ErrorFaceAuthenticationStatus
import com.android.systemui.keyguard.shared.model.TransitionStep
import com.android.systemui.log.core.LogLevel.DEBUG
import com.android.systemui.log.dagger.FaceAuthLog
import com.google.errorprone.annotations.CompileTimeConstant
import javax.inject.Inject

private const val TAG = "DeviceEntryFaceAuthRepositoryLog"
@@ -264,4 +265,8 @@ constructor(
    fun watchdogScheduled() {
        logBuffer.log(TAG, DEBUG, "FaceManager Biometric watchdog scheduled.")
    }

    fun faceLockedOut(@CompileTimeConstant reason: String) {
        logBuffer.log(TAG, DEBUG, "Face auth has been locked out: $reason")
    }
}
Loading