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

Commit 3582d530 authored by Diya Bera's avatar Diya Bera Committed by Android (Google) Code Review
Browse files

Merge "Clean up de hidl flagged code" into main

parents e1a22187 0d94465a
Loading
Loading
Loading
Loading
+1 −7
Original line number Diff line number Diff line
@@ -164,15 +164,9 @@ interface IFaceService {
    void getFeature(IBinder token, int userId, int feature, IFaceServiceReceiver receiver,
            String opPackageName);

    // Registers all HIDL and AIDL sensors. Only HIDL sensor properties need to be provided, because
    // AIDL sensor properties are retrieved directly from the available HALs. If no HIDL HALs exist,
    // hidlSensors must be non-null and empty. See AuthService.java
    @EnforcePermission("USE_BIOMETRIC_INTERNAL")
    void registerAuthenticators(in List<FaceSensorPropertiesInternal> hidlSensors);

    //Register all available face sensors.
    @EnforcePermission("USE_BIOMETRIC_INTERNAL")
    void registerAuthenticatorsLegacy(in FaceSensorConfigurations faceSensorConfigurations);
    void registerAuthenticators(in FaceSensorConfigurations faceSensorConfigurations);

    // Adds a callback which gets called when the service registers all of the face
    // authenticators. The callback is automatically removed after it's invoked.
+1 −7
Original line number Diff line number Diff line
@@ -177,13 +177,7 @@ interface IFingerprintService {

    //Register all available fingerprint sensors.
    @EnforcePermission("USE_BIOMETRIC_INTERNAL")
    void registerAuthenticatorsLegacy(in FingerprintSensorConfigurations fingerprintSensorConfigurations);

    // Registers all HIDL and AIDL sensors. Only HIDL sensor properties need to be provided, because
    // AIDL sensor properties are retrieved directly from the available HALs. If no HIDL HALs exist,
    // hidlSensors must be non-null and empty. See AuthService.java
    @EnforcePermission("USE_BIOMETRIC_INTERNAL")
    void registerAuthenticators(in List<FingerprintSensorPropertiesInternal> hidlSensors);
    void registerAuthenticators(in FingerprintSensorConfigurations fingerprintSensorConfigurations);

    // Adds a callback which gets called when the service registers all of the fingerprint
    // authenticators. The callback is automatically removed after it's invoked.
+3 −85
Original line number Diff line number Diff line
@@ -25,15 +25,12 @@ import static android.Manifest.permission.TEST_BIOMETRIC;
import static android.Manifest.permission.USE_BIOMETRIC;
import static android.Manifest.permission.USE_BIOMETRIC_INTERNAL;
import static android.Manifest.permission.USE_FINGERPRINT;
import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FACE;
import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FINGERPRINT;
import static android.hardware.biometrics.BiometricAuthenticator.TYPE_IRIS;
import static android.hardware.biometrics.BiometricAuthenticator.TYPE_NONE;
import static android.hardware.biometrics.BiometricConstants.BIOMETRIC_ERROR_CANCELED;
import static android.hardware.biometrics.BiometricManager.Authenticators;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.AppOpsManager;
import android.content.Context;
import android.content.pm.PackageManager;
@@ -778,13 +775,7 @@ public class AuthService extends SystemService {
            hidlConfigs = null;
        }

        if (com.android.server.biometrics.Flags.deHidl()) {
        registerAuthenticators();
        } else {
            // Registers HIDL and AIDL authenticators, but only HIDL configs need to be provided.
            registerAuthenticators(hidlConfigs);
        }

        mInjector.publishBinderService(this, mImpl);
    }

@@ -874,7 +865,7 @@ public class AuthService extends SystemService {

            if (faceService != null) {
                try {
                    faceService.registerAuthenticatorsLegacy(mFaceSensorConfigurations);
                    faceService.registerAuthenticators(mFaceSensorConfigurations);
                } catch (RemoteException e) {
                    Slog.e(TAG, "RemoteException when registering face authenticators", e);
                }
@@ -912,8 +903,7 @@ public class AuthService extends SystemService {

            if (fingerprintService != null) {
                try {
                    fingerprintService.registerAuthenticatorsLegacy(
                            mFingerprintSensorConfigurations);
                    fingerprintService.registerAuthenticators(mFingerprintSensorConfigurations);
                } catch (RemoteException e) {
                    Slog.e(TAG, "RemoteException when registering fingerprint authenticators", e);
                }
@@ -948,78 +938,6 @@ public class AuthService extends SystemService {
        return configStrings;
    }

    /**
     * Registers HIDL and AIDL authenticators for all of the available modalities.
     *
     * @param hidlSensors Array of {@link SensorConfig} configuration for all of the HIDL sensors
     *                    available on the device. This array may contain configuration for
     *                    different modalities and different sensors of the same modality in
     *                    arbitrary order. Can be null if no HIDL sensors exist on the device.
     */
    private void registerAuthenticators(@Nullable SensorConfig[] hidlSensors) {
        List<FingerprintSensorPropertiesInternal> hidlFingerprintSensors = new ArrayList<>();
        List<FaceSensorPropertiesInternal> hidlFaceSensors = new ArrayList<>();
        // Iris doesn't have IrisSensorPropertiesInternal, using SensorPropertiesInternal instead.
        List<SensorPropertiesInternal> hidlIrisSensors = new ArrayList<>();

        if (hidlSensors != null) {
            for (SensorConfig sensor : hidlSensors) {
                Slog.d(TAG, "Registering HIDL ID: " + sensor.id + " Modality: " + sensor.modality
                        + " Strength: " + sensor.strength);
                switch (sensor.modality) {
                    case TYPE_FINGERPRINT:
                        hidlFingerprintSensors.add(
                                getHidlFingerprintSensorProps(sensor.id, sensor.strength));
                        break;

                    case TYPE_FACE:
                        hidlFaceSensors.add(getHidlFaceSensorProps(sensor.id, sensor.strength));
                        break;

                    case TYPE_IRIS:
                        hidlIrisSensors.add(getHidlIrisSensorProps(sensor.id, sensor.strength));
                        break;

                    default:
                        Slog.e(TAG, "Unknown modality: " + sensor.modality);
                }
            }
        }

        final IFingerprintService fingerprintService = mInjector.getFingerprintService();
        if (fingerprintService != null) {
            try {
                fingerprintService.registerAuthenticators(hidlFingerprintSensors);
            } catch (RemoteException e) {
                Slog.e(TAG, "RemoteException when registering fingerprint authenticators", e);
            }
        } else if (hidlFingerprintSensors.size() > 0) {
            Slog.e(TAG, "HIDL fingerprint configuration exists, but FingerprintService is null.");
        }

        final IFaceService faceService = mInjector.getFaceService();
        if (faceService != null) {
            try {
                faceService.registerAuthenticators(hidlFaceSensors);
            } catch (RemoteException e) {
                Slog.e(TAG, "RemoteException when registering face authenticators", e);
            }
        } else if (hidlFaceSensors.size() > 0) {
            Slog.e(TAG, "HIDL face configuration exists, but FaceService is null.");
        }

        final IIrisService irisService = mInjector.getIrisService();
        if (irisService != null) {
            try {
                irisService.registerAuthenticators(hidlIrisSensors);
            } catch (RemoteException e) {
                Slog.e(TAG, "RemoteException when registering iris authenticators", e);
            }
        } else if (hidlIrisSensors.size() > 0) {
            Slog.e(TAG, "HIDL iris configuration exists, but IrisService is null.");
        }
    }

    private void checkInternalPermission() {
        getContext().enforceCallingOrSelfPermission(USE_BIOMETRIC_INTERNAL,
                "Must have USE_BIOMETRIC_INTERNAL permission");
+3 −7
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@ import static android.os.Process.THREAD_PRIORITY_DISPLAY;

import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;

/**
 * This class provides the handler to process biometric operations.
@@ -76,11 +75,8 @@ public class BiometricHandlerProvider {
    }

    private Handler getNewHandler(String tag, int priority) {
        if (Flags.deHidl()) {
        HandlerThread handlerThread = new HandlerThread(tag, priority);
        handlerThread.start();
        return new Handler(handlerThread.getLooper());
    }
        return new Handler(Looper.getMainLooper());
    }
}
+0 −16
Original line number Diff line number Diff line
@@ -80,22 +80,6 @@ public interface BiometricContext {
    /** Gets whether touches on sensor are ignored by HAL */
    boolean isHardwareIgnoringTouches();

    /**
     * Subscribe to context changes.
     *
     * Note that this method only notifies for properties that are visible to the HAL.
     *
     * @param context context that will be modified when changed
     * @param consumer callback when the context is modified
     *
     * @deprecated instead use {@link BiometricContext#subscribe(OperationContextExt, Consumer,
     *                                                           Consumer, AuthenticateOptions)}
     * TODO (b/294161627): Delete this API once Flags.DE_HIDL is removed.
     */
    @Deprecated
    void subscribe(@NonNull OperationContextExt context,
            @NonNull Consumer<OperationContext> consumer);

    /**
     * Subscribe to context changes and start the HAL operation.
     *
Loading