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

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

Merge "Avoid IPCs to check for checking enrollment status of face and fp."...

Merge "Avoid IPCs to check for checking enrollment status of face and fp." into tm-qpr-dev am: 90095be8 am: 8f817cc2

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



Change-Id: Ia7263dd0402d2ec43766c772d6661cec3e9b3838
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 457a7c50 8f817cc2
Loading
Loading
Loading
Loading
+6 −3
Original line number Original line Diff line number Diff line
@@ -2566,8 +2566,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
    }
    }


    private boolean isOnlyFaceEnrolled() {
    private boolean isOnlyFaceEnrolled() {
        return isFaceAuthEnabledForUser(getCurrentUser())
        return isFaceEnrolled()
                && !isUnlockWithFingerprintPossible(getCurrentUser());
                && !getCachedIsUnlockWithFingerprintPossible(sCurrentUser);
    }
    }


    private void maybeLogListenerModelData(KeyguardListenModel model) {
    private void maybeLogListenerModelData(KeyguardListenModel model) {
@@ -2682,7 +2682,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        return isUnlockWithFacePossible(userId) || isUnlockWithFingerprintPossible(userId);
        return isUnlockWithFacePossible(userId) || isUnlockWithFingerprintPossible(userId);
    }
    }


    private boolean isUnlockWithFingerprintPossible(int userId) {
    @VisibleForTesting
    boolean isUnlockWithFingerprintPossible(int userId) {
        // TODO (b/242022358), make this rely on onEnrollmentChanged event and update it only once.
        mIsUnlockWithFingerprintPossible.put(userId, mFpm != null && mFpm.isHardwareDetected()
        mIsUnlockWithFingerprintPossible.put(userId, mFpm != null && mFpm.isHardwareDetected()
                && !isFingerprintDisabled(userId) && mFpm.hasEnrolledTemplates(userId));
                && !isFingerprintDisabled(userId) && mFpm.hasEnrolledTemplates(userId));
        return mIsUnlockWithFingerprintPossible.get(userId);
        return mIsUnlockWithFingerprintPossible.get(userId);
@@ -2704,6 +2706,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
     * If face hardware is available, user has enrolled and enabled auth via setting.
     * If face hardware is available, user has enrolled and enabled auth via setting.
     */
     */
    public boolean isFaceAuthEnabledForUser(int userId) {
    public boolean isFaceAuthEnabledForUser(int userId) {
        // TODO (b/242022358), make this rely on onEnrollmentChanged event and update it only once.
        updateFaceEnrolled(userId);
        updateFaceEnrolled(userId);
        return mIsFaceEnrolled;
        return mIsFaceEnrolled;
    }
    }
+17 −0
Original line number Original line Diff line number Diff line
@@ -582,6 +582,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
    @Test
    @Test
    public void testTriesToAuthenticate_whenBouncer() {
    public void testTriesToAuthenticate_whenBouncer() {
        fingerprintIsNotEnrolled();
        fingerprintIsNotEnrolled();
        faceAuthEnabled();
        setKeyguardBouncerVisibility(true);
        setKeyguardBouncerVisibility(true);


        verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean());
        verify(mFaceManager).authenticate(any(), any(), any(), any(), anyInt(), anyBoolean());
@@ -1219,6 +1220,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
    public void testShouldListenForFace_whenFaceIsAlreadyAuthenticated_returnsFalse()
    public void testShouldListenForFace_whenFaceIsAlreadyAuthenticated_returnsFalse()
            throws RemoteException {
            throws RemoteException {
        // Face auth should run when the following is true.
        // Face auth should run when the following is true.
        faceAuthEnabled();
        bouncerFullyVisibleAndNotGoingToSleep();
        bouncerFullyVisibleAndNotGoingToSleep();
        fingerprintIsNotEnrolled();
        fingerprintIsNotEnrolled();
        keyguardNotGoingAway();
        keyguardNotGoingAway();
@@ -1285,6 +1287,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
    public void testShouldListenForFace_whenBiometricsDisabledForUser_returnsFalse()
    public void testShouldListenForFace_whenBiometricsDisabledForUser_returnsFalse()
            throws RemoteException {
            throws RemoteException {
        // Preconditions for face auth to run
        // Preconditions for face auth to run
        faceAuthEnabled();
        keyguardNotGoingAway();
        keyguardNotGoingAway();
        bouncerFullyVisibleAndNotGoingToSleep();
        bouncerFullyVisibleAndNotGoingToSleep();
        fingerprintIsNotEnrolled();
        fingerprintIsNotEnrolled();
@@ -1308,6 +1311,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
    public void testShouldListenForFace_whenUserCurrentlySwitching_returnsFalse()
    public void testShouldListenForFace_whenUserCurrentlySwitching_returnsFalse()
            throws RemoteException {
            throws RemoteException {
        // Preconditions for face auth to run
        // Preconditions for face auth to run
        faceAuthEnabled();
        keyguardNotGoingAway();
        keyguardNotGoingAway();
        bouncerFullyVisibleAndNotGoingToSleep();
        bouncerFullyVisibleAndNotGoingToSleep();
        fingerprintIsNotEnrolled();
        fingerprintIsNotEnrolled();
@@ -1330,6 +1334,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
    public void testShouldListenForFace_whenSecureCameraLaunched_returnsFalse()
    public void testShouldListenForFace_whenSecureCameraLaunched_returnsFalse()
            throws RemoteException {
            throws RemoteException {
        // Preconditions for face auth to run
        // Preconditions for face auth to run
        faceAuthEnabled();
        keyguardNotGoingAway();
        keyguardNotGoingAway();
        bouncerFullyVisibleAndNotGoingToSleep();
        bouncerFullyVisibleAndNotGoingToSleep();
        fingerprintIsNotEnrolled();
        fingerprintIsNotEnrolled();
@@ -1375,6 +1380,7 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
    public void testShouldListenForFace_whenBouncerShowingAndDeviceIsAwake_returnsTrue()
    public void testShouldListenForFace_whenBouncerShowingAndDeviceIsAwake_returnsTrue()
            throws RemoteException {
            throws RemoteException {
        // Preconditions for face auth to run
        // Preconditions for face auth to run
        faceAuthEnabled();
        keyguardNotGoingAway();
        keyguardNotGoingAway();
        currentUserIsPrimary();
        currentUserIsPrimary();
        currentUserDoesNotHaveTrust();
        currentUserDoesNotHaveTrust();
@@ -1540,8 +1546,19 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
        assertThat(mKeyguardUpdateMonitor.shouldListenForFingerprint(anyBoolean())).isEqualTo(true);
        assertThat(mKeyguardUpdateMonitor.shouldListenForFingerprint(anyBoolean())).isEqualTo(true);
    }
    }


    private void faceAuthEnabled() {
        // this ensures KeyguardUpdateMonitor updates the cached mIsFaceEnrolled flag using the
        // face manager mock wire-up in setup()
        mKeyguardUpdateMonitor.isFaceAuthEnabledForUser(mCurrentUserId);
    }

    private void fingerprintIsNotEnrolled() {
    private void fingerprintIsNotEnrolled() {
        when(mFingerprintManager.hasEnrolledTemplates(mCurrentUserId)).thenReturn(false);
        when(mFingerprintManager.hasEnrolledTemplates(mCurrentUserId)).thenReturn(false);
        // This updates the cached fingerprint state.
        // There is no straightforward API to update the fingerprint state.
        // It currently works updates after enrollment changes because something else invokes
        // startListeningForFingerprint(), which internally calls this method.
        mKeyguardUpdateMonitor.isUnlockWithFingerprintPossible(mCurrentUserId);
    }
    }


    private void statusBarShadeIsNotLocked() {
    private void statusBarShadeIsNotLocked() {