Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit db6fde82 authored by Jeff Pu's avatar Jeff Pu Committed by Android (Google) Code Review
Browse files

Merge "Enable biometric virtual sensors separately" into 24D1-dev

parents f8211931 d0071d27
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -10919,13 +10919,29 @@ public final class Settings {
                "biometric_debug_enabled";
        /**
         * Whether or not virtual sensors are enabled.
         * Whether or not both fingerprint and face virtual sensors are enabled.
         * @hide
         */
        @TestApi
        @Readable
        public static final String BIOMETRIC_VIRTUAL_ENABLED = "biometric_virtual_enabled";
        /**
         * Whether or not fingerprint virtual sensors are enabled.
         * @hide
         */
        @FlaggedApi("com.android.server.biometrics.face_vhal_feature")
        public static final String BIOMETRIC_FINGERPRINT_VIRTUAL_ENABLED =
                "biometric_fingerprint_virtual_enabled";
        /**
         * Whether or not face virtual sensors are enabled.
         * @hide
         */
        @FlaggedApi("com.android.server.biometrics.face_vhal_feature")
        public static final String BIOMETRIC_FACE_VIRTUAL_ENABLED =
                "biometric_face_virtual_enabled";
        /**
         * Whether or not biometric is allowed on Keyguard.
         * @hide
+2 −0
Original line number Diff line number Diff line
@@ -848,6 +848,8 @@ public class SettingsBackupTest {
                        Settings.Secure.BIOMETRIC_APP_ENABLED,
                        Settings.Secure.BIOMETRIC_KEYGUARD_ENABLED,
                        Settings.Secure.BIOMETRIC_VIRTUAL_ENABLED,
                        Settings.Secure.BIOMETRIC_FINGERPRINT_VIRTUAL_ENABLED,
                        Settings.Secure.BIOMETRIC_FACE_VIRTUAL_ENABLED,
                        Settings.Secure.BLUETOOTH_ADDR_VALID,
                        Settings.Secure.BLUETOOTH_ADDRESS,
                        Settings.Secure.BLUETOOTH_NAME,
+16 −4
Original line number Diff line number Diff line
@@ -89,11 +89,23 @@ public class Utils {
        return true;
    }

    /** If virtualized biometrics are supported (requires debug build). */
    public static boolean isVirtualEnabled(@NonNull Context context) {
    /** If virtualized fingerprint sensor is supported. */
    public static boolean isFingerprintVirtualEnabled(@NonNull Context context) {
        return Build.isDebuggable()
                && Settings.Secure.getIntForUser(context.getContentResolver(),
                Settings.Secure.BIOMETRIC_VIRTUAL_ENABLED, 0, UserHandle.USER_CURRENT) == 1;
                && (Settings.Secure.getIntForUser(context.getContentResolver(),
                Settings.Secure.BIOMETRIC_FINGERPRINT_VIRTUAL_ENABLED, 0,
                UserHandle.USER_CURRENT) == 1
                || Settings.Secure.getIntForUser(context.getContentResolver(),
                Settings.Secure.BIOMETRIC_VIRTUAL_ENABLED, 0, UserHandle.USER_CURRENT) == 1);
    }

    /** If virtualized face sensor is supported. */
    public static boolean isFaceVirtualEnabled(@NonNull Context context) {
        return Build.isDebuggable()
                && (Settings.Secure.getIntForUser(context.getContentResolver(),
                Settings.Secure.BIOMETRIC_FACE_VIRTUAL_ENABLED, 0, UserHandle.USER_CURRENT) == 1
                || Settings.Secure.getIntForUser(context.getContentResolver(),
                Settings.Secure.BIOMETRIC_VIRTUAL_ENABLED, 0, UserHandle.USER_CURRENT) == 1);
    }

    /**
+3 −3
Original line number Diff line number Diff line
@@ -748,7 +748,7 @@ public class FaceService extends SystemService {
            final Pair<String, SensorProps[]> virtualSensorProps = faceSensorConfigurations
                    .getSensorPairForInstance("virtual");

            if (Utils.isVirtualEnabled(getContext())) {
            if (Utils.isFaceVirtualEnabled(getContext())) {
                if (virtualSensorProps != null) {
                    return virtualSensorProps;
                } else {
@@ -778,7 +778,7 @@ public class FaceService extends SystemService {
            }

            final int virtualAt = aidlInstances.indexOf("virtual");
            if (Flags.faceVhalFeature() && Utils.isVirtualEnabled(getContext())) {
            if (Flags.faceVhalFeature() && Utils.isFaceVirtualEnabled(getContext())) {
                if (virtualAt != -1) {
                    //only virtual instance should be returned
                    Slog.i(TAG, "virtual hal is used");
@@ -920,7 +920,7 @@ public class FaceService extends SystemService {

    void syncEnrollmentsNow() {
        Utils.checkPermissionOrShell(getContext(), MANAGE_FACE);
        if (Flags.faceVhalFeature() && Utils.isVirtualEnabled(getContext())) {
        if (Flags.faceVhalFeature() && Utils.isFaceVirtualEnabled(getContext())) {
            Slog.i(TAG, "Sync virtual enrollments");
            final int userId = ActivityManager.getCurrentUser();
            for (ServiceProvider provider : mRegistry.getProviders()) {
+4 −4
Original line number Diff line number Diff line
@@ -1136,7 +1136,7 @@ public class FingerprintService extends SystemService {

        final Pair<String, SensorProps[]> virtualSensorPropsPair = fingerprintSensorConfigurations
                .getSensorPairForInstance("virtual");
        if (Utils.isVirtualEnabled(getContext())) {
        if (Utils.isFingerprintVirtualEnabled(getContext())) {
            if (virtualSensorPropsPair != null) {
                return virtualSensorPropsPair;
            } else {
@@ -1160,7 +1160,7 @@ public class FingerprintService extends SystemService {
        }

        final int virtualAt = aidlInstances.indexOf("virtual");
        if (Utils.isVirtualEnabled(getContext())) {
        if (Utils.isFingerprintVirtualEnabled(getContext())) {
            if (virtualAt != -1) {
                //only virtual instance should be returned
                Slog.i(TAG, "virtual hal is used");
@@ -1286,7 +1286,7 @@ public class FingerprintService extends SystemService {

    void syncEnrollmentsNow() {
        Utils.checkPermissionOrShell(getContext(), MANAGE_FINGERPRINT);
        if (Utils.isVirtualEnabled(getContext())) {
        if (Utils.isFingerprintVirtualEnabled(getContext())) {
            Slog.i(TAG, "Sync virtual enrollments");
            final int userId = ActivityManager.getCurrentUser();
            final CountDownLatch latch = new CountDownLatch(mRegistry.getProviders().size());
@@ -1315,7 +1315,7 @@ public class FingerprintService extends SystemService {
    }

    void simulateVhalFingerDown() {
        if (Utils.isVirtualEnabled(getContext())) {
        if (Utils.isFingerprintVirtualEnabled(getContext())) {
            Slog.i(TAG, "Simulate virtual HAL finger down event");
            final Pair<Integer, ServiceProvider> provider = mRegistry.getSingleProvider();
            if (provider != null) {
Loading