Make bypass controller consistent with rest of face unlock settings
1) Should only be shown for owner profile 2) Should be disabled if A) not enrolled, B) DevicePolicyManager, C) HAL issue Fixes: 134700640 Test: Manual test of conditions above Change-Id: Id72db59c662df6c529c98aafd610de8c86c77ebd
This commit is contained in:
@@ -21,14 +21,22 @@ import android.content.pm.PackageManager;
|
||||
import android.hardware.face.FaceManager;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
public class FaceSettingsLockscreenBypassPreferenceController extends TogglePreferenceController {
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
|
||||
public class FaceSettingsLockscreenBypassPreferenceController
|
||||
extends FaceSettingsPreferenceController {
|
||||
|
||||
static final String KEY = "security_lockscreen_bypass";
|
||||
|
||||
@VisibleForTesting
|
||||
protected FaceManager mFaceManager;
|
||||
|
||||
public FaceSettingsLockscreenBypassPreferenceController(Context context) {
|
||||
this(context, KEY);
|
||||
}
|
||||
|
||||
public FaceSettingsLockscreenBypassPreferenceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE)) {
|
||||
@@ -51,6 +59,20 @@ public class FaceSettingsLockscreenBypassPreferenceController extends TogglePref
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
super.updateState(preference);
|
||||
if (!FaceSettings.isAvailable(mContext)) {
|
||||
preference.setEnabled(false);
|
||||
} else if (adminDisabled()) {
|
||||
preference.setEnabled(false);
|
||||
} else if (!mFaceManager.hasEnrolledTemplates(getUserId())) {
|
||||
preference.setEnabled(false);
|
||||
} else {
|
||||
preference.setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
if (mFaceManager != null && mFaceManager.isHardwareDetected()) {
|
||||
|
Reference in New Issue
Block a user