• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.hardware.fingerprint;
18 
19 import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_POWER_BUTTON;
20 import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_UDFPS_OPTICAL;
21 import static android.hardware.fingerprint.FingerprintSensorProperties.TYPE_UDFPS_ULTRASONIC;
22 
23 import android.annotation.NonNull;
24 import android.hardware.biometrics.ComponentInfoInternal;
25 import android.hardware.biometrics.SensorProperties;
26 import android.hardware.biometrics.SensorPropertiesInternal;
27 import android.os.Parcel;
28 
29 import java.util.List;
30 
31 /**
32  * Container for fingerprint sensor properties.
33  * @hide
34  */
35 public class FingerprintSensorPropertiesInternal extends SensorPropertiesInternal {
36     /**
37      * See {@link FingerprintSensorProperties.SensorType}.
38      */
39     public final @FingerprintSensorProperties.SensorType int sensorType;
40 
41     /**
42      * The location of the center of the sensor if applicable. For example, sensors of type
43      * {@link FingerprintSensorProperties#TYPE_UDFPS_OPTICAL} would report this value as the
44      * distance in pixels, measured from the left edge of the screen.
45      */
46     public final int sensorLocationX;
47 
48     /**
49      * The location of the center of the sensor if applicable. For example, sensors of type
50      * {@link FingerprintSensorProperties#TYPE_UDFPS_OPTICAL} would report this value as the
51      * distance in pixels, measured from the top edge of the screen.
52      *
53      */
54     public final int sensorLocationY;
55 
56     /**
57      * The radius of the sensor if applicable. For example, sensors of type
58      * {@link FingerprintSensorProperties#TYPE_UDFPS_OPTICAL} would report this value as the radius
59      * of the sensor, in pixels.
60      */
61     public final int sensorRadius;
62 
FingerprintSensorPropertiesInternal(int sensorId, @SensorProperties.Strength int strength, int maxEnrollmentsPerUser, @NonNull List<ComponentInfoInternal> componentInfo, @FingerprintSensorProperties.SensorType int sensorType, boolean resetLockoutRequiresHardwareAuthToken, int sensorLocationX, int sensorLocationY, int sensorRadius)63     public FingerprintSensorPropertiesInternal(int sensorId,
64             @SensorProperties.Strength int strength, int maxEnrollmentsPerUser,
65             @NonNull List<ComponentInfoInternal> componentInfo,
66             @FingerprintSensorProperties.SensorType int sensorType,
67             boolean resetLockoutRequiresHardwareAuthToken, int sensorLocationX, int sensorLocationY,
68             int sensorRadius) {
69         // IBiometricsFingerprint@2.1 handles lockout in the framework, so the challenge is not
70         // required as it can only be generated/attested/verified by TEE components.
71         // IFingerprint@1.0 handles lockout below the HAL, but does not require a challenge. See
72         // the HAL interface for more details.
73         super(sensorId, strength, maxEnrollmentsPerUser, componentInfo,
74             resetLockoutRequiresHardwareAuthToken, false /* resetLockoutRequiresChallenge */);
75         this.sensorType = sensorType;
76         this.sensorLocationX = sensorLocationX;
77         this.sensorLocationY = sensorLocationY;
78         this.sensorRadius = sensorRadius;
79     }
80 
81     /**
82      * Initializes SensorProperties with specified values
83      */
FingerprintSensorPropertiesInternal(int sensorId, @SensorProperties.Strength int strength, int maxEnrollmentsPerUser, @NonNull List<ComponentInfoInternal> componentInfo, @FingerprintSensorProperties.SensorType int sensorType, boolean resetLockoutRequiresHardwareAuthToken)84     public FingerprintSensorPropertiesInternal(int sensorId,
85             @SensorProperties.Strength int strength, int maxEnrollmentsPerUser,
86             @NonNull List<ComponentInfoInternal> componentInfo,
87             @FingerprintSensorProperties.SensorType int sensorType,
88             boolean resetLockoutRequiresHardwareAuthToken) {
89         // TODO(b/179175438): Value should be provided from the HAL
90         this(sensorId, strength, maxEnrollmentsPerUser, componentInfo, sensorType,
91                 resetLockoutRequiresHardwareAuthToken, 540 /* sensorLocationX */,
92                 1636 /* sensorLocationY */, 130 /* sensorRadius */);
93     }
94 
FingerprintSensorPropertiesInternal(Parcel in)95     protected FingerprintSensorPropertiesInternal(Parcel in) {
96         super(in);
97         sensorType = in.readInt();
98         sensorLocationX = in.readInt();
99         sensorLocationY = in.readInt();
100         sensorRadius = in.readInt();
101     }
102 
103     public static final Creator<FingerprintSensorPropertiesInternal> CREATOR =
104             new Creator<FingerprintSensorPropertiesInternal>() {
105                 @Override
106                 public FingerprintSensorPropertiesInternal createFromParcel(Parcel in) {
107                     return new FingerprintSensorPropertiesInternal(in);
108                 }
109 
110                 @Override
111                 public FingerprintSensorPropertiesInternal[] newArray(int size) {
112                     return new FingerprintSensorPropertiesInternal[size];
113                 }
114             };
115 
116     @Override
describeContents()117     public int describeContents() {
118         return 0;
119     }
120 
121     @Override
writeToParcel(Parcel dest, int flags)122     public void writeToParcel(Parcel dest, int flags) {
123         super.writeToParcel(dest, flags);
124         dest.writeInt(sensorType);
125         dest.writeInt(sensorLocationX);
126         dest.writeInt(sensorLocationY);
127         dest.writeInt(sensorRadius);
128     }
129 
isAnyUdfpsType()130     public boolean isAnyUdfpsType() {
131         switch (sensorType) {
132             case TYPE_UDFPS_OPTICAL:
133             case TYPE_UDFPS_ULTRASONIC:
134                 return true;
135             default:
136                 return false;
137         }
138     }
139 
140     /**
141      * Returns if sensor type is side-FPS
142      * @return true if sensor is side-fps, false otherwise
143      */
isAnySidefpsType()144     public boolean isAnySidefpsType() {
145         switch (sensorType) {
146             case TYPE_POWER_BUTTON:
147                 return true;
148             default:
149                 return false;
150         }
151     }
152 
153     @Override
toString()154     public String toString() {
155         return "ID: " + sensorId + ", Strength: " + sensorStrength + ", Type: " + sensorType;
156     }
157 }
158