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

Commit 9a619fcc authored by Wenhui Yang's avatar Wenhui Yang Committed by Android (Google) Code Review
Browse files

Merge "[8/n] FRR notification counter update" into udc-qpr-dev

parents 9a7c1712 0687d703
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -90,6 +90,11 @@ public class AuthenticationStats {
        mRejectedAttempts = 0;
    }

    /** Update enrollment notification counter after sending a notification. */
    public void updateNotificationCounter() {
        mEnrollmentNotifications++;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
+4 −1
Original line number Diff line number Diff line
@@ -121,10 +121,11 @@ public class AuthenticationStatsCollector {

        authenticationStats.authenticate(authenticated);

        sendNotificationIfNeeded(userId);

        if (mPersisterInitialized) {
            persistDataIfNeeded(userId);
        }
        sendNotificationIfNeeded(userId);
    }

    /** Check if a notification should be sent after a calculation cycle. */
@@ -164,8 +165,10 @@ public class AuthenticationStatsCollector {
        }
        if (hasEnrolledFace && !hasEnrolledFingerprint) {
            mBiometricNotification.sendFpEnrollNotification(mContext);
            authenticationStats.updateNotificationCounter();
        } else if (!hasEnrolledFace && hasEnrolledFingerprint) {
            mBiometricNotification.sendFaceEnrollNotification(mContext);
            authenticationStats.updateNotificationCounter();
        }
    }

+0 −4
Original line number Diff line number Diff line
@@ -95,8 +95,6 @@ public class BiometricNotificationUtils {

        final Intent intent = new Intent(FACE_ENROLL_ACTION);
        intent.setPackage(SETTINGS_PACKAGE);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);

        final PendingIntent pendingIntent = PendingIntent.getActivityAsUser(context,
                0 /* requestCode */, intent, PendingIntent.FLAG_IMMUTABLE /* flags */,
@@ -120,8 +118,6 @@ public class BiometricNotificationUtils {

        final Intent intent = new Intent(FINGERPRINT_ENROLL_ACTION);
        intent.setPackage(SETTINGS_PACKAGE);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);

        final PendingIntent pendingIntent = PendingIntent.getActivityAsUser(context,
                0 /* requestCode */, intent, PendingIntent.FLAG_IMMUTABLE /* flags */,
+9 −0
Original line number Diff line number Diff line
@@ -181,6 +181,7 @@ public class AuthenticationStatsCollectorTest {
                .getAuthenticationStatsForUser(USER_ID_1);
        assertThat(authenticationStats.getTotalAttempts()).isEqualTo(0);
        assertThat(authenticationStats.getRejectedAttempts()).isEqualTo(0);
        assertThat(authenticationStats.getEnrollmentNotifications()).isEqualTo(0);
        assertThat(authenticationStats.getFrr()).isWithin(0f).of(-1.0f);
    }

@@ -203,6 +204,8 @@ public class AuthenticationStatsCollectorTest {
                .getAuthenticationStatsForUser(USER_ID_1);
        assertThat(authenticationStats.getTotalAttempts()).isEqualTo(500);
        assertThat(authenticationStats.getRejectedAttempts()).isEqualTo(400);
        assertThat(authenticationStats.getEnrollmentNotifications())
                .isEqualTo(MAXIMUM_ENROLLMENT_NOTIFICATIONS);
        assertThat(authenticationStats.getFrr()).isWithin(0f).of(0.8f);
    }

@@ -230,6 +233,7 @@ public class AuthenticationStatsCollectorTest {
                .getAuthenticationStatsForUser(USER_ID_1);
        assertThat(authenticationStats.getTotalAttempts()).isEqualTo(0);
        assertThat(authenticationStats.getRejectedAttempts()).isEqualTo(0);
        assertThat(authenticationStats.getEnrollmentNotifications()).isEqualTo(0);
        assertThat(authenticationStats.getFrr()).isWithin(0f).of(-1.0f);
    }

@@ -256,6 +260,7 @@ public class AuthenticationStatsCollectorTest {
                .getAuthenticationStatsForUser(USER_ID_1);
        assertThat(authenticationStats.getTotalAttempts()).isEqualTo(0);
        assertThat(authenticationStats.getRejectedAttempts()).isEqualTo(0);
        assertThat(authenticationStats.getEnrollmentNotifications()).isEqualTo(0);
        assertThat(authenticationStats.getFrr()).isWithin(0f).of(-1.0f);
    }

@@ -284,6 +289,8 @@ public class AuthenticationStatsCollectorTest {
        assertThat(authenticationStats.getTotalAttempts()).isEqualTo(0);
        assertThat(authenticationStats.getRejectedAttempts()).isEqualTo(0);
        assertThat(authenticationStats.getFrr()).isWithin(0f).of(-1.0f);
        // Assert that notification count has been updated.
        assertThat(authenticationStats.getEnrollmentNotifications()).isEqualTo(1);
    }

    @Test
@@ -311,5 +318,7 @@ public class AuthenticationStatsCollectorTest {
        assertThat(authenticationStats.getTotalAttempts()).isEqualTo(0);
        assertThat(authenticationStats.getRejectedAttempts()).isEqualTo(0);
        assertThat(authenticationStats.getFrr()).isWithin(0f).of(-1.0f);
        // Assert that notification count has been updated.
        assertThat(authenticationStats.getEnrollmentNotifications()).isEqualTo(1);
    }
}