diff --git a/tangem-sdk-android/src/main/java/com/tangem/sdk/authentication/AndroidAuthenticationManager.kt b/tangem-sdk-android/src/main/java/com/tangem/sdk/authentication/AndroidAuthenticationManager.kt index a6e3c511..ea4f4bbe 100644 --- a/tangem-sdk-android/src/main/java/com/tangem/sdk/authentication/AndroidAuthenticationManager.kt +++ b/tangem-sdk-android/src/main/java/com/tangem/sdk/authentication/AndroidAuthenticationManager.kt @@ -68,11 +68,13 @@ internal class AndroidAuthenticationManager( if (authenticationMutex.isLocked) { Log.warning { "$TAG - A user authentication has already been launched" } + Log.biometric { "A user authentication has already been launched" } return } authenticationMutex.withLock { Log.debug { "$TAG - Trying to authenticate a user" } + Log.biometric { "Try to authenticate a user" } val canAuthenticate = canAuthenticateInternal.filterNotNull().first() if (canAuthenticate) { @@ -81,6 +83,7 @@ internal class AndroidAuthenticationManager( } } else { Log.warning { "$TAG - Unable to authenticate the user as the biometrics feature is unavailable" } + Log.biometric { "Unable to authenticate the user as the biometrics feature is unavailable" } throw TangemSdkError.AuthenticationUnavailable() } @@ -115,6 +118,7 @@ internal class AndroidAuthenticationManager( when (biometricManager.canAuthenticate(AUTHENTICATORS)) { SystemBiometricManager.BIOMETRIC_SUCCESS -> { Log.debug { "$TAG - Biometric features are available" } + Log.biometric { "Biometric features are available" } continuation.resume( BiometricsAvailability( available = true, @@ -125,6 +129,7 @@ internal class AndroidAuthenticationManager( SystemBiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED -> { Log.debug { "$TAG - No biometric features enrolled" } + Log.biometric { "No biometric features enrolled" } continuation.resume( BiometricsAvailability( available = false, @@ -134,6 +139,7 @@ internal class AndroidAuthenticationManager( } SystemBiometricManager.BIOMETRIC_ERROR_NO_HARDWARE -> { Log.debug { "$TAG - No biometric features available on this device" } + Log.biometric { "No biometric features available on this device" } continuation.resume( BiometricsAvailability( available = false, @@ -143,6 +149,7 @@ internal class AndroidAuthenticationManager( } SystemBiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE -> { Log.debug { "$TAG - Biometric features are currently unavailable" } + Log.biometric { "Biometric features are currently unavailable" } continuation.resume( BiometricsAvailability( available = false, @@ -152,6 +159,7 @@ internal class AndroidAuthenticationManager( } SystemBiometricManager.BIOMETRIC_ERROR_SECURITY_UPDATE_REQUIRED -> { Log.debug { "$TAG - Biometric features are currently unavailable, security update required" } + Log.biometric { "Biometric features are currently unavailable, security update required" } continuation.resume( BiometricsAvailability( available = false, @@ -161,6 +169,7 @@ internal class AndroidAuthenticationManager( } SystemBiometricManager.BIOMETRIC_STATUS_UNKNOWN -> { Log.debug { "$TAG - Biometric features are in unknown status" } + Log.biometric { "Biometric features are in unknown status" } continuation.resume( BiometricsAvailability( available = false, @@ -170,6 +179,7 @@ internal class AndroidAuthenticationManager( } SystemBiometricManager.BIOMETRIC_ERROR_UNSUPPORTED -> { Log.debug { "$TAG - Biometric features are unsupported" } + Log.biometric { "Biometric features are unsupported" } continuation.resume( BiometricsAvailability( available = false, @@ -204,17 +214,20 @@ internal class AndroidAuthenticationManager( |- Cause: $error """.trimIndent() } + Log.biometric { "Biometric authentication error:\n$error" } result(BiometricAuthenticationResult.Failure(error)) } override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) { Log.debug { "$TAG - Biometric authentication succeed" } + Log.biometric { "Biometric authentication succeed" } result(BiometricAuthenticationResult.Success(result)) } override fun onAuthenticationFailed() { Log.warning { "$TAG - Biometric authentication failed" } + Log.biometric { "Biometric authentication failed" } } } } diff --git a/tangem-sdk-core/src/main/java/com/tangem/Log.kt b/tangem-sdk-core/src/main/java/com/tangem/Log.kt index e0faaa1a..5b1239c0 100644 --- a/tangem-sdk-core/src/main/java/com/tangem/Log.kt +++ b/tangem-sdk-core/src/main/java/com/tangem/Log.kt @@ -65,6 +65,10 @@ object Log { logInternal(message, Level.Info) } + fun biometric(message: () -> String) { + logInternal(message, Level.Biometric) + } + private fun logInternal(message: () -> String, level: Level) { if (loggers.isEmpty()) return @@ -92,6 +96,7 @@ object Log { Apdu(""), Nfc("NFCReader: "), Tlv(""), + Biometric("Biometric: "), } enum class Config(val levels: List) {