Merge changes from topic "face-bypass-move" into qt-r1-dev

* changes:
  Make bypass controller consistent with rest of face unlock settings
  Move lockscreen bypass setting to Settings > Security > Face unlock
This commit is contained in:
Kevin Chyn
2019-06-12 21:51:42 +00:00
committed by Android (Google) Code Review
8 changed files with 55 additions and 38 deletions

View File

@@ -123,8 +123,10 @@ public class FaceSettings extends DashboardFragment {
Preference appPref = findPreference(FaceSettingsAppPreferenceController.KEY);
Preference attentionPref = findPreference(FaceSettingsAttentionPreferenceController.KEY);
Preference confirmPref = findPreference(FaceSettingsConfirmPreferenceController.KEY);
Preference bypassPref =
findPreference(FaceSettingsLockscreenBypassPreferenceController.KEY);
mTogglePreferences = new ArrayList<>(
Arrays.asList(keyguardPref, appPref, attentionPref, confirmPref));
Arrays.asList(keyguardPref, appPref, attentionPref, confirmPref, bypassPref));
mRemoveButton = findPreference(FaceSettingsRemoveButtonPreferenceController.KEY);
mEnrollButton = findPreference(FaceSettingsEnrollButtonPreferenceController.KEY);
@@ -142,6 +144,7 @@ public class FaceSettings extends DashboardFragment {
// Don't show keyguard controller for work profile settings.
if (mUserManager.isManagedProfile(mUserId)) {
removePreference(FaceSettingsKeyguardPreferenceController.KEY);
removePreference(FaceSettingsLockscreenBypassPreferenceController.KEY);
}
if (savedInstanceState != null) {
@@ -248,6 +251,7 @@ public class FaceSettings extends DashboardFragment {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
controllers.add(new FaceSettingsVideoPreferenceController(context));
controllers.add(new FaceSettingsKeyguardPreferenceController(context));
controllers.add(new FaceSettingsLockscreenBypassPreferenceController(context));
controllers.add(new FaceSettingsAppPreferenceController(context));
controllers.add(new FaceSettingsAttentionPreferenceController(context));
controllers.add(new FaceSettingsRemoveButtonPreferenceController(context));

View File

@@ -18,16 +18,13 @@ package com.android.settings.biometrics.face;
import static android.provider.Settings.Secure.FACE_UNLOCK_KEYGUARD_ENABLED;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.hardware.face.FaceManager;
import android.os.UserHandle;
import android.provider.Settings;
import androidx.preference.Preference;
import com.android.settings.Utils;
import com.android.settings.core.TogglePreferenceController;
/**
* Preference controller for Face settings page controlling the ability to unlock the phone
@@ -87,13 +84,4 @@ public class FaceSettingsKeyguardPreferenceController extends FaceSettingsPrefer
preference.setEnabled(true);
}
}
private boolean adminDisabled() {
DevicePolicyManager dpm =
(DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
return dpm != null &&
(dpm.getKeyguardDisabledFeatures(null, UserHandle.myUserId())
& DevicePolicyManager.KEYGUARD_DISABLE_FACE)
!= 0;
}
}

View File

@@ -0,0 +1,84 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
package com.android.settings.biometrics.face;
import android.content.Context;
import android.content.pm.PackageManager;
import android.hardware.face.FaceManager;
import android.provider.Settings;
import androidx.preference.Preference;
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)) {
mFaceManager = context.getSystemService(FaceManager.class);
}
}
@Override
public boolean isChecked() {
boolean defaultValue = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_faceAuthDismissesKeyguard);
return Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.FACE_UNLOCK_DISMISSES_KEYGUARD, defaultValue ? 1 : 0) != 0;
}
@Override
public boolean setChecked(boolean isChecked) {
Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.FACE_UNLOCK_DISMISSES_KEYGUARD, isChecked ? 1 : 0);
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()) {
return mFaceManager.hasEnrolledTemplates() ? AVAILABLE : DISABLED_DEPENDENT_SETTING;
} else {
return UNSUPPORTED_ON_DEVICE;
}
}
}

View File

@@ -16,7 +16,9 @@
package com.android.settings.biometrics.face;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.os.UserHandle;
import com.android.settings.core.TogglePreferenceController;
@@ -38,4 +40,13 @@ public abstract class FaceSettingsPreferenceController extends TogglePreferenceC
protected int getUserId() {
return mUserId;
}
protected boolean adminDisabled() {
DevicePolicyManager dpm =
(DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
return dpm != null &&
(dpm.getKeyguardDisabledFeatures(null, UserHandle.myUserId())
& DevicePolicyManager.KEYGUARD_DISABLE_FACE)
!= 0;
}
}