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

Commit 82a38b09 authored by Haining Chen's avatar Haining Chen Committed by Android (Google) Code Review
Browse files

Merge "Add biometric component info and face type into SensorPropertiesInternal" into sc-dev

parents 667d2424 d04a1619
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1053,6 +1053,7 @@ package android.hardware.biometrics {
  }

  public class SensorProperties {
    method @NonNull public java.util.List<android.hardware.biometrics.SensorProperties.ComponentInfo> getComponentInfo();
    method public int getSensorId();
    method public int getSensorStrength();
    field public static final int STRENGTH_CONVENIENCE = 0; // 0x0
@@ -1060,6 +1061,14 @@ package android.hardware.biometrics {
    field public static final int STRENGTH_WEAK = 1; // 0x1
  }

  public static final class SensorProperties.ComponentInfo {
    method @NonNull public String getComponentId();
    method @NonNull public String getFirmwareVersion();
    method @NonNull public String getHardwareVersion();
    method @NonNull public String getSerialNumber();
    method @NonNull public String getSoftwareVersion();
  }

}

package android.hardware.camera2 {
+18 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package android.hardware.biometrics;

parcelable ComponentInfoInternal;
 No newline at end of file
+100 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.biometrics;

import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;

/**
 * The internal class for storing the component info for a subsystem of the biometric sensor,
 * as defined in {@link android.hardware.biometrics.common.ComponentInfo}.
 * @hide
 */
public class ComponentInfoInternal implements Parcelable {

    public final String componentId;
    public final String hardwareVersion;
    public final String firmwareVersion;
    public final String serialNumber;
    public final String softwareVersion;

    /**
     * Constructs a {@link ComponentInfoInternal} from another instance.
     * @hide
     */
    public static ComponentInfoInternal from(@NonNull ComponentInfoInternal comp) {
        return new ComponentInfoInternal(comp.componentId, comp.hardwareVersion,
                comp.firmwareVersion, comp.serialNumber, comp.softwareVersion);
    }

    /**
     * @hide
     */
    public ComponentInfoInternal(String componentId, String hardwareVersion,
            String firmwareVersion, String serialNumber, String softwareVersion) {
        this.componentId = componentId;
        this.hardwareVersion = hardwareVersion;
        this.firmwareVersion = firmwareVersion;
        this.serialNumber = serialNumber;
        this.softwareVersion = softwareVersion;
    }

    protected ComponentInfoInternal(Parcel in) {
        componentId = in.readString();
        hardwareVersion = in.readString();
        firmwareVersion = in.readString();
        serialNumber = in.readString();
        softwareVersion = in.readString();
    }

    public static final Creator<ComponentInfoInternal> CREATOR =
            new Creator<ComponentInfoInternal>() {
        @Override
        public ComponentInfoInternal createFromParcel(Parcel in) {
            return new ComponentInfoInternal(in);
        }

        @Override
        public ComponentInfoInternal[] newArray(int size) {
            return new ComponentInfoInternal[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(componentId);
        dest.writeString(hardwareVersion);
        dest.writeString(firmwareVersion);
        dest.writeString(serialNumber);
        dest.writeString(softwareVersion);
    }

    @Override
    public String toString() {
        return "ComponentId: " + componentId
                + ", HardwareVersion: " + hardwareVersion
                + ", FirmwareVersion: " + firmwareVersion
                + ", SerialNumber " + serialNumber
                + ", SoftwareVersion: " + softwareVersion;
    }
}
+96 −2
Original line number Diff line number Diff line
@@ -17,10 +17,13 @@
package android.hardware.biometrics;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.TestApi;

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

/**
 * The base class containing all modality-agnostic information.
@@ -56,15 +59,93 @@ public class SensorProperties {
    @Retention(RetentionPolicy.SOURCE)
    public @interface Strength {}

    /**
     * A class storing the component info for a subsystem of the sensor.
     */
    public static final class ComponentInfo {
        @NonNull private final String mComponentId;
        @NonNull private final String mHardwareVersion;
        @NonNull private final String mFirmwareVersion;
        @NonNull private final String mSerialNumber;
        @NonNull private final String mSoftwareVersion;

        /**
         * @hide
         */
        public ComponentInfo(@NonNull String componentId, @NonNull String hardwareVersion,
                @NonNull String firmwareVersion, @NonNull String serialNumber,
                @NonNull String softwareVersion) {
            mComponentId = componentId;
            mHardwareVersion = hardwareVersion;
            mFirmwareVersion = firmwareVersion;
            mSerialNumber = serialNumber;
            mSoftwareVersion = softwareVersion;
        }

        /**
         * @return The unique identifier for the subsystem.
         */
        @NonNull
        public String getComponentId() {
            return mComponentId;
        }

        /**
         * @return The hardware version for the subsystem. For example, <vendor>/<model>/<revision>.
         */
        @NonNull
        public String getHardwareVersion() {
            return mHardwareVersion;
        }

        /**
         * @return The firmware version for the subsystem.
         */
        @NonNull
        public String getFirmwareVersion() {
            return mFirmwareVersion;
        }

        /**
         * @return The serial number for the subsystem.
         */
        @NonNull
        public String getSerialNumber() {
            return mSerialNumber;
        }

        /**
         * @return The software version for the subsystem.
         * For example, <vendor>/<version>/<revision>.
         */
        @NonNull
        public String getSoftwareVersion() {
            return mSoftwareVersion;
        }

        /**
         * Constructs a {@link ComponentInfo} from the internal parcelable representation.
         * @hide
         */
        public static ComponentInfo from(ComponentInfoInternal internalComp) {
            return new ComponentInfo(internalComp.componentId, internalComp.hardwareVersion,
                    internalComp.firmwareVersion, internalComp.serialNumber,
                    internalComp.softwareVersion);
        }
    }

    private final int mSensorId;
    @Strength private final int mSensorStrength;
    private final List<ComponentInfo> mComponentInfo;

    /**
     * @hide
     */
    public SensorProperties(int sensorId, @Strength int sensorStrength) {
    public SensorProperties(int sensorId, @Strength int sensorStrength,
            List<ComponentInfo> componentInfo) {
        mSensorId = sensorId;
        mSensorStrength = sensorStrength;
        mComponentInfo = componentInfo;
    }

    /**
@@ -82,11 +163,24 @@ public class SensorProperties {
        return mSensorStrength;
    }

    /**
     * @return The sensor's component info.
     */
    @NonNull
    public List<ComponentInfo> getComponentInfo() {
        return mComponentInfo;
    }

    /**
     * Constructs a {@link SensorProperties} from the internal parcelable representation.
     * @hide
     */
    public static SensorProperties from(SensorPropertiesInternal internalProp) {
        return new SensorProperties(internalProp.sensorId, internalProp.sensorStrength);
        final List<ComponentInfo> componentInfo = new ArrayList<>();
        for (ComponentInfoInternal internalComp : internalProp.componentInfo) {
            componentInfo.add(ComponentInfo.from(internalComp));
        }
        return new SensorProperties(internalProp.sensorId, internalProp.sensorStrength,
                componentInfo);
    }
}
+22 −5
Original line number Diff line number Diff line
@@ -20,6 +20,9 @@ import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;
import java.util.List;

/**
 * The base class containing all modality-agnostic information. This is a superset of the
 * {@link android.hardware.biometrics.common.CommonProps}, and provides backwards-compatible
@@ -31,21 +34,23 @@ public class SensorPropertiesInternal implements Parcelable {
    public final int sensorId;
    @SensorProperties.Strength public final int sensorStrength;
    public final int maxEnrollmentsPerUser;
    public final List<ComponentInfoInternal> componentInfo;
    public final boolean resetLockoutRequiresHardwareAuthToken;
    public final boolean resetLockoutRequiresChallenge;

    public static SensorPropertiesInternal from(@NonNull SensorPropertiesInternal prop) {
        return new SensorPropertiesInternal(prop.sensorId, prop.sensorStrength,
                prop.maxEnrollmentsPerUser, prop.resetLockoutRequiresHardwareAuthToken,
                prop.resetLockoutRequiresChallenge);
                prop.maxEnrollmentsPerUser, prop.componentInfo,
                prop.resetLockoutRequiresHardwareAuthToken, prop.resetLockoutRequiresChallenge);
    }

    protected SensorPropertiesInternal(int sensorId, @SensorProperties.Strength int sensorStrength,
            int maxEnrollmentsPerUser, boolean resetLockoutRequiresHardwareAuthToken,
            boolean resetLockoutRequiresChallenge) {
            int maxEnrollmentsPerUser, @NonNull List<ComponentInfoInternal> componentInfo,
            boolean resetLockoutRequiresHardwareAuthToken, boolean resetLockoutRequiresChallenge) {
        this.sensorId = sensorId;
        this.sensorStrength = sensorStrength;
        this.maxEnrollmentsPerUser = maxEnrollmentsPerUser;
        this.componentInfo = componentInfo;
        this.resetLockoutRequiresHardwareAuthToken = resetLockoutRequiresHardwareAuthToken;
        this.resetLockoutRequiresChallenge = resetLockoutRequiresChallenge;
    }
@@ -54,6 +59,8 @@ public class SensorPropertiesInternal implements Parcelable {
        sensorId = in.readInt();
        sensorStrength = in.readInt();
        maxEnrollmentsPerUser = in.readInt();
        componentInfo = new ArrayList<>();
        in.readList(componentInfo, ComponentInfoInternal.class.getClassLoader());
        resetLockoutRequiresHardwareAuthToken = in.readBoolean();
        resetLockoutRequiresChallenge = in.readBoolean();
    }
@@ -81,13 +88,23 @@ public class SensorPropertiesInternal implements Parcelable {
        dest.writeInt(sensorId);
        dest.writeInt(sensorStrength);
        dest.writeInt(maxEnrollmentsPerUser);
        dest.writeList(componentInfo);
        dest.writeBoolean(resetLockoutRequiresHardwareAuthToken);
        dest.writeBoolean(resetLockoutRequiresChallenge);
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder();
        sb.append("[ ");
        for (ComponentInfoInternal info : componentInfo) {
            sb.append("[").append(info.toString());
            sb.append("] ");
        }
        sb.append("]");

        return "ID: " + sensorId + ", Strength: " + sensorStrength
                + ", MaxEnrollmentsPerUser: " + maxEnrollmentsPerUser;
                + ", MaxEnrollmentsPerUser: " + maxEnrollmentsPerUser
                + ", ComponentInfo: " + sb.toString();
    }
}
Loading