1 /* 2 * Copyright (C) 2018 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.biometrics; 18 19 import android.annotation.IntDef; 20 import android.app.KeyguardManager; 21 import android.compat.annotation.UnsupportedAppUsage; 22 import android.hardware.biometrics.BiometricManager.Authenticators; 23 import android.hardware.fingerprint.FingerprintManager; 24 import android.os.Build; 25 26 import java.lang.annotation.Retention; 27 import java.lang.annotation.RetentionPolicy; 28 29 /** 30 * Interface containing all of the fingerprint-specific constants. 31 * 32 * NOTE: The error messages must be consistent between BiometricConstants, Biometric*Constants, 33 * and the frameworks/support/biometric/.../BiometricConstants files. 34 * 35 * @hide 36 */ 37 public interface BiometricFingerprintConstants { 38 // 39 // Error messages from fingerprint hardware during initilization, enrollment, authentication or 40 // removal. Must agree with the list in fingerprint.h 41 // 42 43 /** 44 * @hide 45 */ 46 @IntDef({FINGERPRINT_ERROR_HW_UNAVAILABLE, 47 FINGERPRINT_ERROR_UNABLE_TO_PROCESS, 48 FINGERPRINT_ERROR_TIMEOUT, 49 FINGERPRINT_ERROR_NO_SPACE, 50 FINGERPRINT_ERROR_CANCELED, 51 FINGERPRINT_ERROR_UNABLE_TO_REMOVE, 52 FINGERPRINT_ERROR_LOCKOUT, 53 FINGERPRINT_ERROR_VENDOR, 54 FINGERPRINT_ERROR_LOCKOUT_PERMANENT, 55 FINGERPRINT_ERROR_USER_CANCELED, 56 FINGERPRINT_ERROR_NO_FINGERPRINTS, 57 FINGERPRINT_ERROR_HW_NOT_PRESENT, 58 FINGERPRINT_ERROR_NEGATIVE_BUTTON, 59 BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL, 60 BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED, 61 BIOMETRIC_ERROR_RE_ENROLL, 62 BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED, 63 FINGERPRINT_ERROR_UNKNOWN, 64 FINGERPRINT_ERROR_BAD_CALIBRATION, 65 BIOMETRIC_ERROR_POWER_PRESSED}) 66 @Retention(RetentionPolicy.SOURCE) 67 @interface FingerprintError {} 68 69 /** 70 * The hardware is unavailable. Try again later. 71 */ 72 int FINGERPRINT_ERROR_HW_UNAVAILABLE = 1; 73 74 /** 75 * Error state returned when the sensor was unable to process the current image. 76 */ 77 int FINGERPRINT_ERROR_UNABLE_TO_PROCESS = 2; 78 79 /** 80 * Error state returned when the current request has been running too long. This is intended to 81 * prevent programs from waiting for the fingerprint sensor indefinitely. The timeout is 82 * platform and sensor-specific, but is generally on the order of 30 seconds. 83 */ 84 int FINGERPRINT_ERROR_TIMEOUT = 3; 85 86 /** 87 * Error state returned for operations like enrollment; the operation cannot be completed 88 * because there's not enough storage remaining to complete the operation. 89 */ 90 int FINGERPRINT_ERROR_NO_SPACE = 4; 91 92 /** 93 * The operation was canceled because the fingerprint sensor is unavailable. For example, 94 * this may happen when the user is switched, the device is locked or another pending operation 95 * prevents or disables it. 96 */ 97 int FINGERPRINT_ERROR_CANCELED = 5; 98 99 /** 100 * The {@link FingerprintManager#remove} call failed. Typically this will happen when the 101 * provided fingerprint id was incorrect. 102 * 103 * @hide 104 */ 105 int FINGERPRINT_ERROR_UNABLE_TO_REMOVE = 6; 106 107 /** 108 * The operation was canceled because the API is locked out due to too many attempts. 109 * This occurs after 5 failed attempts, and lasts for 30 seconds. 110 */ 111 int FINGERPRINT_ERROR_LOCKOUT = 7; 112 113 /** 114 * Hardware vendors may extend this list if there are conditions that do not fall under one of 115 * the above categories. Vendors are responsible for providing error strings for these errors. 116 * These messages are typically reserved for internal operations such as enrollment, but may be 117 * used to express vendor errors not covered by the ones in fingerprint.h. Applications are 118 * expected to show the error message string if they happen, but are advised not to rely on the 119 * message id since they will be device and vendor-specific 120 */ 121 int FINGERPRINT_ERROR_VENDOR = 8; 122 123 /** 124 * The operation was canceled because FINGERPRINT_ERROR_LOCKOUT occurred too many times. 125 * Fingerprint authentication is disabled until the user unlocks with strong authentication 126 * (PIN/Pattern/Password) 127 */ 128 int FINGERPRINT_ERROR_LOCKOUT_PERMANENT = 9; 129 130 /** 131 * The user canceled the operation. Upon receiving this, applications should use alternate 132 * authentication (e.g. a password). The application should also provide the means to return 133 * to fingerprint authentication, such as a "use fingerprint" button. 134 */ 135 int FINGERPRINT_ERROR_USER_CANCELED = 10; 136 137 /** 138 * The user does not have any fingerprints enrolled. 139 */ 140 int FINGERPRINT_ERROR_NO_FINGERPRINTS = 11; 141 142 /** 143 * The device does not have a fingerprint sensor. 144 */ 145 int FINGERPRINT_ERROR_HW_NOT_PRESENT = 12; 146 147 /** 148 * The user pressed the negative button. This is a placeholder that is currently only used 149 * by the support library. 150 * 151 * @hide 152 */ 153 int FINGERPRINT_ERROR_NEGATIVE_BUTTON = 13; 154 155 /** 156 * The device does not have pin, pattern, or password set up. See 157 * {@link BiometricPrompt.Builder#setDeviceCredentialAllowed(boolean)} and 158 * {@link KeyguardManager#isDeviceSecure()} 159 * 160 * @hide 161 */ 162 int BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL = 14; 163 164 /** 165 * A security vulnerability has been discovered and the sensor is unavailable until a 166 * security update has addressed this issue. This error can be received if for example, 167 * authentication was requested with {@link Authenticators#BIOMETRIC_STRONG}, but the 168 * sensor's strength can currently only meet {@link Authenticators#BIOMETRIC_WEAK}. 169 * @hide 170 */ 171 int BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED = 15; 172 173 /** 174 * Authentication cannot proceed because re-enrollment is required. 175 * @hide 176 */ 177 int BIOMETRIC_ERROR_RE_ENROLL = 16; 178 179 /** 180 * Unknown error received from the HAL. 181 * @hide 182 */ 183 int FINGERPRINT_ERROR_UNKNOWN = 17; 184 185 /** 186 * Error indicating that the fingerprint sensor has bad calibration. 187 * @hide 188 */ 189 int FINGERPRINT_ERROR_BAD_CALIBRATION = 18; 190 191 /** 192 * A power press stopped this biometric operation. 193 * @hide 194 */ 195 int BIOMETRIC_ERROR_POWER_PRESSED = 19; 196 197 /** 198 * @hide 199 */ 200 @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) 201 int FINGERPRINT_ERROR_VENDOR_BASE = 1000; 202 203 // 204 // Image acquisition messages. Must agree with those in fingerprint.h 205 // 206 207 /** 208 * @hide 209 */ 210 @IntDef({FINGERPRINT_ACQUIRED_GOOD, 211 FINGERPRINT_ACQUIRED_PARTIAL, 212 FINGERPRINT_ACQUIRED_INSUFFICIENT, 213 FINGERPRINT_ACQUIRED_IMAGER_DIRTY, 214 FINGERPRINT_ACQUIRED_TOO_SLOW, 215 FINGERPRINT_ACQUIRED_TOO_FAST, 216 FINGERPRINT_ACQUIRED_VENDOR, 217 FINGERPRINT_ACQUIRED_START, 218 FINGERPRINT_ACQUIRED_UNKNOWN, 219 FINGERPRINT_ACQUIRED_IMMOBILE, 220 FINGERPRINT_ACQUIRED_TOO_BRIGHT, 221 FINGERPRINT_ACQUIRED_POWER_PRESSED, 222 FINGERPRINT_ACQUIRED_RE_ENROLL}) 223 @Retention(RetentionPolicy.SOURCE) 224 @interface FingerprintAcquired {} 225 226 /** 227 * The image acquired was good. 228 */ 229 int FINGERPRINT_ACQUIRED_GOOD = 0; 230 231 /** 232 * Only a partial fingerprint image was detected. During enrollment, the user should be 233 * informed on what needs to happen to resolve this problem, e.g. "press firmly on sensor." 234 */ 235 int FINGERPRINT_ACQUIRED_PARTIAL = 1; 236 237 /** 238 * The fingerprint image was too noisy to process due to a detected condition (i.e. dry skin) or 239 * a possibly dirty sensor (See {@link #FINGERPRINT_ACQUIRED_IMAGER_DIRTY}). 240 */ 241 int FINGERPRINT_ACQUIRED_INSUFFICIENT = 2; 242 243 /** 244 * The fingerprint image was too noisy due to suspected or detected dirt on the sensor. 245 * For example, it's reasonable return this after multiple 246 * {@link #FINGERPRINT_ACQUIRED_INSUFFICIENT} or actual detection of dirt on the sensor 247 * (stuck pixels, swaths, etc.). The user is expected to take action to clean the sensor 248 * when this is returned. 249 */ 250 int FINGERPRINT_ACQUIRED_IMAGER_DIRTY = 3; 251 252 /** 253 * The fingerprint image was unreadable due to lack of motion. This is most appropriate for 254 * linear array sensors that require a swipe motion. 255 */ 256 int FINGERPRINT_ACQUIRED_TOO_SLOW = 4; 257 258 /** 259 * The fingerprint image was incomplete due to quick motion. While mostly appropriate for 260 * linear array sensors, this could also happen if the finger was moved during acquisition. 261 * The user should be asked to move the finger slower (linear) or leave the finger on the sensor 262 * longer. 263 */ 264 int FINGERPRINT_ACQUIRED_TOO_FAST = 5; 265 266 /** 267 * Hardware vendors may extend this list if there are conditions that do not fall under one of 268 * the above categories. Vendors are responsible for providing error strings for these errors. 269 * 270 * @hide 271 */ 272 int FINGERPRINT_ACQUIRED_VENDOR = 6; 273 274 /** 275 * This message represents the earliest message sent at the beginning of the authentication 276 * pipeline. It is expected to be used to measure latency. Note this should be sent whenever 277 * authentication is restarted. 278 * The framework will measure latency based on the time between the last START message and the 279 * onAuthenticated callback. 280 * 281 * @hide 282 */ 283 int FINGERPRINT_ACQUIRED_START = 7; 284 285 /** 286 * Unknown acquired code received from the HAL. 287 * @hide 288 */ 289 int FINGERPRINT_ACQUIRED_UNKNOWN = 8; 290 291 /** 292 * This message may be sent during enrollment if the same area of the finger has already 293 * been captured during this enrollment session. In general, enrolling multiple areas of the 294 * same finger can help against false rejections. 295 * @hide 296 */ 297 int FINGERPRINT_ACQUIRED_IMMOBILE = 9; 298 299 /** 300 * For sensors that require illumination, such as optical under-display fingerprint sensors, 301 * the image was too bright to be used for matching. 302 * @hide 303 */ 304 int FINGERPRINT_ACQUIRED_TOO_BRIGHT = 10; 305 306 /** 307 * For sensors that have the power button co-located with their sensor, this event will 308 * be sent during enrollment. 309 * @hide 310 */ 311 int FINGERPRINT_ACQUIRED_POWER_PRESSED = 11; 312 313 /** 314 * This message is sent to encourage the user to re-enroll their fingerprints. 315 * @hide 316 */ 317 int FINGERPRINT_ACQUIRED_RE_ENROLL = 12; 318 319 /** 320 * @hide 321 */ 322 int FINGERPRINT_ACQUIRED_VENDOR_BASE = 1000; 323 324 /** 325 * Whether the FingerprintAcquired message is a signal to disable the UDFPS display mode. 326 * We want to disable the UDFPS mode as soon as possible to conserve power and provide better 327 * UX. For example, prolonged high-brightness illumination of optical sensors can be unpleasant 328 * to the user, can cause long term display burn-in, and can drain the battery faster. 329 */ shouldDisableUdfpsDisplayMode(@ingerprintAcquired int acquiredInfo)330 static boolean shouldDisableUdfpsDisplayMode(@FingerprintAcquired int acquiredInfo) { 331 switch (acquiredInfo) { 332 case FINGERPRINT_ACQUIRED_START: 333 // Keep the UDFPS mode because the authentication just began. 334 return false; 335 case FINGERPRINT_ACQUIRED_GOOD: 336 case FINGERPRINT_ACQUIRED_PARTIAL: 337 case FINGERPRINT_ACQUIRED_INSUFFICIENT: 338 case FINGERPRINT_ACQUIRED_IMAGER_DIRTY: 339 case FINGERPRINT_ACQUIRED_TOO_SLOW: 340 case FINGERPRINT_ACQUIRED_TOO_FAST: 341 case FINGERPRINT_ACQUIRED_IMMOBILE: 342 case FINGERPRINT_ACQUIRED_TOO_BRIGHT: 343 case FINGERPRINT_ACQUIRED_VENDOR: 344 // Disable the UDFPS mode because the image capture has finished. The overlay 345 // can be hidden later, once the authentication result arrives. 346 return true; 347 case FINGERPRINT_ACQUIRED_UNKNOWN: 348 default: 349 // Keep the UDFPS mode in case of an unknown message. 350 return false; 351 } 352 } 353 } 354