Merge "Support face unlock for PS if class2 biometric and above" into main

This commit is contained in:
Joseph Vincent
2024-04-04 13:03:31 +00:00
committed by Android (Google) Code Review
5 changed files with 100 additions and 8 deletions

View File

@@ -54,8 +54,10 @@ import android.graphics.drawable.AdaptiveIconDrawable;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.VectorDrawable;
import android.hardware.biometrics.SensorProperties;
import android.hardware.face.Face;
import android.hardware.face.FaceManager;
import android.hardware.face.FaceSensorPropertiesInternal;
import android.hardware.fingerprint.Fingerprint;
import android.hardware.fingerprint.FingerprintManager;
import android.net.ConnectivityManager;
@@ -927,6 +929,23 @@ public final class Utils extends com.android.settingslib.Utils {
return hasFingerprintHardware(context) && hasFaceHardware(context);
}
/**
* Return true if face is supported as Class 2 biometrics and above on the device, false
* otherwise.
*/
public static boolean isFaceNotConvenienceBiometric(@NonNull Context context) {
FaceManager faceManager = getFaceManagerOrNull(context);
if (faceManager != null) {
final List<FaceSensorPropertiesInternal> faceProperties =
faceManager.getSensorPropertiesInternal();
if (!faceProperties.isEmpty()) {
final FaceSensorPropertiesInternal props = faceProperties.get(0);
return props.sensorStrength != SensorProperties.STRENGTH_CONVENIENCE;
}
}
return false;
}
/**
* Launches an intent which may optionally have a user id defined.
* @param fragment Fragment to use to launch the activity.

View File

@@ -64,8 +64,8 @@ public class PrivateSpaceFacePreferenceController extends BiometricFaceStatusPre
@Override
public int getAvailabilityStatus() {
return android.os.Flags.allowPrivateProfile()
&& android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()
&& android.multiuser.Flags.enablePrivateSpaceFeatures()
&& android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()
&& android.multiuser.Flags.enablePrivateSpaceFeatures()
? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
}
@@ -87,7 +87,8 @@ public class PrivateSpaceFacePreferenceController extends BiometricFaceStatusPre
public void displayPreference(@NonNull PreferenceScreen screen) {
super.displayPreference(screen);
Preference preference = screen.findPreference(getPreferenceKey());
if (!Utils.isMultipleBiometricsSupported(mContext)) {
if (!Utils.isMultipleBiometricsSupported(mContext)
&& Utils.isFaceNotConvenienceBiometric(mContext)) {
preference.setTitle(R.string.private_space_face_title);
}
}

View File

@@ -66,8 +66,8 @@ public class PrivateSpaceFingerprintPreferenceController
@Override
public int getAvailabilityStatus() {
return android.os.Flags.allowPrivateProfile()
&& android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()
&& android.multiuser.Flags.enablePrivateSpaceFeatures()
&& android.multiuser.Flags.enableBiometricsToUnlockPrivateSpace()
&& android.multiuser.Flags.enablePrivateSpaceFeatures()
? AVAILABLE
: UNSUPPORTED_ON_DEVICE;
}
@@ -89,7 +89,8 @@ public class PrivateSpaceFingerprintPreferenceController
public void displayPreference(@NonNull PreferenceScreen screen) {
super.displayPreference(screen);
Preference preference = screen.findPreference(getPreferenceKey());
if (!Utils.isMultipleBiometricsSupported(mContext)) {
if (!Utils.isMultipleBiometricsSupported(mContext)
|| !Utils.isFaceNotConvenienceBiometric(mContext)) {
preference.setTitle(R.string.private_space_fingerprint_title);
}
}

View File

@@ -73,13 +73,14 @@ public class UseOneLockSettingsFragment extends DashboardFragment {
final List<AbstractPreferenceController> controllers = new ArrayList<>();
controllers.add(new UseOneLockControllerSwitch(context, this));
controllers.add(new PrivateSpaceLockController(context, this));
if (Utils.isMultipleBiometricsSupported(context)) {
boolean isFaceAuthAllowed = Utils.isFaceNotConvenienceBiometric(context);
if (Utils.isMultipleBiometricsSupported(context) && isFaceAuthAllowed) {
controllers.add(new FaceFingerprintUnlockController(context, getSettingsLifecycle()));
} else if (Utils.hasFingerprintHardware(context)) {
controllers.add(
new PrivateSpaceFingerprintPreferenceController(
context, "private_space_biometrics", getSettingsLifecycle()));
} else if (Utils.hasFaceHardware(context)) {
} else if (Utils.hasFaceHardware(context) && isFaceAuthAllowed) {
controllers.add(
new PrivateSpaceFacePreferenceController(
context, "private_space_biometrics", getSettingsLifecycle()));