Add Biometrics settings inside private space One Lock settings
This includes below changes: - Add Biometrics preferernce in Private Space One Lock settings page - Face and Fingerprint enrolment for Private profile - Feature is behind flag android.multiuser.enable_biometrics_to_unlock_private_space Screenshots: go/ss/9cWZRAuvGGW7gMm.png go/ss/B3NoFbL3KbpSzeN.png go/ss/7xH3DLi9d6Lu2mR.png go/ss/8WBEgKychWpduXg.png go/ss/8pmPGshd9aiPvVC.png go/ss/AFPBPbiaBBvTj3p.png go/ss/3fE4XKLLUdP8LmF.png Bug: 308862923 Test: atest CombinedBiometricStatusUtilsTest, atest FaceFingerprintUnlockControllerTest Change-Id: I1853107a4df4fc97db53c97524c6d44a4f554e37
This commit is contained in:
@@ -17,25 +17,43 @@
|
||||
package com.android.settings.privatespace.onelock;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.os.UserHandle;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settings.biometrics.combination.CombinedBiometricStatusPreferenceController;
|
||||
import com.android.settings.privatespace.PrivateSpaceMaintainer;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
/** Represents the preference controller to enroll biometrics for private space lock. */
|
||||
public class FaceFingerprintUnlockController extends AbstractPreferenceController {
|
||||
public class FaceFingerprintUnlockController extends CombinedBiometricStatusPreferenceController {
|
||||
private static final String TAG = "PSBiometricCtrl";
|
||||
private static final String KEY_SET_UNSET_FACE_FINGERPRINT = "private_space_biometrics";
|
||||
private final int mProfileUserId;
|
||||
|
||||
public FaceFingerprintUnlockController(Context context, SettingsPreferenceFragment host) {
|
||||
super(context);
|
||||
public FaceFingerprintUnlockController(Context context, Lifecycle lifecycle) {
|
||||
super(context, KEY_SET_UNSET_FACE_FINGERPRINT, lifecycle);
|
||||
mProfileUserId = getUserId();
|
||||
}
|
||||
|
||||
protected boolean isUserSupported() {
|
||||
return android.os.Flags.allowPrivateProfile()
|
||||
&& android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()
|
||||
&& mProfileUserId != UserHandle.USER_NULL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return android.os.Flags.allowPrivateProfile();
|
||||
protected int getUserId() {
|
||||
UserHandle privateProfileHandle =
|
||||
PrivateSpaceMaintainer.getInstance(mContext).getPrivateProfileHandle();
|
||||
if (privateProfileHandle != null) {
|
||||
return privateProfileHandle.getIdentifier();
|
||||
} else {
|
||||
Log.e(TAG, "Private profile user handle is not expected to be null.");
|
||||
}
|
||||
return UserHandle.USER_NULL;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -44,14 +62,19 @@ public class FaceFingerprintUnlockController extends AbstractPreferenceControlle
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handlePreferenceTreeClick(Preference preference) {
|
||||
return TextUtils.equals(preference.getKey(), getPreferenceKey());
|
||||
protected String getSettingsClassName() {
|
||||
return mCombinedBiometricStatusUtils.getPrivateProfileSettingsClassName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
//TODO(b/308862923) : Add condition to check and enable when separate private lock is set.
|
||||
preference.setSummary(mContext.getString(R.string.lock_settings_profile_unified_summary));
|
||||
preference.setEnabled(false);
|
||||
if (mLockPatternUtils.isSeparateProfileChallengeEnabled(mProfileUserId)) {
|
||||
super.updateState(preference);
|
||||
preference.setEnabled(true);
|
||||
} else {
|
||||
preference.setSummary(
|
||||
mContext.getString(R.string.lock_settings_profile_unified_summary));
|
||||
preference.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user