Remove recalibrate notification when user enrolls
Fixes: 134440107
Test: Force RECALIBRATE error to be received, then enroll without
tapping on the notification. Notification is automatically dismissed
Change-Id: I96ad00cb3599d3f288fed8555176995f9d7e168e
diff --git a/services/core/java/com/android/server/biometrics/face/FaceService.java b/services/core/java/com/android/server/biometrics/face/FaceService.java
index bcd22d4..2e6f3d8 100644
--- a/services/core/java/com/android/server/biometrics/face/FaceService.java
+++ b/services/core/java/com/android/server/biometrics/face/FaceService.java
@@ -97,6 +97,9 @@
"com.android.server.biometrics.face.ACTION_LOCKOUT_RESET";
private static final int CHALLENGE_TIMEOUT_SEC = 600; // 10 minutes
+ private static final String NOTIFICATION_TAG = "FaceService";
+ private static final int NOTIFICATION_ID = 1;
+
private final class FaceAuthClient extends AuthenticationClientImpl {
private int mLastAcquire;
@@ -177,13 +180,11 @@
0 /* requestCode */, intent, 0 /* flags */, null /* options */,
UserHandle.CURRENT);
- final String id = "FaceService";
+ final String channelName = "FaceEnrollNotificationChannel";
- NotificationManager nm =
- getContext().getSystemService(NotificationManager.class);
- NotificationChannel channel = new NotificationChannel(id, name,
+ NotificationChannel channel = new NotificationChannel(channelName, name,
NotificationManager.IMPORTANCE_HIGH);
- Notification notification = new Notification.Builder(getContext(), id)
+ Notification notification = new Notification.Builder(getContext(), channelName)
.setSmallIcon(R.drawable.ic_lock)
.setContentTitle(title)
.setContentText(content)
@@ -196,8 +197,9 @@
.setVisibility(Notification.VISIBILITY_SECRET)
.build();
- nm.createNotificationChannel(channel);
- nm.notifyAsUser(null /* tag */, 0 /* id */, notification, UserHandle.CURRENT);
+ mNotificationManager.createNotificationChannel(channel);
+ mNotificationManager.notifyAsUser(NOTIFICATION_TAG, NOTIFICATION_ID, notification,
+ UserHandle.CURRENT);
}
return super.onAcquired(acquireInfo, vendorCode);
@@ -231,6 +233,9 @@
final int[] disabledFeatures) {
checkPermission(MANAGE_BIOMETRIC);
+ mNotificationManager.cancelAsUser(NOTIFICATION_TAG, NOTIFICATION_ID,
+ UserHandle.CURRENT);
+
final boolean restricted = isRestricted();
final EnrollClientImpl client = new EnrollClientImpl(getContext(), mDaemonWrapper,
mHalDeviceId, token, new ServiceListenerImpl(receiver), mCurrentUserId,
@@ -688,6 +693,8 @@
// One of the AuthenticationClient constants
private int mCurrentUserLockoutMode;
+ private NotificationManager mNotificationManager;
+
private int[] mBiometricPromptIgnoreList;
private int[] mBiometricPromptIgnoreListVendor;
private int[] mKeyguardIgnoreList;
@@ -881,6 +888,8 @@
public FaceService(Context context) {
super(context);
+ mNotificationManager = getContext().getSystemService(NotificationManager.class);
+
mBiometricPromptIgnoreList = getContext().getResources()
.getIntArray(R.array.config_face_acquire_biometricprompt_ignorelist);
mBiometricPromptIgnoreListVendor = getContext().getResources()