OSDN Git Service

Favor setup face in search settings.
authorjoshmccloskey <joshmccloskey@google.com>
Tue, 9 Jul 2019 22:28:05 +0000 (15:28 -0700)
committerJoshua Mccloskey <joshmccloskey@google.com>
Tue, 9 Jul 2019 22:41:33 +0000 (22:41 +0000)
Test: Manual.
Fixes: 137135217
Change-Id: I5e0a72a117e2af6d9262d07616cc539ee7a7e55e

src/com/android/settings/biometrics/face/FaceSettingsAppPreferenceController.java

index 70c00e5..a54171e 100644 (file)
@@ -78,6 +78,19 @@ public class FaceSettingsAppPreferenceController extends FaceSettingsPreferenceC
 
     @Override
     public int getAvailabilityStatus() {
-        return AVAILABLE;
+        if(mFaceManager == null){
+            return AVAILABLE_UNSEARCHABLE;
+        }
+
+        // By only allowing this preference controller to be searchable when the feature is turned
+        // off, it will give preference to the face setup controller.
+        final boolean hasEnrolledUser = mFaceManager.hasEnrolledTemplates(getUserId());
+        final boolean appUnlockEnabled = Settings.Secure.getIntForUser(
+                mContext.getContentResolver(), FACE_UNLOCK_APP_ENABLED, OFF, getUserId()) == ON;
+        if (hasEnrolledUser && !appUnlockEnabled) {
+            return AVAILABLE;
+        } else {
+            return AVAILABLE_UNSEARCHABLE;
+        }
     }
 }