diff options
| author | Haining Chen <hainingc@google.com> | 2021-03-05 19:34:42 -0800 |
|---|---|---|
| committer | Haining Chen <hainingc@google.com> | 2021-03-17 16:10:18 -0700 |
| commit | d04a1619c005464b3253bbf5e5c59e1d97ee29b2 (patch) | |
| tree | 89b592613820062ea317ce5a48016c9c5f884787 /core/java/android | |
| parent | 324d2e390afd40359d80cc6cf29646017f43b66a (diff) | |
Add biometric component info and face type into SensorPropertiesInternal
Bug: 156024031
Test: m -j test-api-stubs-docs-non-updatable-update-current-api
Test: m -j
Test: atest com.android.server.biometrics
Test: atest com.android.systemui.biometrics
Change-Id: I527713b6c87a3d49e28aed09ed6c74df4b5db175
Diffstat (limited to 'core/java/android')
8 files changed, 326 insertions, 21 deletions
diff --git a/core/java/android/hardware/biometrics/ComponentInfoInternal.aidl b/core/java/android/hardware/biometrics/ComponentInfoInternal.aidl new file mode 100644 index 000000000000..0c780cc71974 --- /dev/null +++ b/core/java/android/hardware/biometrics/ComponentInfoInternal.aidl @@ -0,0 +1,18 @@ +/* + * 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 diff --git a/core/java/android/hardware/biometrics/ComponentInfoInternal.java b/core/java/android/hardware/biometrics/ComponentInfoInternal.java new file mode 100644 index 000000000000..fa34e0b4f0f2 --- /dev/null +++ b/core/java/android/hardware/biometrics/ComponentInfoInternal.java @@ -0,0 +1,100 @@ +/* + * 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; + } +} diff --git a/core/java/android/hardware/biometrics/SensorProperties.java b/core/java/android/hardware/biometrics/SensorProperties.java index 360f138815c0..3b9cad49250f 100644 --- a/core/java/android/hardware/biometrics/SensorProperties.java +++ b/core/java/android/hardware/biometrics/SensorProperties.java @@ -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; } /** @@ -83,10 +164,23 @@ public class SensorProperties { } /** + * @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); } } diff --git a/core/java/android/hardware/biometrics/SensorPropertiesInternal.java b/core/java/android/hardware/biometrics/SensorPropertiesInternal.java index 909f456dd433..eda0ded42cdd 100644 --- a/core/java/android/hardware/biometrics/SensorPropertiesInternal.java +++ b/core/java/android/hardware/biometrics/SensorPropertiesInternal.java @@ -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(); } } diff --git a/core/java/android/hardware/face/FaceSensorProperties.java b/core/java/android/hardware/face/FaceSensorProperties.java index e61d93166cc5..6ddea5017088 100644 --- a/core/java/android/hardware/face/FaceSensorProperties.java +++ b/core/java/android/hardware/face/FaceSensorProperties.java @@ -16,25 +16,75 @@ package android.hardware.face; +import android.annotation.IntDef; +import android.hardware.biometrics.ComponentInfoInternal; import android.hardware.biometrics.SensorProperties; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.util.ArrayList; +import java.util.List; + /** * Container for face sensor properties. * @hide */ public class FaceSensorProperties extends SensorProperties { + /** + * @hide + */ + public static final int TYPE_UNKNOWN = 0; + + /** + * @hide + */ + public static final int TYPE_RGB = 1; + + /** + * @hide + */ + public static final int TYPE_IR = 2; + + /** + * @hide + */ + @IntDef({TYPE_UNKNOWN, + TYPE_RGB, + TYPE_IR}) + @Retention(RetentionPolicy.SOURCE) + public @interface SensorType {} + + @FaceSensorProperties.SensorType + final int mSensorType; /** * @hide */ public static FaceSensorProperties from(FaceSensorPropertiesInternal internalProp) { - return new FaceSensorProperties(internalProp.sensorId, internalProp.sensorStrength); + final List<ComponentInfo> componentInfo = new ArrayList<>(); + for (ComponentInfoInternal internalComp : internalProp.componentInfo) { + componentInfo.add(ComponentInfo.from(internalComp)); + } + return new FaceSensorProperties(internalProp.sensorId, + internalProp.sensorStrength, + componentInfo, + internalProp.sensorType); } /** * @hide */ - public FaceSensorProperties(int sensorId, int sensorStrength) { - super(sensorId, sensorStrength); + public FaceSensorProperties(int sensorId, int sensorStrength, + List<ComponentInfo> componentInfo, @FaceSensorProperties.SensorType int sensorType) { + super(sensorId, sensorStrength, componentInfo); + mSensorType = sensorType; } + /** + * @hide + * @return The sensor's type. + */ + @FaceSensorProperties.SensorType + public int getSensorType() { + return mSensorType; + } } diff --git a/core/java/android/hardware/face/FaceSensorPropertiesInternal.java b/core/java/android/hardware/face/FaceSensorPropertiesInternal.java index 34cbcb417e1b..50ea60a2ff57 100644 --- a/core/java/android/hardware/face/FaceSensorPropertiesInternal.java +++ b/core/java/android/hardware/face/FaceSensorPropertiesInternal.java @@ -16,16 +16,24 @@ package android.hardware.face; +import android.hardware.biometrics.ComponentInfoInternal; import android.hardware.biometrics.SensorProperties; import android.hardware.biometrics.SensorPropertiesInternal; import android.os.Parcel; +import java.util.List; + /** * Container for face sensor properties. * @hide */ public class FaceSensorPropertiesInternal extends SensorPropertiesInternal { /** + * See {@link FaceSensorProperties.SensorType}. + */ + public final @FaceSensorProperties.SensorType int sensorType; + + /** * True if the sensor is able to perform generic face detection, without running the * matching algorithm, and without affecting the lockout counter. */ @@ -40,18 +48,21 @@ public class FaceSensorPropertiesInternal extends SensorPropertiesInternal { * Initializes SensorProperties with specified values */ public FaceSensorPropertiesInternal(int sensorId, @SensorProperties.Strength int strength, - int maxEnrollmentsPerUser, boolean supportsFaceDetection, + int maxEnrollmentsPerUser, List<ComponentInfoInternal> componentInfo, + @FaceSensorProperties.SensorType int sensorType, boolean supportsFaceDetection, boolean supportsSelfIllumination, boolean resetLockoutRequiresChallenge) { // resetLockout is managed by the HAL and requires a HardwareAuthToken for all face // HAL interfaces (IBiometricsFace@1.0 HIDL and IFace@1.0 AIDL). - super(sensorId, strength, maxEnrollmentsPerUser, - true /* resetLockoutRequiresHardwareAuthToken */, resetLockoutRequiresChallenge); + super(sensorId, strength, maxEnrollmentsPerUser, componentInfo, + true /* resetLockoutRequiresHardwareAuthToken */, resetLockoutRequiresChallenge); + this.sensorType = sensorType; this.supportsFaceDetection = supportsFaceDetection; this.supportsSelfIllumination = supportsSelfIllumination; } protected FaceSensorPropertiesInternal(Parcel in) { super(in); + sensorType = in.readInt(); supportsFaceDetection = in.readBoolean(); supportsSelfIllumination = in.readBoolean(); } @@ -77,12 +88,13 @@ public class FaceSensorPropertiesInternal extends SensorPropertiesInternal { @Override public void writeToParcel(Parcel dest, int flags) { super.writeToParcel(dest, flags); + dest.writeInt(sensorType); dest.writeBoolean(supportsFaceDetection); dest.writeBoolean(supportsSelfIllumination); } @Override public String toString() { - return "ID: " + sensorId + ", Strength: " + sensorStrength; + return "ID: " + sensorId + ", Strength: " + sensorStrength + ", Type: " + sensorType; } } diff --git a/core/java/android/hardware/fingerprint/FingerprintSensorProperties.java b/core/java/android/hardware/fingerprint/FingerprintSensorProperties.java index 684d7d9cf0a0..a3385752aaf3 100644 --- a/core/java/android/hardware/fingerprint/FingerprintSensorProperties.java +++ b/core/java/android/hardware/fingerprint/FingerprintSensorProperties.java @@ -17,10 +17,13 @@ package android.hardware.fingerprint; import android.annotation.IntDef; +import android.hardware.biometrics.ComponentInfoInternal; import android.hardware.biometrics.SensorProperties; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; +import java.util.ArrayList; +import java.util.List; /** * Container for fingerprint sensor properties. @@ -77,8 +80,13 @@ public class FingerprintSensorProperties extends SensorProperties { */ public static FingerprintSensorProperties from( FingerprintSensorPropertiesInternal internalProp) { + final List<ComponentInfo> componentInfo = new ArrayList<>(); + for (ComponentInfoInternal internalComp : internalProp.componentInfo) { + componentInfo.add(ComponentInfo.from(internalComp)); + } return new FingerprintSensorProperties(internalProp.sensorId, internalProp.sensorStrength, + componentInfo, internalProp.sensorType); } @@ -86,8 +94,8 @@ public class FingerprintSensorProperties extends SensorProperties { * @hide */ public FingerprintSensorProperties(int sensorId, int sensorStrength, - @SensorType int sensorType) { - super(sensorId, sensorStrength); + List<ComponentInfo> componentInfo, @SensorType int sensorType) { + super(sensorId, sensorStrength, componentInfo); mSensorType = sensorType; } diff --git a/core/java/android/hardware/fingerprint/FingerprintSensorPropertiesInternal.java b/core/java/android/hardware/fingerprint/FingerprintSensorPropertiesInternal.java index adc61a744f89..1b1337072f5e 100644 --- a/core/java/android/hardware/fingerprint/FingerprintSensorPropertiesInternal.java +++ b/core/java/android/hardware/fingerprint/FingerprintSensorPropertiesInternal.java @@ -21,10 +21,13 @@ import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_UDFP import android.annotation.NonNull; import android.content.Context; +import android.hardware.biometrics.ComponentInfoInternal; import android.hardware.biometrics.SensorProperties; import android.hardware.biometrics.SensorPropertiesInternal; import android.os.Parcel; +import java.util.List; + /** * Container for fingerprint sensor properties. * @hide @@ -59,6 +62,7 @@ public class FingerprintSensorPropertiesInternal extends SensorPropertiesInterna public FingerprintSensorPropertiesInternal(int sensorId, @SensorProperties.Strength int strength, int maxEnrollmentsPerUser, + List<ComponentInfoInternal> componentInfo, @FingerprintSensorProperties.SensorType int sensorType, boolean resetLockoutRequiresHardwareAuthToken, int sensorLocationX, int sensorLocationY, int sensorRadius) { @@ -66,8 +70,8 @@ public class FingerprintSensorPropertiesInternal extends SensorPropertiesInterna // required as it can only be generated/attested/verified by TEE components. // IFingerprint@1.0 handles lockout below the HAL, but does not require a challenge. See // the HAL interface for more details. - super(sensorId, strength, maxEnrollmentsPerUser, resetLockoutRequiresHardwareAuthToken, - false /* resetLockoutRequiresChallenge */); + super(sensorId, strength, maxEnrollmentsPerUser, componentInfo, + resetLockoutRequiresHardwareAuthToken, false /* resetLockoutRequiresChallenge */); this.sensorType = sensorType; this.sensorLocationX = sensorLocationX; this.sensorLocationY = sensorLocationY; @@ -79,10 +83,11 @@ public class FingerprintSensorPropertiesInternal extends SensorPropertiesInterna */ public FingerprintSensorPropertiesInternal(int sensorId, @SensorProperties.Strength int strength, int maxEnrollmentsPerUser, + List<ComponentInfoInternal> componentInfo, @FingerprintSensorProperties.SensorType int sensorType, boolean resetLockoutRequiresHardwareAuthToken) { // TODO(b/179175438): Value should be provided from the HAL - this(sensorId, strength, maxEnrollmentsPerUser, sensorType, + this(sensorId, strength, maxEnrollmentsPerUser, componentInfo, sensorType, resetLockoutRequiresHardwareAuthToken, 540 /* sensorLocationX */, 1636 /* sensorLocationY */, 130 /* sensorRadius */); } @@ -94,10 +99,11 @@ public class FingerprintSensorPropertiesInternal extends SensorPropertiesInterna // TODO(b/179175438): Remove this constructor once all HALs move to AIDL. public FingerprintSensorPropertiesInternal(@NonNull Context context, int sensorId, @SensorProperties.Strength int strength, int maxEnrollmentsPerUser, + List<ComponentInfoInternal> componentInfo, @FingerprintSensorProperties.SensorType int sensorType, boolean resetLockoutRequiresHardwareAuthToken) { - super(sensorId, strength, maxEnrollmentsPerUser, resetLockoutRequiresHardwareAuthToken, - false /* resetLockoutRequiresChallenge */); + super(sensorId, strength, maxEnrollmentsPerUser, componentInfo, + resetLockoutRequiresHardwareAuthToken, false /* resetLockoutRequiresChallenge */); this.sensorType = sensorType; int[] props = context.getResources().getIntArray( |
