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.app.KeyguardManager; 20 import android.compat.annotation.UnsupportedAppUsage; 21 22 23 /** 24 * Interface containing all of the biometric modality agnostic constants. 25 * 26 * NOTE: The error messages must be consistent between BiometricConstants, Biometric*Constants, 27 * and the frameworks/support/biometric/.../BiometricConstants files. 28 * 29 * @hide 30 */ 31 public interface BiometricConstants { 32 // 33 // Error messages from biometric hardware during initilization, enrollment, authentication or 34 // removal. 35 // 36 37 /** 38 * This was not added here since it would update BiometricPrompt API. But, is used in 39 * BiometricManager. 40 * @hide 41 */ 42 int BIOMETRIC_SUCCESS = 0; 43 44 /** 45 * The hardware is unavailable. Try again later. 46 */ 47 int BIOMETRIC_ERROR_HW_UNAVAILABLE = 1; 48 49 /** 50 * Error state returned when the sensor was unable to process the current image. 51 */ 52 int BIOMETRIC_ERROR_UNABLE_TO_PROCESS = 2; 53 54 /** 55 * Error state returned when the current request has been running too long. This is intended to 56 * prevent programs from waiting for the biometric sensor indefinitely. The timeout is platform 57 * and sensor-specific, but is generally on the order of 30 seconds. 58 */ 59 int BIOMETRIC_ERROR_TIMEOUT = 3; 60 61 /** 62 * Error state returned for operations like enrollment; the operation cannot be completed 63 * because there's not enough storage remaining to complete the operation. 64 */ 65 int BIOMETRIC_ERROR_NO_SPACE = 4; 66 67 /** 68 * The operation was canceled because the biometric sensor is unavailable. For example, this may 69 * happen when the user is switched, the device is locked or another pending operation prevents 70 * or disables it. 71 */ 72 int BIOMETRIC_ERROR_CANCELED = 5; 73 74 /** 75 * The {@link BiometricManager#remove} call failed. Typically this will happen when the provided 76 * biometric id was incorrect. 77 * 78 * @hide 79 */ 80 int BIOMETRIC_ERROR_UNABLE_TO_REMOVE = 6; 81 82 /** 83 * The operation was canceled because the API is locked out due to too many attempts. 84 * This occurs after 5 failed attempts, and lasts for 30 seconds. 85 */ 86 int BIOMETRIC_ERROR_LOCKOUT = 7; 87 88 /** 89 * Hardware vendors may extend this list if there are conditions that do not fall under one of 90 * the above categories. Vendors are responsible for providing error strings for these errors. 91 * These messages are typically reserved for internal operations such as enrollment, but may be 92 * used to express vendor errors not otherwise covered. Applications are expected to show the 93 * error message string if they happen, but are advised not to rely on the message id since they 94 * will be device and vendor-specific 95 */ 96 int BIOMETRIC_ERROR_VENDOR = 8; 97 98 /** 99 * The operation was canceled because BIOMETRIC_ERROR_LOCKOUT occurred too many times. 100 * Biometric authentication is disabled until the user unlocks with strong authentication 101 * (PIN/Pattern/Password) 102 */ 103 int BIOMETRIC_ERROR_LOCKOUT_PERMANENT = 9; 104 105 /** 106 * The user canceled the operation. Upon receiving this, applications should use alternate 107 * authentication (e.g. a password). The application should also provide the means to return to 108 * biometric authentication, such as a "use <biometric>" button. 109 */ 110 int BIOMETRIC_ERROR_USER_CANCELED = 10; 111 112 /** 113 * The user does not have any biometrics enrolled. 114 */ 115 int BIOMETRIC_ERROR_NO_BIOMETRICS = 11; 116 117 /** 118 * The device does not have a biometric sensor. 119 */ 120 int BIOMETRIC_ERROR_HW_NOT_PRESENT = 12; 121 122 /** 123 * The user pressed the negative button. This is a placeholder that is currently only used 124 * by the support library. 125 * @hide 126 */ 127 int BIOMETRIC_ERROR_NEGATIVE_BUTTON = 13; 128 129 /** 130 * The device does not have pin, pattern, or password set up. See 131 * {@link BiometricPrompt.Builder#setDeviceCredentialAllowed(boolean)} and 132 * {@link KeyguardManager#isDeviceSecure()} 133 */ 134 int BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL = 14; 135 136 /** 137 * @hide 138 */ 139 @UnsupportedAppUsage 140 int BIOMETRIC_ERROR_VENDOR_BASE = 1000; 141 142 // 143 // Image acquisition messages. 144 // 145 146 /** 147 * The image acquired was good. 148 */ 149 int BIOMETRIC_ACQUIRED_GOOD = 0; 150 151 /** 152 * Only a partial biometric image was detected. During enrollment, the user should be informed 153 * on what needs to happen to resolve this problem, e.g. "press firmly on sensor." (for 154 * fingerprint) 155 */ 156 int BIOMETRIC_ACQUIRED_PARTIAL = 1; 157 158 /** 159 * The biometric image was too noisy to process due to a detected condition or a possibly dirty 160 * sensor (See {@link #BIOMETRIC_ACQUIRED_IMAGER_DIRTY}). 161 */ 162 int BIOMETRIC_ACQUIRED_INSUFFICIENT = 2; 163 164 /** 165 * The biometric image was too noisy due to suspected or detected dirt on the sensor. For 166 * example, it's reasonable return this after multiple {@link #BIOMETRIC_ACQUIRED_INSUFFICIENT} 167 * or actual detection of dirt on the sensor (stuck pixels, swaths, etc.). The user is expected 168 * to take action to clean the sensor when this is returned. 169 */ 170 int BIOMETRIC_ACQUIRED_IMAGER_DIRTY = 3; 171 172 /** 173 * The biometric image was unreadable due to lack of motion. 174 */ 175 int BIOMETRIC_ACQUIRED_TOO_SLOW = 4; 176 177 /** 178 * The biometric image was incomplete due to quick motion. For example, this could also happen 179 * if the user moved during acquisition. The user should be asked to repeat the operation more 180 * slowly. 181 */ 182 int BIOMETRIC_ACQUIRED_TOO_FAST = 5; 183 184 /** 185 * Hardware vendors may extend this list if there are conditions that do not fall under one of 186 * the above categories. Vendors are responsible for providing error strings for these errors. 187 * @hide 188 */ 189 int BIOMETRIC_ACQUIRED_VENDOR = 6; 190 /** 191 * @hide 192 */ 193 int BIOMETRIC_ACQUIRED_VENDOR_BASE = 1000; 194 } 195