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

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

Merge changes I55d3de76,I3f7c7aac into main

* changes:
  Don't update face auth locked out state if face auth is not enabled or enrolled
  Add isFaceEnrolledAndEnabled method to the interactor to allow KeyguardUpdatMonitor to read the state
parents 78594940 e422e380
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -3463,7 +3463,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    @Deprecated
    private boolean isUnlockWithFacePossible(int userId) {
        if (isFaceAuthInteractorEnabled()) {
            return getFaceAuthInteractor().canFaceAuthRun();
            return getFaceAuthInteractor() != null
                    && getFaceAuthInteractor().isFaceAuthEnabledAndEnrolled();
        }
        return isFaceAuthEnabledForUser(userId) && !isFaceDisabled(userId);
    }
+3 −2
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ interface BiometricSettingsRepository {
     * If the current user can use face auth to enter the device. This is true when the user has
     * face auth enrolled, and is enabled in settings/device policy.
     */
    val isFaceAuthEnrolledAndEnabled: Flow<Boolean>
    val isFaceAuthEnrolledAndEnabled: StateFlow<Boolean>

    /**
     * If the current user can use face auth to enter the device right now. This is true when
@@ -348,10 +348,11 @@ constructor(
            .and(isFingerprintBiometricAllowed)
            .stateIn(scope, SharingStarted.Eagerly, false)

    override val isFaceAuthEnrolledAndEnabled: Flow<Boolean> =
    override val isFaceAuthEnrolledAndEnabled: StateFlow<Boolean> =
        isFaceAuthenticationEnabled
            .and(isFaceEnrolled)
            .and(mobileConnectionsRepository.isAnySimSecure.isFalse())
            .stateIn(scope, SharingStarted.Eagerly, false)

    override val isFaceAuthCurrentlyAllowed: Flow<Boolean> =
        isFaceAuthEnrolledAndEnabled
+3 −0
Original line number Diff line number Diff line
@@ -41,6 +41,9 @@ interface KeyguardFaceAuthInteractor {
    /** Whether face auth is in lock out state. */
    fun isLockedOut(): Boolean

    /** Whether face auth is enrolled and enabled for the current user */
    fun isFaceAuthEnabledAndEnrolled(): Boolean

    /**
     * Register listener for use from code that cannot use [authenticationStatus] or
     * [detectionStatus]
+1 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ class NoopKeyguardFaceAuthInteractor @Inject constructor() : KeyguardFaceAuthInt
    override fun isLockedOut(): Boolean = false

    override fun isEnabled() = false
    override fun isFaceAuthEnabledAndEnrolled(): Boolean = false

    override fun registerListener(listener: FaceAuthenticationListener) {}

+9 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import com.android.systemui.dagger.qualifiers.Application
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.BiometricSettingsRepository
import com.android.systemui.keyguard.data.repository.DeviceEntryFaceAuthRepository
import com.android.systemui.keyguard.data.repository.DeviceEntryFingerprintAuthRepository
import com.android.systemui.keyguard.shared.model.ErrorFaceAuthenticationStatus
@@ -81,6 +82,7 @@ constructor(
    private val facePropertyRepository: FacePropertyRepository,
    private val faceWakeUpTriggersConfig: FaceWakeUpTriggersConfig,
    private val powerInteractor: PowerInteractor,
    private val biometricSettingsRepository: BiometricSettingsRepository,
) : CoreStartable, KeyguardFaceAuthInteractor {

    private val listeners: MutableList<FaceAuthenticationListener> = mutableListOf()
@@ -149,9 +151,12 @@ constructor(
            .onEach {
                if (it) {
                    faceAuthenticationLogger.faceLockedOut("Fingerprint locked out")
                    // We don't care about this if face auth is not enabled.
                    if (isFaceAuthEnabledAndEnrolled()) {
                        repository.setLockedOut(true)
                    }
                }
            }
            .launchIn(applicationScope)

        // User switching should stop face auth and then when it is complete we should trigger face
@@ -263,6 +268,9 @@ constructor(
        }
    }

    override fun isFaceAuthEnabledAndEnrolled(): Boolean =
        biometricSettingsRepository.isFaceAuthEnrolledAndEnabled.value

    private fun observeFaceAuthStateUpdates() {
        authenticationStatus
            .onEach { authStatusUpdate ->
Loading