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 android.annotation.IntDef; 20 import android.annotation.NonNull; 21 import android.hardware.biometrics.ComponentInfoInternal; 22 import android.hardware.biometrics.SensorProperties; 23 24 import java.lang.annotation.Retention; 25 import java.lang.annotation.RetentionPolicy; 26 import java.util.ArrayList; 27 import java.util.List; 28 29 /** 30 * Container for fingerprint sensor properties. 31 * @hide 32 */ 33 public class FingerprintSensorProperties extends SensorProperties { 34 /** 35 * @hide 36 */ 37 public static final int TYPE_UNKNOWN = 0; 38 39 /** 40 * @hide 41 */ 42 public static final int TYPE_REAR = 1; 43 44 /** 45 * @hide 46 */ 47 public static final int TYPE_UDFPS_ULTRASONIC = 2; 48 49 /** 50 * @hide 51 */ 52 public static final int TYPE_UDFPS_OPTICAL = 3; 53 54 /** 55 * @hide 56 */ 57 public static final int TYPE_POWER_BUTTON = 4; 58 59 /** 60 * @hide 61 */ 62 public static final int TYPE_HOME_BUTTON = 5; 63 64 /** 65 * @hide 66 */ 67 @IntDef({TYPE_UNKNOWN, 68 TYPE_REAR, 69 TYPE_UDFPS_ULTRASONIC, 70 TYPE_UDFPS_OPTICAL, 71 TYPE_POWER_BUTTON, 72 TYPE_HOME_BUTTON}) 73 @Retention(RetentionPolicy.SOURCE) 74 public @interface SensorType {} 75 76 @SensorType final int mSensorType; 77 78 /** 79 * Constructs a {@link FingerprintSensorProperties} from the internal parcelable representation. 80 * @hide 81 */ from( FingerprintSensorPropertiesInternal internalProp)82 public static FingerprintSensorProperties from( 83 FingerprintSensorPropertiesInternal internalProp) { 84 final List<ComponentInfo> componentInfo = new ArrayList<>(); 85 for (ComponentInfoInternal internalComp : internalProp.componentInfo) { 86 componentInfo.add(ComponentInfo.from(internalComp)); 87 } 88 return new FingerprintSensorProperties(internalProp.sensorId, 89 internalProp.sensorStrength, 90 componentInfo, 91 internalProp.sensorType); 92 } 93 94 /** 95 * @hide 96 */ FingerprintSensorProperties(int sensorId, int sensorStrength, @NonNull List<ComponentInfo> componentInfo, @SensorType int sensorType)97 public FingerprintSensorProperties(int sensorId, int sensorStrength, 98 @NonNull List<ComponentInfo> componentInfo, @SensorType int sensorType) { 99 super(sensorId, sensorStrength, componentInfo); 100 mSensorType = sensorType; 101 } 102 103 /** 104 * @hide 105 * @return The sensor's type. 106 */ 107 @SensorType getSensorType()108 public int getSensorType() { 109 return mSensorType; 110 } 111 } 112