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

Commit 67855509 authored by Haining Chen's avatar Haining Chen Committed by Automerger Merge Worker
Browse files

Merge "Revert "Add ComponentInfo in sensor properties into dumpsys"" into...

Merge "Revert "Add ComponentInfo in sensor properties into dumpsys"" into udc-dev am: 2e637bb6 am: 1c5b43c1

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23149557



Change-Id: I80d07dcbf6ed5464df2baa506b335a0abd5fc033
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 326eb643 1c5b43c1
Loading
Loading
Loading
Loading
+7 −16
Original line number Diff line number Diff line
@@ -19,8 +19,6 @@ 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,
@@ -92,19 +90,12 @@ public class ComponentInfoInternal implements Parcelable {
        dest.writeString(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();
    @Override
    public String toString() {
        return "ComponentId: " + componentId
                + ", HardwareVersion: " + hardwareVersion
                + ", FirmwareVersion: " + firmwareVersion
                + ", SerialNumber " + serialNumber
                + ", SoftwareVersion: " + softwareVersion;
    }
}
+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).
    // Sensor Id in sensor props must be unique, whereas modality doesn't need to be.
    // Id must be unique, whereas strength and modality don't need to be.
    // TODO(b/123321528): Turn strength and modality into enums.
    @EnforcePermission("USE_BIOMETRIC_INTERNAL")
    void registerAuthenticator(int modality, in SensorPropertiesInternal props,
    void registerAuthenticator(int id, int modality, int strength,
            IBiometricAuthenticator authenticator);

    // Register callback for when keyguard biometric eligibility changes.
+6 −31
Original line number Diff line number Diff line
@@ -22,20 +22,14 @@ 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,
@@ -73,7 +67,6 @@ 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
@@ -93,16 +86,15 @@ public abstract class BiometricSensor {
     */
    abstract boolean confirmationSupported();

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

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

@@ -186,25 +178,8 @@ 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();
    }
}
+7 −15
Original line number Diff line number Diff line
@@ -64,7 +64,6 @@ 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;
@@ -642,16 +641,13 @@ public class BiometricService extends SystemService {

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

            super.registerAuthenticator_enforcePermission();

            @Authenticators.Types final int strength =
                    Utils.propertyStrengthToAuthenticatorStrength(props.sensorStrength);

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

@@ -672,12 +668,12 @@ public class BiometricService extends SystemService {
            }

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

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

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

    private void dumpInternal(PrintWriter pw) {
        pw.println("Legacy Settings: " + mSettingObserver.mUseLegacyFaceOnlySettings);
        pw.println();

        pw.println("Sensors:");
        for (BiometricSensor sensor : mSensors) {
            pw.increaseIndent();
            sensor.dump(pw);
            pw.decreaseIndent();
            pw.println(" " + sensor);
        }
        pw.println();
        pw.println("CurrentSession: " + mAuthSession);
+5 −1
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ 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;
@@ -27,6 +28,7 @@ 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;
@@ -51,8 +53,10 @@ 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(TYPE_FACE, props,
            service.registerAuthenticator(props.sensorId, TYPE_FACE, strength,
                    new FaceAuthenticator(mService, props.sensorId));
        } catch (RemoteException e) {
            Slog.e(TAG, "Remote exception when registering sensorId: " + props.sensorId);
Loading