Merge "Post a notification when ACQUIRED_RECALIBRATE is received" into qt-dev

am: 895664662b

Change-Id: I5028210278c1238591ec5b9e842fd7b2a0b73868
This commit is contained in:
Kevin Chyn
2019-04-23 22:36:20 -07:00
committed by android-build-merger
3 changed files with 59 additions and 1 deletions

View File

@@ -1507,6 +1507,13 @@
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. [CHAR LIMIT=90] -->
<string name="permdesc_useFaceAuthentication">Allows the app to use face authentication hardware for authentication</string>
<!-- Notification name shown when the system requires the user to re-enroll their face. [CHAR LIMIT=NONE] -->
<string name="face_recalibrate_notification_name">Face Authentication</string>
<!-- Notification title shown when the system requires the user to re-enroll their face. [CHAR LIMIT=NONE] -->
<string name="face_recalibrate_notification_title">Re-enroll your face</string>
<!-- Notification content shown when the system requires the user to re-enroll their face. [CHAR LIMIT=NONE] -->
<string name="face_recalibrate_notification_content">To improve recognition, please re-enroll your face</string>
<!-- Message shown during face acquisition when the face cannot be recognized [CHAR LIMIT=50] -->
<string name="face_acquired_insufficient">Couldn\u2019t capture accurate face data. Try again.</string>
<!-- Message shown during face acquisition when the image is too bright [CHAR LIMIT=50] -->

View File

@@ -2533,6 +2533,9 @@
<java-symbol type="bool" name="config_fingerprintSupportsGestures"/>
<!-- Face authentication messages -->
<java-symbol type="string" name="face_recalibrate_notification_name" />
<java-symbol type="string" name="face_recalibrate_notification_title" />
<java-symbol type="string" name="face_recalibrate_notification_content" />
<java-symbol type="string" name="face_error_unable_to_process" />
<java-symbol type="string" name="face_error_hw_not_available" />
<java-symbol type="string" name="face_error_no_space" />

View File

@@ -23,7 +23,12 @@ import static android.Manifest.permission.USE_BIOMETRIC_INTERNAL;
import android.app.ActivityManager;
import android.app.AppOpsManager;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.pm.UserInfo;
import android.hardware.biometrics.BiometricAuthenticator;
import android.hardware.biometrics.BiometricConstants;
@@ -48,10 +53,10 @@ import android.os.SELinux;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
import android.provider.Settings;
import android.util.Slog;
import android.util.proto.ProtoOutputStream;
import com.android.internal.R;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.util.DumpUtils;
@@ -124,6 +129,49 @@ public class FaceService extends BiometricServiceBase {
// but let's leave it as-is for now.
return result || !authenticated;
}
@Override
public boolean onAcquired(int acquireInfo, int vendorCode) {
if (acquireInfo == FaceManager.FACE_ACQUIRED_RECALIBRATE) {
final String name =
getContext().getString(R.string.face_recalibrate_notification_name);
final String title =
getContext().getString(R.string.face_recalibrate_notification_title);
final String content =
getContext().getString(R.string.face_recalibrate_notification_content);
final Intent intent = new Intent("android.settings.FACE_SETTINGS");
intent.setPackage("com.android.settings");
final PendingIntent pendingIntent = PendingIntent.getActivityAsUser(getContext(),
0 /* requestCode */, intent, 0 /* flags */, null /* options */,
UserHandle.CURRENT);
final String id = "FaceService";
NotificationManager nm =
getContext().getSystemService(NotificationManager.class);
NotificationChannel channel = new NotificationChannel(id, name,
NotificationManager.IMPORTANCE_HIGH);
Notification notification = new Notification.Builder(getContext(), id)
.setSmallIcon(R.drawable.ic_lock)
.setContentTitle(title)
.setContentText(content)
.setSubText(name)
.setOnlyAlertOnce(true)
.setLocalOnly(true)
.setAutoCancel(true)
.setCategory(Notification.CATEGORY_SYSTEM)
.setContentIntent(pendingIntent)
.build();
nm.createNotificationChannel(channel);
nm.notifyAsUser(null /* tag */, 0 /* id */, notification, UserHandle.CURRENT);
}
return super.onAcquired(acquireInfo, vendorCode);
}
}
/**