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

Commit 37ab8cbe authored by Chandru S's avatar Chandru S
Browse files

Add isFaceEnrolledAndEnabled method to the interactor to allow...

Add isFaceEnrolledAndEnabled method to the interactor to allow KeyguardUpdatMonitor to read the state

We were using a more restrictive boolean before which was also checking all the other gating conditions.

Other changes:
 - Test setup changes to BiometricSettingsRepositoryTest to handle two instances of AuthControllerCallback being registered.

Bug: 302572730
Test: atest KeyguardUpdateMonitorTest
Test: atest KeyguardFaceAuthInteractorTest

Change-Id: I3f7c7aac3c0eccc2ad7b86068cc456a3244b4a43
parent 67863693
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -153,7 +153,6 @@ import com.android.settingslib.Utils;
import com.android.settingslib.WirelessUtils;
import com.android.settingslib.fuelgauge.BatteryStatus;
import com.android.systemui.Dumpable;
import com.android.systemui.res.R;
import com.android.systemui.biometrics.AuthController;
import com.android.systemui.biometrics.FingerprintInteractiveToAuthProvider;
import com.android.systemui.broadcast.BroadcastDispatcher;
@@ -177,6 +176,7 @@ import com.android.systemui.keyguard.shared.model.SysUiFaceAuthenticateOptions;
import com.android.systemui.log.SessionTracker;
import com.android.systemui.plugins.WeatherData;
import com.android.systemui.plugins.statusbar.StatusBarStateController;
import com.android.systemui.res.R;
import com.android.systemui.settings.DisplayTracker;
import com.android.systemui.settings.UserTracker;
import com.android.systemui.shared.system.TaskStackChangeListener;
@@ -3457,7 +3457,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) {}

+5 −0
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()
@@ -263,6 +265,9 @@ constructor(
        }
    }

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

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