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 static android.hardware.biometrics.BiometricManager.Authenticators; 20 21 import android.compat.annotation.UnsupportedAppUsage; 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 * OEMs should use this constant if there are conditions that do not fit under any of the other 90 * publicly defined constants, and must provide appropriate strings for these 91 * errors to the {@link BiometricPrompt.AuthenticationCallback#onAuthenticationError(int, 92 * CharSequence)} callback. OEMs should expect that the error message will be shown to users. 93 */ 94 int BIOMETRIC_ERROR_VENDOR = 8; 95 96 /** 97 * The operation was canceled because BIOMETRIC_ERROR_LOCKOUT occurred too many times. 98 * Biometric authentication is disabled until the user unlocks with strong authentication 99 * (PIN/Pattern/Password) 100 */ 101 int BIOMETRIC_ERROR_LOCKOUT_PERMANENT = 9; 102 103 /** 104 * The user canceled the operation. Upon receiving this, applications should use alternate 105 * authentication (e.g. a password). The application should also provide the means to return to 106 * biometric authentication, such as a "use <biometric>" button. 107 */ 108 int BIOMETRIC_ERROR_USER_CANCELED = 10; 109 110 /** 111 * The user does not have any biometrics enrolled. 112 */ 113 int BIOMETRIC_ERROR_NO_BIOMETRICS = 11; 114 115 /** 116 * The device does not have a biometric sensor. 117 */ 118 int BIOMETRIC_ERROR_HW_NOT_PRESENT = 12; 119 120 /** 121 * The user pressed the negative button. This is a placeholder that is currently only used 122 * by the support library. 123 * @hide 124 */ 125 int BIOMETRIC_ERROR_NEGATIVE_BUTTON = 13; 126 127 /** 128 * The device does not have pin, pattern, or password set up. See 129 * {@link BiometricPrompt.Builder#setAllowedAuthenticators(int)}, 130 * {@link Authenticators#DEVICE_CREDENTIAL}, and {@link BiometricManager#canAuthenticate(int)}. 131 */ 132 int BIOMETRIC_ERROR_NO_DEVICE_CREDENTIAL = 14; 133 134 /** 135 * A security vulnerability has been discovered and the sensor is unavailable until a 136 * security update has addressed this issue. This error can be received if for example, 137 * authentication was requested with {@link Authenticators#BIOMETRIC_STRONG}, but the 138 * sensor's strength can currently only meet {@link Authenticators#BIOMETRIC_WEAK}. 139 */ 140 int BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED = 15; 141 142 /** 143 * This constant is only used by SystemUI. It notifies SystemUI that authentication was paused 144 * because the authentication attempt was unsuccessful. 145 * @hide 146 */ 147 int BIOMETRIC_PAUSED_REJECTED = 100; 148 149 /** 150 * @hide 151 */ 152 @UnsupportedAppUsage 153 int BIOMETRIC_ERROR_VENDOR_BASE = 1000; 154 155 // 156 // Image acquisition messages. 157 // 158 159 /** 160 * The image acquired was good. 161 */ 162 int BIOMETRIC_ACQUIRED_GOOD = 0; 163 164 /** 165 * Only a partial biometric image was detected. During enrollment, the user should be informed 166 * on what needs to happen to resolve this problem, e.g. "press firmly on sensor." (for 167 * fingerprint) 168 */ 169 int BIOMETRIC_ACQUIRED_PARTIAL = 1; 170 171 /** 172 * The biometric image was too noisy to process due to a detected condition or a possibly dirty 173 * sensor (See {@link #BIOMETRIC_ACQUIRED_IMAGER_DIRTY}). 174 */ 175 int BIOMETRIC_ACQUIRED_INSUFFICIENT = 2; 176 177 /** 178 * The biometric image was too noisy due to suspected or detected dirt on the sensor. For 179 * example, it's reasonable return this after multiple {@link #BIOMETRIC_ACQUIRED_INSUFFICIENT} 180 * or actual detection of dirt on the sensor (stuck pixels, swaths, etc.). The user is expected 181 * to take action to clean the sensor when this is returned. 182 */ 183 int BIOMETRIC_ACQUIRED_IMAGER_DIRTY = 3; 184 185 /** 186 * The biometric image was unreadable due to lack of motion. 187 */ 188 int BIOMETRIC_ACQUIRED_TOO_SLOW = 4; 189 190 /** 191 * The biometric image was incomplete due to quick motion. For example, this could also happen 192 * if the user moved during acquisition. The user should be asked to repeat the operation more 193 * slowly. 194 */ 195 int BIOMETRIC_ACQUIRED_TOO_FAST = 5; 196 197 /** 198 * Hardware vendors may extend this list if there are conditions that do not fall under one of 199 * the above categories. Vendors are responsible for providing error strings for these errors. 200 * @hide 201 */ 202 int BIOMETRIC_ACQUIRED_VENDOR = 6; 203 /** 204 * @hide 205 */ 206 int BIOMETRIC_ACQUIRED_VENDOR_BASE = 1000; 207 208 // 209 // Internal messages. 210 // 211 212 /** 213 * See {@link BiometricPrompt.Builder#setReceiveSystemEvents(boolean)}. This message is sent 214 * immediately when the user cancels authentication for example by tapping the back button or 215 * tapping the scrim. This is before {@link #BIOMETRIC_ERROR_USER_CANCELED}, which is sent when 216 * dismissal animation completes. 217 * @hide 218 */ 219 int BIOMETRIC_SYSTEM_EVENT_EARLY_USER_CANCEL = 1; 220 221 } 222