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

Commit 80ac68ca authored by Yanting Yang's avatar Yanting Yang
Browse files

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
parent f9a02151
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -323,16 +323,18 @@ public class FaceSettings extends DashboardFragment {

                @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 @@ public class FaceSettings extends DashboardFragment {
                    }
                    return isAttentionSupported;
                }

                private boolean hasEnrolledBiometrics(Context context) {
                    final FaceManager faceManager = Utils.getFaceManagerOrNull(context);
                    if (faceManager != null) {
                        return faceManager.hasEnrolledTemplates(UserHandle.myUserId());
                    }
                    return false;
                }
            };
}