diff options
author | 2023-08-27 16:22:54 +0000 | |
---|---|---|
committer | 2023-08-27 16:22:54 +0000 | |
commit | 9a619fccbf0095dd543a070ac6158523b75cc07a (patch) | |
tree | e126b0e4ede62b12f341d0f3bf37a3208dfeb5e5 | |
parent | 9a7c171286a0faba8d8edaf74060825f53ea20a5 (diff) | |
parent | 0687d7038834f550da8950039f87cfb2d27f551f (diff) |
Merge "[8/n] FRR notification counter update" into udc-qpr-dev
4 files changed, 18 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/biometrics/AuthenticationStats.java b/services/core/java/com/android/server/biometrics/AuthenticationStats.java index e109cc8011e7..707240bf41f8 100644 --- a/services/core/java/com/android/server/biometrics/AuthenticationStats.java +++ b/services/core/java/com/android/server/biometrics/AuthenticationStats.java @@ -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) { diff --git a/services/core/java/com/android/server/biometrics/AuthenticationStatsCollector.java b/services/core/java/com/android/server/biometrics/AuthenticationStatsCollector.java index 3d1b162d508b..2a3302c119a9 100644 --- a/services/core/java/com/android/server/biometrics/AuthenticationStatsCollector.java +++ b/services/core/java/com/android/server/biometrics/AuthenticationStatsCollector.java @@ -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(); } } diff --git a/services/core/java/com/android/server/biometrics/sensors/BiometricNotificationUtils.java b/services/core/java/com/android/server/biometrics/sensors/BiometricNotificationUtils.java index 2ff695d7b85d..0fc8ababbafb 100644 --- a/services/core/java/com/android/server/biometrics/sensors/BiometricNotificationUtils.java +++ b/services/core/java/com/android/server/biometrics/sensors/BiometricNotificationUtils.java @@ -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 */, diff --git a/services/tests/servicestests/src/com/android/server/biometrics/AuthenticationStatsCollectorTest.java b/services/tests/servicestests/src/com/android/server/biometrics/AuthenticationStatsCollectorTest.java index 64e776e35f00..a621c0c01067 100644 --- a/services/tests/servicestests/src/com/android/server/biometrics/AuthenticationStatsCollectorTest.java +++ b/services/tests/servicestests/src/com/android/server/biometrics/AuthenticationStatsCollectorTest.java @@ -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); } } |