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

Commit b1f13181 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Add ComponentInfo in sensor properties into dumpsys" into udc-dev am: 1ceca93e

parents fc71fc04 1ceca93e
Loading
Loading
Loading
Loading
+16 −7
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package android.hardware.biometrics;
import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
import android.util.IndentingPrintWriter;

/**
 * The internal class for storing the component info for a subsystem of the biometric sensor,
@@ -90,12 +92,19 @@ public class ComponentInfoInternal implements Parcelable {
        dest.writeString(softwareVersion);
    }

    @Override
    public String toString() {
        return "ComponentId: " + componentId
                + ", HardwareVersion: " + hardwareVersion
                + ", FirmwareVersion: " + firmwareVersion
                + ", SerialNumber " + serialNumber
                + ", SoftwareVersion: " + softwareVersion;
    /**
     * Print the component info into the given stream.
     *
     * @param pw The stream to dump the info into.
     * @hide
     */
    public void dump(@NonNull IndentingPrintWriter pw) {
        pw.println(TextUtils.formatSimple("componentId: %s", componentId));
        pw.increaseIndent();
        pw.println(TextUtils.formatSimple("hardwareVersion: %s", hardwareVersion));
        pw.println(TextUtils.formatSimple("firmwareVersion: %s", firmwareVersion));
        pw.println(TextUtils.formatSimple("serialNumber: %s", serialNumber));
        pw.println(TextUtils.formatSimple("softwareVersion: %s", softwareVersion));
        pw.decreaseIndent();
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -58,10 +58,10 @@ interface IBiometricService {
    boolean hasEnrolledBiometrics(int userId, String opPackageName);

    // Registers an authenticator (e.g. face, fingerprint, iris).
    // Id must be unique, whereas strength and modality don't need to be.
    // Sensor Id in sensor props must be unique, whereas modality doesn't need to be.
    // TODO(b/123321528): Turn strength and modality into enums.
    @EnforcePermission("USE_BIOMETRIC_INTERNAL")
    void registerAuthenticator(int id, int modality, int strength,
    void registerAuthenticator(int modality, in SensorPropertiesInternal props,
            IBiometricAuthenticator authenticator);

    // Register callback for when keyguard biometric eligibility changes.
+31 −6
Original line number Diff line number Diff line
@@ -22,14 +22,20 @@ import android.annotation.IntDef;
import android.annotation.NonNull;
import android.content.Context;
import android.hardware.biometrics.BiometricConstants;
import android.hardware.biometrics.ComponentInfoInternal;
import android.hardware.biometrics.IBiometricAuthenticator;
import android.hardware.biometrics.IBiometricSensorReceiver;
import android.hardware.biometrics.SensorPropertiesInternal;
import android.os.IBinder;
import android.os.RemoteException;
import android.text.TextUtils;
import android.util.IndentingPrintWriter;
import android.util.Slog;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Collections;
import java.util.List;

/**
 * Wraps IBiometricAuthenticator implementation and stores information about the authenticator,
@@ -67,6 +73,7 @@ public abstract class BiometricSensor {
    public final int id;
    public final @Authenticators.Types int oemStrength; // strength as configured by the OEM
    public final int modality;
    @NonNull public final List<ComponentInfoInternal> componentInfo;
    public final IBiometricAuthenticator impl;

    private @Authenticators.Types int mUpdatedStrength; // updated by BiometricStrengthController
@@ -86,15 +93,16 @@ public abstract class BiometricSensor {
     */
    abstract boolean confirmationSupported();

    BiometricSensor(@NonNull Context context, int id, int modality,
            @Authenticators.Types int strength, IBiometricAuthenticator impl) {
    BiometricSensor(@NonNull Context context, int modality, @NonNull SensorPropertiesInternal props,
            IBiometricAuthenticator impl) {
        this.mContext = context;
        this.id = id;
        this.id = props.sensorId;
        this.modality = modality;
        this.oemStrength = strength;
        this.oemStrength = Utils.propertyStrengthToAuthenticatorStrength(props.sensorStrength);
        this.componentInfo = Collections.unmodifiableList(props.componentInfo);
        this.impl = impl;

        mUpdatedStrength = strength;
        mUpdatedStrength = oemStrength;
        goToStateUnknown();
    }

@@ -178,8 +186,25 @@ public abstract class BiometricSensor {
        return "ID(" + id + ")"
                + ", oemStrength: " + oemStrength
                + ", updatedStrength: " + mUpdatedStrength
                + ", modality " + modality
                + ", modality: " + modality
                + ", state: " + mSensorState
                + ", cookie: " + mCookie;
    }

    protected void dump(@NonNull IndentingPrintWriter pw) {
        pw.println(TextUtils.formatSimple("ID: %d", id));
        pw.increaseIndent();
        pw.println(TextUtils.formatSimple("oemStrength: %d", oemStrength));
        pw.println(TextUtils.formatSimple("updatedStrength: %d", mUpdatedStrength));
        pw.println(TextUtils.formatSimple("modality: %d", modality));
        pw.println("componentInfo:");
        for (ComponentInfoInternal info : componentInfo) {
            pw.increaseIndent();
            info.dump(pw);
            pw.decreaseIndent();
        }
        pw.println(TextUtils.formatSimple("state: %d", mSensorState));
        pw.println(TextUtils.formatSimple("cookie: %d", mCookie));
        pw.decreaseIndent();
    }
}
+15 −7
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ import android.provider.Settings;
import android.security.KeyStore;
import android.text.TextUtils;
import android.util.ArraySet;
import android.util.IndentingPrintWriter;
import android.util.Pair;
import android.util.Slog;
import android.util.proto.ProtoOutputStream;
@@ -638,13 +639,16 @@ public class BiometricService extends SystemService {

        @android.annotation.EnforcePermission(android.Manifest.permission.USE_BIOMETRIC_INTERNAL)
        @Override
        public synchronized void registerAuthenticator(int id, int modality,
                @Authenticators.Types int strength,
        public synchronized void registerAuthenticator(int modality,
                @NonNull SensorPropertiesInternal props,
                @NonNull IBiometricAuthenticator authenticator) {

            super.registerAuthenticator_enforcePermission();

            Slog.d(TAG, "Registering ID: " + id
            @Authenticators.Types final int strength =
                    Utils.propertyStrengthToAuthenticatorStrength(props.sensorStrength);

            Slog.d(TAG, "Registering ID: " + props.sensorId
                    + " Modality: " + modality
                    + " Strength: " + strength);

@@ -665,12 +669,12 @@ public class BiometricService extends SystemService {
            }

            for (BiometricSensor sensor : mSensors) {
                if (sensor.id == id) {
                if (sensor.id == props.sensorId) {
                    throw new IllegalStateException("Cannot register duplicate authenticator");
                }
            }

            mSensors.add(new BiometricSensor(getContext(), id, modality, strength, authenticator) {
            mSensors.add(new BiometricSensor(getContext(), modality, props, authenticator) {
                @Override
                boolean confirmationAlwaysRequired(int userId) {
                    return mSettingObserver.getConfirmationAlwaysRequired(modality, userId);
@@ -1360,13 +1364,17 @@ public class BiometricService extends SystemService {
        return null;
    }

    private void dumpInternal(PrintWriter pw) {
    private void dumpInternal(PrintWriter printWriter) {
        IndentingPrintWriter pw = new IndentingPrintWriter(printWriter);

        pw.println("Legacy Settings: " + mSettingObserver.mUseLegacyFaceOnlySettings);
        pw.println();

        pw.println("Sensors:");
        for (BiometricSensor sensor : mSensors) {
            pw.println(" " + sensor);
            pw.increaseIndent();
            sensor.dump(pw);
            pw.decreaseIndent();
        }
        pw.println();
        pw.println("CurrentSession: " + mAuthSession);
+1 −5
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FACE;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.hardware.biometrics.BiometricManager;
import android.hardware.biometrics.IBiometricService;
import android.hardware.face.FaceSensorPropertiesInternal;
import android.hardware.face.IFaceAuthenticatorsRegisteredCallback;
@@ -28,7 +27,6 @@ import android.hardware.face.IFaceService;
import android.os.RemoteException;
import android.util.Slog;

import com.android.server.biometrics.Utils;
import com.android.server.biometrics.sensors.BiometricServiceRegistry;

import java.util.List;
@@ -53,10 +51,8 @@ public class FaceServiceRegistry extends BiometricServiceRegistry<ServiceProvide
    @Override
    protected void registerService(@NonNull IBiometricService service,
            @NonNull FaceSensorPropertiesInternal props) {
        @BiometricManager.Authenticators.Types final int strength =
                Utils.propertyStrengthToAuthenticatorStrength(props.sensorStrength);
        try {
            service.registerAuthenticator(props.sensorId, TYPE_FACE, strength,
            service.registerAuthenticator(TYPE_FACE, props,
                    new FaceAuthenticator(mService, props.sensorId));
        } catch (RemoteException e) {
            Slog.e(TAG, "Remote exception when registering sensorId: " + props.sensorId);
Loading