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

Commit 8634ddb6 authored by Beverly's avatar Beverly
Browse files

Move clearing face biometric recognized to FaceAuthInteractor

Previously, KeyguardUpdateMonitor would only clear its local
cache of fingerprint recognized but then would inform
trustManager to clear both fingerprint and face. Meanwhile,
SystemUIFaceAuthInteractor would separately track the face
authenticated state and be the source of truth for the
face authenticated state.

Instead of this confusing caches of state, this CL separates
fingerprint and face authenticated states. KeyguardUpdateMonitor
is responsible for fingerprint state and SystemUIFaceAuthInteractor
is reponsible for the face auth state.

Due to dependency cycles between KeyguardStateControllerImpl,
BypassController and DeviceEntryFaceAuthRepository, we still need
to source the onFacesCleared callback through KeyguardUpdateMonitor.

Test: manually attempt UDFPS right after a successful
face auth & going to sleep
Test: atest KeyguardFaceAuthInteractorTest KeyguardStateControllerTest
Flag: None
Bug: 301171760
Fixes: 312860694

Change-Id: I2c3481787e8838f91c8c3bfbf5236dbbc6160f12
parent d31ed40a
Loading
Loading
Loading
Loading
+26 −10
Original line number Diff line number Diff line
@@ -1277,6 +1277,17 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab

    private final FaceAuthenticationListener mFaceAuthenticationListener =
            new FaceAuthenticationListener() {
                public void onAuthenticatedChanged(boolean isAuthenticated) {
                    if (!isAuthenticated) {
                        for (int i = 0; i < mCallbacks.size(); i++) {
                            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
                            if (cb != null) {
                                cb.onFacesCleared();
                            }
                        }
                    }
                }

                @Override
                public void onAuthEnrollmentStateChanged(boolean enrolled) {
                    notifyAboutEnrollmentChange(TYPE_FACE);
@@ -1961,7 +1972,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab

    protected void handleStartedGoingToSleep(int arg1) {
        Assert.isMainThread();
        clearBiometricRecognized();
        clearFingerprintRecognized();
        for (int i = 0; i < mCallbacks.size(); i++) {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
            if (cb != null) {
@@ -3010,7 +3021,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    void handleUserSwitching(int userId, Runnable resultCallback) {
        mLogger.logUserSwitching(userId, "from UserTracker");
        Assert.isMainThread();
        clearBiometricRecognized();
        clearFingerprintRecognized();
        boolean trustUsuallyManaged = mTrustManager.isTrustUsuallyManaged(userId);
        mLogger.logTrustUsuallyManagedUpdated(userId, mUserTrustIsUsuallyManaged.get(userId),
                trustUsuallyManaged, "userSwitching");
@@ -3560,25 +3571,30 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        return mServiceStates.get(subId);
    }

    public void clearBiometricRecognized() {
        clearBiometricRecognized(UserHandle.USER_NULL);
    /**
     * Resets the fingerprint authenticated state to false.
     */
    public void clearFingerprintRecognized() {
        clearFingerprintRecognized(UserHandle.USER_NULL);
    }

    public void clearBiometricRecognizedWhenKeyguardDone(int unlockedUser) {
        clearBiometricRecognized(unlockedUser);
    /**
     * Resets the fingerprint authenticated state to false.
     */
    public void clearFingerprintRecognizedWhenKeyguardDone(int unlockedUser) {
        clearFingerprintRecognized(unlockedUser);
    }

    private void clearBiometricRecognized(int unlockedUser) {
    private void clearFingerprintRecognized(int unlockedUser) {
        Assert.isMainThread();
        mUserFingerprintAuthenticated.clear();
        mTrustManager.clearAllBiometricRecognized(FINGERPRINT, unlockedUser);
        mTrustManager.clearAllBiometricRecognized(FACE, unlockedUser);
        mLogger.d("clearBiometricRecognized");
        mLogger.d("clearFingerprintRecognized");

        for (int i = 0; i < mCallbacks.size(); i++) {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
            if (cb != null) {
                cb.onBiometricsCleared();
                cb.onFingerprintsCleared();
            }
        }
    }
+7 −2
Original line number Diff line number Diff line
@@ -291,9 +291,14 @@ public class KeyguardUpdateMonitorCallback {
    public void onLogoutEnabledChanged() { }

    /**
     * Called when authenticated biometrics are cleared.
     * Called when authenticated fingerprint biometrics are cleared.
     */
    public void onBiometricsCleared() { }
    public void onFingerprintsCleared() { }

    /**
     * Called when authenticated face biometrics have cleared.
     */
    public void onFacesCleared() { }

    /**
     * Called when the secondary lock screen requirement changes.
+1 −1
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ public class DozeAuthRemover implements DozeMachine.Part {
        if (newState == DozeMachine.State.DOZE || newState == DozeMachine.State.DOZE_AOD) {
            int currentUser = mSelectedUserInteractor.getSelectedUserId();
            if (mKeyguardUpdateMonitor.getUserUnlockedWithBiometric(currentUser)) {
                mKeyguardUpdateMonitor.clearBiometricRecognized();
                mKeyguardUpdateMonitor.clearFingerprintRecognized();
            }
        }
    }
+2 −2
Original line number Diff line number Diff line
@@ -2611,14 +2611,14 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
        }

        if (mGoingToSleep) {
            mUpdateMonitor.clearBiometricRecognizedWhenKeyguardDone(currentUser);
            mUpdateMonitor.clearFingerprintRecognizedWhenKeyguardDone(currentUser);
            Log.i(TAG, "Device is going to sleep, aborting keyguardDone");
            return;
        }
        setPendingLock(false); // user may have authenticated during the screen off animation

        handleHide();
        mUpdateMonitor.clearBiometricRecognizedWhenKeyguardDone(currentUser);
        mUpdateMonitor.clearFingerprintRecognizedWhenKeyguardDone(currentUser);
        Trace.endSection();
    }

+1 −1
Original line number Diff line number Diff line
@@ -326,7 +326,7 @@ constructor(
                    it.selectionStatus == SelectionStatus.SELECTION_IN_PROGRESS
                },
            )
            .flowOn(backgroundDispatcher)
            .flowOn(mainDispatcher) // should revoke auth ASAP in the main thread
            .onEach { anyOfThemIsTrue ->
                if (anyOfThemIsTrue) {
                    clearPendingAuthRequest("Resetting auth status")
Loading