Stay in face settings unless the user explicitly backs out
Bug: 130898604 Test: Builds Change-Id: I7159c3a6259d298f78b8328b2c6974ba46fb56f9
This commit is contained in:
@@ -19,22 +19,28 @@ package com.android.settings.biometrics.face;
|
||||
import static android.provider.Settings.Secure.FACE_UNLOCK_APP_ENABLED;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.face.FaceManager;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
/**
|
||||
* Preference controller for Face settings page controlling the ability to use
|
||||
* Face authentication in apps (through BiometricPrompt).
|
||||
*/
|
||||
public class FaceSettingsAppPreferenceController extends FaceSettingsPreferenceController {
|
||||
|
||||
private static final String KEY = "security_settings_face_app";
|
||||
static final String KEY = "security_settings_face_app";
|
||||
|
||||
private static final int ON = 1;
|
||||
private static final int OFF = 0;
|
||||
private static final int DEFAULT = ON; // face unlock is enabled for BiometricPrompt by default
|
||||
|
||||
private FaceManager mFaceManager;
|
||||
|
||||
public FaceSettingsAppPreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
mFaceManager = context.getSystemService(FaceManager.class);
|
||||
}
|
||||
|
||||
public FaceSettingsAppPreferenceController(Context context) {
|
||||
@@ -56,6 +62,18 @@ public class FaceSettingsAppPreferenceController extends FaceSettingsPreferenceC
|
||||
isChecked ? ON : OFF, getUserId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
if (!FaceSettings.isAvailable(mContext)) {
|
||||
preference.setEnabled(false);
|
||||
} else if (!mFaceManager.hasEnrolledTemplates(getUserId())) {
|
||||
preference.setEnabled(false);
|
||||
} else {
|
||||
preference.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
|
Reference in New Issue
Block a user