According to the enrolled status to show/hide face unlock results
In current design, we only check the hardware support for face unlock to
show/hide the face unlock results in Settings Search. However the face
settings page is not launchable when the user doesn't enroll the face
unlock. It will cause user confused that face unlock results is no
response when they click them. Therefore, it's more making sense to add
enrolled status checking to index the face unlock results.
Test: manual and robotests
Fixes: 157954564
Change-Id: I5dd36e15fe48d537ee499c73cc172fc913b39554
diff --git a/src/com/android/settings/biometrics/face/FaceSettings.java b/src/com/android/settings/biometrics/face/FaceSettings.java
index c1ee545..a493ae0 100644
--- a/src/com/android/settings/biometrics/face/FaceSettings.java
+++ b/src/com/android/settings/biometrics/face/FaceSettings.java
@@ -323,16 +323,18 @@
@Override
protected boolean isPageSearchEnabled(Context context) {
- return isAvailable(context);
+ if (isAvailable(context)) {
+ return hasEnrolledBiometrics(context);
+ }
+
+ return false;
}
@Override
public List<String> getNonIndexableKeys(Context context) {
final List<String> keys = super.getNonIndexableKeys(context);
if (isAvailable(context)) {
- final FaceManager faceManager = context.getSystemService(FaceManager.class);
- final boolean hasEnrolled = faceManager.hasEnrolledTemplates(
- UserHandle.myUserId());
+ final boolean hasEnrolled = hasEnrolledBiometrics(context);
keys.add(hasEnrolled ? PREF_KEY_ENROLL_FACE_UNLOCK
: PREF_KEY_DELETE_FACE_DATA);
}
@@ -353,5 +355,13 @@
}
return isAttentionSupported;
}
+
+ private boolean hasEnrolledBiometrics(Context context) {
+ final FaceManager faceManager = Utils.getFaceManagerOrNull(context);
+ if (faceManager != null) {
+ return faceManager.hasEnrolledTemplates(UserHandle.myUserId());
+ }
+ return false;
+ }
};
}