@@ -61,42 +61,44 @@ object BiometricAuthenticator {
61
61
override fun onAuthenticationError (errorCode : Int , errString : CharSequence ) {
62
62
super .onAuthenticationError(errorCode, errString)
63
63
logcat(TAG ) { " onAuthenticationError(errorCode=$errorCode , msg=$errString )" }
64
- callback(
65
- when (errorCode) {
66
- BiometricPrompt .ERROR_CANCELED ,
67
- BiometricPrompt .ERROR_USER_CANCELED ,
68
- BiometricPrompt . ERROR_NEGATIVE_BUTTON -> {
69
- Result . Cancelled
70
- }
71
- BiometricPrompt .ERROR_HW_NOT_PRESENT ,
72
- BiometricPrompt .ERROR_HW_UNAVAILABLE ,
73
- BiometricPrompt .ERROR_NO_BIOMETRICS ,
74
- BiometricPrompt . ERROR_NO_DEVICE_CREDENTIAL -> {
75
- Result . HardwareUnavailableOrDisabled
76
- }
77
- BiometricPrompt .ERROR_LOCKOUT ,
78
- BiometricPrompt .ERROR_LOCKOUT_PERMANENT ,
79
- BiometricPrompt .ERROR_NO_SPACE ,
80
- BiometricPrompt .ERROR_TIMEOUT ,
81
- BiometricPrompt . ERROR_VENDOR -> {
64
+ when (errorCode) {
65
+ BiometricPrompt . ERROR_CANCELED ,
66
+ BiometricPrompt .ERROR_USER_CANCELED ,
67
+ BiometricPrompt .ERROR_NEGATIVE_BUTTON -> {
68
+ callback( Result . Cancelled )
69
+ }
70
+ BiometricPrompt . ERROR_HW_NOT_PRESENT ,
71
+ BiometricPrompt .ERROR_HW_UNAVAILABLE ,
72
+ BiometricPrompt .ERROR_NO_BIOMETRICS ,
73
+ BiometricPrompt .ERROR_NO_DEVICE_CREDENTIAL -> {
74
+ callback( Result . HardwareUnavailableOrDisabled )
75
+ }
76
+ BiometricPrompt . ERROR_LOCKOUT ,
77
+ BiometricPrompt .ERROR_LOCKOUT_PERMANENT ,
78
+ BiometricPrompt .ERROR_NO_SPACE ,
79
+ BiometricPrompt .ERROR_TIMEOUT ,
80
+ BiometricPrompt .ERROR_VENDOR -> {
81
+ callback(
82
82
Result .Failure (
83
83
errorCode,
84
84
activity.getString(R .string.biometric_auth_error_reason, errString)
85
85
)
86
- }
87
- BiometricPrompt .ERROR_UNABLE_TO_PROCESS -> {
88
- Result .Retry
89
- }
90
- // We cover all guaranteed values above, but [errorCode] is still an Int
91
- // at the end of the day so a catch-all else will always be required.
92
- else -> {
86
+ )
87
+ }
88
+ BiometricPrompt .ERROR_UNABLE_TO_PROCESS -> {
89
+ callback(Result .Retry )
90
+ }
91
+ // We cover all guaranteed values above, but [errorCode] is still an Int
92
+ // at the end of the day so a catch-all else will always be required.
93
+ else -> {
94
+ callback(
93
95
Result .Failure (
94
96
errorCode,
95
97
activity.getString(R .string.biometric_auth_error_reason, errString)
96
98
)
97
- }
99
+ )
98
100
}
99
- )
101
+ }
100
102
}
101
103
102
104
override fun onAuthenticationFailed () {
0 commit comments