|
| 1 | +/* |
| 2 | + * Copyright 2026 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 androidx.biometric; |
| 18 | + |
| 19 | + |
| 20 | +import androidx.annotation.RestrictTo; |
| 21 | + |
| 22 | +/** |
| 23 | + * Interface containing all of the biometric modality agnostic constants. |
| 24 | + * |
| 25 | + * NOTE: The error messages must be consistent with |
| 26 | + * {@link android.hardware.biometrics.BiometricConstants} |
| 27 | + */ |
| 28 | +interface BiometricConstants { |
| 29 | + |
| 30 | + /** |
| 31 | + * There is no error, and the user can successfully authenticate. |
| 32 | + */ |
| 33 | + @RestrictTo(RestrictTo.Scope.LIBRARY) |
| 34 | + int BIOMETRIC_SUCCESS = 0; |
| 35 | + |
| 36 | + /** |
| 37 | + * The hardware is unavailable. Try again later. |
| 38 | + */ |
| 39 | + int ERROR_HW_UNAVAILABLE = 1; |
| 40 | + |
| 41 | + /** |
| 42 | + * The sensor was unable to process the current image. |
| 43 | + */ |
| 44 | + int ERROR_UNABLE_TO_PROCESS = 2; |
| 45 | + |
| 46 | + /** |
| 47 | + * The current operation has been running too long and has timed out. |
| 48 | + * |
| 49 | + * <p>This is intended to prevent programs from waiting for the biometric sensor indefinitely. |
| 50 | + * The timeout is platform and sensor-specific, but is generally on the order of ~30 seconds. |
| 51 | + */ |
| 52 | + int ERROR_TIMEOUT = 3; |
| 53 | + |
| 54 | + /** |
| 55 | + * The operation can't be completed because there is not enough device storage remaining. |
| 56 | + */ |
| 57 | + int ERROR_NO_SPACE = 4; |
| 58 | + |
| 59 | + /** |
| 60 | + * The operation was canceled because the biometric sensor is unavailable. This may happen when |
| 61 | + * the user is switched, the device is locked, or another pending operation prevents it. |
| 62 | + */ |
| 63 | + int ERROR_CANCELED = 5; |
| 64 | + |
| 65 | + /** |
| 66 | + * The operation was canceled because the API is locked out due to too many attempts. This |
| 67 | + * occurs after 5 failed attempts, and lasts for 30 seconds. |
| 68 | + */ |
| 69 | + int ERROR_LOCKOUT = 7; |
| 70 | + |
| 71 | + /** |
| 72 | + * The operation failed due to a vendor-specific error. |
| 73 | + * |
| 74 | + * <p>This error code may be used by hardware vendors to extend this list to cover errors that |
| 75 | + * don't fall under one of the other predefined categories. Vendors are responsible for |
| 76 | + * providing the strings for these errors. |
| 77 | + * |
| 78 | + * <p>These messages are typically reserved for internal operations such as enrollment but may |
| 79 | + * be used to express any error that is not otherwise covered. In this case, applications are |
| 80 | + * expected to show the error message, but they are advised not to rely on the message ID, since |
| 81 | + * this may vary by vendor and device. |
| 82 | + */ |
| 83 | + int ERROR_VENDOR = 8; |
| 84 | + |
| 85 | + /** |
| 86 | + * The operation was canceled because {@link #ERROR_LOCKOUT} occurred too many times. Biometric |
| 87 | + * authentication is disabled until the user unlocks with their device credential (i.e. PIN, |
| 88 | + * pattern, or password). |
| 89 | + */ |
| 90 | + int ERROR_LOCKOUT_PERMANENT = 9; |
| 91 | + |
| 92 | + /** |
| 93 | + * The user canceled the operation. |
| 94 | + * |
| 95 | + * <p>Upon receiving this, applications should use alternate authentication, such as a password. |
| 96 | + * The application should also provide the user a way of returning to biometric authentication, |
| 97 | + * such as a button. |
| 98 | + */ |
| 99 | + int ERROR_USER_CANCELED = 10; |
| 100 | + |
| 101 | + /** |
| 102 | + * The user does not have any biometrics enrolled. |
| 103 | + */ |
| 104 | + int ERROR_NO_BIOMETRICS = 11; |
| 105 | + |
| 106 | + /** |
| 107 | + * The device does not have the required authentication hardware. |
| 108 | + */ |
| 109 | + int ERROR_HW_NOT_PRESENT = 12; |
| 110 | + |
| 111 | + /** |
| 112 | + * The user pressed the negative button. |
| 113 | + */ |
| 114 | + int ERROR_NEGATIVE_BUTTON = 13; |
| 115 | + |
| 116 | + /** |
| 117 | + * The device does not have pin, pattern, or password set up. |
| 118 | + */ |
| 119 | + int ERROR_NO_DEVICE_CREDENTIAL = 14; |
| 120 | + |
| 121 | + /** |
| 122 | + * A security vulnerability has been discovered with one or more hardware sensors. The |
| 123 | + * affected sensor(s) are unavailable until a security update has addressed the issue. |
| 124 | + */ |
| 125 | + int ERROR_SECURITY_UPDATE_REQUIRED = 15; |
| 126 | + |
| 127 | + /** |
| 128 | + * The privacy setting has been enabled and will block use of the sensor. |
| 129 | + */ |
| 130 | + @RestrictTo(RestrictTo.Scope.LIBRARY) |
| 131 | + int ERROR_SENSOR_PRIVACY_ENABLED = 18; |
| 132 | + |
| 133 | + /** |
| 134 | + * Identity Check is currently not active. |
| 135 | + * |
| 136 | + * This device either doesn't have this feature enabled, or it's not considered in a |
| 137 | + * high-risk environment that requires extra security measures for accessing sensitive data. |
| 138 | + */ |
| 139 | + int ERROR_IDENTITY_CHECK_NOT_ACTIVE = 20; |
| 140 | + |
| 141 | + /** |
| 142 | + * Biometrics is not allowed to verify the user in apps. It's for internal use only. This |
| 143 | + * error code, introduced in API 35, was previously covered by ERROR_HW_UNAVAILABLE and |
| 144 | + * doesn't need to be public. Therefore, for backward compatibility, this error will be |
| 145 | + * converted to ERROR_HW_UNAVAILABLE. |
| 146 | + */ |
| 147 | + @RestrictTo(RestrictTo.Scope.LIBRARY) |
| 148 | + int ERROR_NOT_ENABLED_FOR_APPS = 21; |
| 149 | + |
| 150 | + /** |
| 151 | + * The user pressed the more options button on {@link PromptContentViewWithMoreOptionsButton} |
| 152 | + * set by {@link BiometricPrompt.PromptInfo.Builder#setContentView} |
| 153 | + */ |
| 154 | + int ERROR_CONTENT_VIEW_MORE_OPTIONS_BUTTON = 22; |
| 155 | + |
| 156 | + |
| 157 | + /** |
| 158 | + * Authentication type reported by {@link BiometricPrompt.AuthenticationResult} when the user |
| 159 | + * authenticated via an unknown method. |
| 160 | + * |
| 161 | + * <p>This value may be returned on older Android versions due to partial incompatibility |
| 162 | + * with a newer API. It does NOT necessarily imply that the user authenticated with a method |
| 163 | + * other than those represented by {@link #AUTHENTICATION_RESULT_TYPE_DEVICE_CREDENTIAL} and |
| 164 | + * {@link #AUTHENTICATION_RESULT_TYPE_BIOMETRIC}. |
| 165 | + */ |
| 166 | + int AUTHENTICATION_RESULT_TYPE_UNKNOWN = -1; |
| 167 | + |
| 168 | + /** |
| 169 | + * Authentication type reported by {@link BiometricPrompt.AuthenticationResult} when the user |
| 170 | + * authenticated by entering their device PIN, pattern, or password. |
| 171 | + */ |
| 172 | + int AUTHENTICATION_RESULT_TYPE_DEVICE_CREDENTIAL = 1; |
| 173 | + |
| 174 | + /** |
| 175 | + * Authentication type reported by {@link BiometricPrompt.AuthenticationResult} when the user |
| 176 | + * authenticated by presenting some form of biometric (e.g. fingerprint or face). |
| 177 | + */ |
| 178 | + int AUTHENTICATION_RESULT_TYPE_BIOMETRIC = 2; |
| 179 | + |
| 180 | +} |
0 commit comments