| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 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.annotation.Nullable; |
| 25 |
import android.hardware.biometrics.ComponentInfoInternal; |
| 26 |
import android.hardware.biometrics.SensorLocationInternal; |
| 27 |
import android.hardware.biometrics.SensorProperties; |
| 28 |
import android.hardware.biometrics.SensorPropertiesInternal; |
| 29 |
import android.os.Parcel; |
| 30 |
|
| 31 |
import java.util.List; |
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
public class FingerprintSensorPropertiesInternal extends SensorPropertiesInternal { |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
public final @FingerprintSensorProperties.SensorType int sensorType; |
| 42 |
public final boolean halControlsIllumination; |
| 43 |
|
| 44 |
private final List<SensorLocationInternal> mSensorLocations; |
| 45 |
|
| 46 |
public FingerprintSensorPropertiesInternal(int sensorId, |
| 47 |
@SensorProperties.Strength int strength, int maxEnrollmentsPerUser, |
| 48 |
@NonNull List<ComponentInfoInternal> componentInfo, |
| 49 |
@FingerprintSensorProperties.SensorType int sensorType, |
| 50 |
boolean halControlsIllumination, |
| 51 |
boolean resetLockoutRequiresHardwareAuthToken, |
| 52 |
@NonNull List<SensorLocationInternal> sensorLocations) { |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
super(sensorId, strength, maxEnrollmentsPerUser, componentInfo, |
| 58 |
resetLockoutRequiresHardwareAuthToken, false ); |
| 59 |
this.sensorType = sensorType; |
| 60 |
this.halControlsIllumination = halControlsIllumination; |
| 61 |
this.mSensorLocations = List.copyOf(sensorLocations); |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
public FingerprintSensorPropertiesInternal(int sensorId, |
| 68 |
@SensorProperties.Strength int strength, int maxEnrollmentsPerUser, |
| 69 |
@NonNull List<ComponentInfoInternal> componentInfo, |
| 70 |
@FingerprintSensorProperties.SensorType int sensorType, |
| 71 |
boolean resetLockoutRequiresHardwareAuthToken) { |
| 72 |
|
| 73 |
this(sensorId, strength, maxEnrollmentsPerUser, componentInfo, sensorType, |
| 74 |
false , resetLockoutRequiresHardwareAuthToken, |
| 75 |
List.of(new SensorLocationInternal("" , 540 , |
| 76 |
1636 , 130 ))); |
| 77 |
} |
| 78 |
|
| 79 |
protected FingerprintSensorPropertiesInternal(Parcel in) { |
| 80 |
super(in); |
| 81 |
sensorType = in.readInt(); |
| 82 |
halControlsIllumination = in.readBoolean(); |
| 83 |
mSensorLocations = in.createTypedArrayList(SensorLocationInternal.CREATOR); |
| 84 |
} |
| 85 |
|
| 86 |
public static final Creator<FingerprintSensorPropertiesInternal> CREATOR = |
| 87 |
new Creator<FingerprintSensorPropertiesInternal>() { |
| 88 |
@Override |
| 89 |
public FingerprintSensorPropertiesInternal createFromParcel(Parcel in) { |
| 90 |
return new FingerprintSensorPropertiesInternal(in); |
| 91 |
} |
| 92 |
|
| 93 |
@Override |
| 94 |
public FingerprintSensorPropertiesInternal[] newArray(int size) { |
| 95 |
return new FingerprintSensorPropertiesInternal[size]; |
| 96 |
} |
| 97 |
}; |
| 98 |
|
| 99 |
@Override |
| 100 |
public int describeContents() { |
| 101 |
return 0; |
| 102 |
} |
| 103 |
|
| 104 |
@Override |
| 105 |
public void writeToParcel(Parcel dest, int flags) { |
| 106 |
super.writeToParcel(dest, flags); |
| 107 |
dest.writeInt(sensorType); |
| 108 |
dest.writeBoolean(halControlsIllumination); |
| 109 |
dest.writeTypedList(mSensorLocations); |
| 110 |
} |
| 111 |
|
| 112 |
public boolean isAnyUdfpsType() { |
| 113 |
switch (sensorType) { |
| 114 |
case TYPE_UDFPS_OPTICAL: |
| 115 |
case TYPE_UDFPS_ULTRASONIC: |
| 116 |
return true; |
| 117 |
default: |
| 118 |
return false; |
| 119 |
} |
| 120 |
} |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
public boolean isAnySidefpsType() { |
| 127 |
switch (sensorType) { |
| 128 |
case TYPE_POWER_BUTTON: |
| 129 |
return true; |
| 130 |
default: |
| 131 |
return false; |
| 132 |
} |
| 133 |
} |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
@NonNull |
| 143 |
public SensorLocationInternal getLocation() { |
| 144 |
final SensorLocationInternal location = getLocation("" ); |
| 145 |
return location != null ? location : SensorLocationInternal.DEFAULT; |
| 146 |
} |
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
@Nullable |
| 155 |
public SensorLocationInternal getLocation(String displayId) { |
| 156 |
for (SensorLocationInternal location : mSensorLocations) { |
| 157 |
if (location.displayId.equals(displayId)) { |
| 158 |
return location; |
| 159 |
} |
| 160 |
} |
| 161 |
return null; |
| 162 |
} |
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
@NonNull |
| 169 |
public List<SensorLocationInternal> getAllLocations() { |
| 170 |
return mSensorLocations; |
| 171 |
} |
| 172 |
|
| 173 |
@Override |
| 174 |
public String toString() { |
| 175 |
return "ID: " + sensorId + ", Strength: " + sensorStrength + ", Type: " + sensorType; |
| 176 |
} |
| 177 |
} |