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

Commit 8dc937df authored by Beverly's avatar Beverly Committed by Beverly Tai
Browse files

Don't start running FP until FPS is registered

Else, there may be a discrepancy between the
KeyguardUpdateMonitor state and the FPM state if KUM tries to startup
the FPS before it's registered.

Test: atest KeyguardUpdateMonitorTest
Test: manually crash SystemUI when the screen is off,
when turning the screen back on - FPS is running (on devices
with UDFPS, we see the UDFPS affordance)
Fixes: 216718969

Change-Id: I60e75057910f64c59a0c35c46a77763e11540a32
parent 82212e90
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -2027,6 +2027,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
        mAuthController.addCallback(new AuthController.Callback() {
            @Override
            public void onAllAuthenticatorsRegistered() {
                mainExecutor.execute(() -> updateBiometricListeningState(BIOMETRIC_ACTION_UPDATE));
            }

            @Override
@@ -2156,6 +2157,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            return;
        }

        // don't start running fingerprint until they're registered
        if (!mAuthController.areAllAuthenticatorsRegistered()) {
            return;
        }
        final boolean shouldListenForFingerprint = shouldListenForFingerprint(isUdfpsSupported());
        final boolean runningOrRestarting = mFingerprintRunningState == BIOMETRIC_STATE_RUNNING
                || mFingerprintRunningState == BIOMETRIC_STATE_CANCELLING_RESTARTING;
@@ -3523,6 +3528,8 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
            final int strongAuthFlags = mStrongAuthTracker.getStrongAuthForUser(userId);
            BiometricAuthenticated fingerprint = mUserFingerprintAuthenticated.get(userId);
            pw.println("  Fingerprint state (user=" + userId + ")");
            pw.println("    areAllAuthenticatorsRegistered="
                    + mAuthController.areAllAuthenticatorsRegistered());
            pw.println("    allowed="
                    + (fingerprint != null
                            && isUnlockingWithBiometricAllowed(fingerprint.mIsStrongBiometric)));
+9 −0
Original line number Diff line number Diff line
@@ -136,6 +136,7 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
    @NonNull private final SparseBooleanArray mUdfpsEnrolledForUser;
    @NonNull private final SensorPrivacyManager mSensorPrivacyManager;
    private final WakefulnessLifecycle mWakefulnessLifecycle;
    private boolean mAllAuthenticatorsRegistered;

    private class BiometricTaskStackListener extends TaskStackListener {
        @Override
@@ -226,6 +227,13 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
        }
    }

    /**
     * Whether all authentictors have been registered.
     */
    public boolean areAllAuthenticatorsRegistered() {
        return mAllAuthenticatorsRegistered;
    }

    private void handleAllAuthenticatorsRegistered(
            List<FingerprintSensorPropertiesInternal> sensors) {
        mExecution.assertIsMainThread();
@@ -233,6 +241,7 @@ public class AuthController extends CoreStartable implements CommandQueue.Callba
            Log.d(TAG, "handleAllAuthenticatorsRegistered | sensors: " + Arrays.toString(
                    sensors.toArray()));
        }
        mAllAuthenticatorsRegistered = true;
        mFpProps = sensors;
        List<FingerprintSensorPropertiesInternal> udfpsProps = new ArrayList<>();
        List<FingerprintSensorPropertiesInternal> sidefpsProps = new ArrayList<>();
+15 −0
Original line number Diff line number Diff line
@@ -243,6 +243,9 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
        verify(mStatusBarStateController).addCallback(mStatusBarStateListenerCaptor.capture());
        mStatusBarStateListener = mStatusBarStateListenerCaptor.getValue();
        mKeyguardUpdateMonitor.registerCallback(mTestCallback);

        mTestableLooper.processAllMessages();
        when(mAuthController.areAllAuthenticatorsRegistered()).thenReturn(true);
    }

    @After
@@ -470,6 +473,18 @@ public class KeyguardUpdateMonitorTest extends SysuiTestCase {
        verify(mFingerprintManager, never()).detectFingerprint(any(), any(), anyInt());
    }

    @Test
    public void test_doesNotTryToAuthenticateFingerprint_whenAuthenticatorsNotRegistered() {
        when(mAuthController.areAllAuthenticatorsRegistered()).thenReturn(false);

        mKeyguardUpdateMonitor.dispatchStartedGoingToSleep(0 /* why */);
        mTestableLooper.processAllMessages();

        verify(mFingerprintManager, never()).authenticate(any(), any(), any(), any(), anyInt(),
                anyInt(), anyInt());
        verify(mFingerprintManager, never()).detectFingerprint(any(), any(), anyInt());
    }

    @Test
    public void testFingerprintDoesNotAuth_whenEncrypted() {
        testFingerprintWhenStrongAuth(