fix: remove logs

This commit is contained in:
2026-02-03 22:19:01 +05:00
parent 6bb0a90ea0
commit a7268bb986
11 changed files with 176 additions and 83 deletions

View File

@@ -123,7 +123,6 @@ class BiometricAuthManager(private val context: Context) {
Arrays.fill(passwordBytes, 0.toByte())
}
} catch (e: Exception) {
Log.e(TAG, "Encryption failed", e)
onError("Ошибка шифрования: ${e.message}")
}
},
@@ -131,11 +130,9 @@ class BiometricAuthManager(private val context: Context) {
onCancel = onCancel
)
} catch (e: KeyPermanentlyInvalidatedException) {
Log.e(TAG, "Key invalidated, removing and retrying", e)
removeBiometricData()
onError("Биометрические данные изменились. Пожалуйста, настройте заново.")
} catch (e: Exception) {
Log.e(TAG, "Failed to initialize encryption", e)
onError("Ошибка инициализации: ${e.message}")
}
}
@@ -185,7 +182,6 @@ class BiometricAuthManager(private val context: Context) {
decrypted = authenticatedCipher.doFinal(encrypted)
onSuccess(String(decrypted, Charsets.UTF_8))
} catch (e: Exception) {
Log.e(TAG, "Decryption failed", e)
onError("Ошибка расшифровки: ${e.message}")
} finally {
// Secure memory wipe - обнуляем расшифрованные данные
@@ -196,11 +192,9 @@ class BiometricAuthManager(private val context: Context) {
onCancel = onCancel
)
} catch (e: KeyPermanentlyInvalidatedException) {
Log.e(TAG, "Key permanently invalidated", e)
removeBiometricData()
onError("Биометрические данные изменились. Пожалуйста, войдите с паролем и настройте биометрию заново.")
} catch (e: Exception) {
Log.e(TAG, "Failed to initialize decryption", e)
onError("Ошибка инициализации: ${e.message}")
}
}
@@ -222,8 +216,6 @@ class BiometricAuthManager(private val context: Context) {
val callback = object : BiometricPrompt.AuthenticationCallback() {
override fun onAuthenticationError(errorCode: Int, errString: CharSequence) {
super.onAuthenticationError(errorCode, errString)
Log.d(TAG, "Authentication error: $errorCode - $errString")
when (errorCode) {
BiometricPrompt.ERROR_USER_CANCELED,
BiometricPrompt.ERROR_NEGATIVE_BUTTON,
@@ -237,8 +229,6 @@ class BiometricAuthManager(private val context: Context) {
override fun onAuthenticationSucceeded(result: BiometricPrompt.AuthenticationResult) {
super.onAuthenticationSucceeded(result)
Log.d(TAG, "Authentication succeeded")
// Получаем аутентифицированный Cipher из CryptoObject
val authenticatedCipher = result.cryptoObject?.cipher
if (authenticatedCipher != null) {
@@ -250,8 +240,7 @@ class BiometricAuthManager(private val context: Context) {
override fun onAuthenticationFailed() {
super.onAuthenticationFailed()
Log.d(TAG, "Authentication failed (user can retry)")
// Не вызываем onError - пользователь может попробовать снова
// Не вызываем onError - пользователь может попробовать снова
}
}
@@ -312,7 +301,6 @@ class BiometricAuthManager(private val context: Context) {
try {
builder.setAttestationChallenge(generateAttestationChallenge())
} catch (e: Exception) {
Log.w(TAG, "Key attestation not supported", e)
}
}
@@ -321,7 +309,6 @@ class BiometricAuthManager(private val context: Context) {
try {
builder.setIsStrongBoxBacked(true)
} catch (e: Exception) {
Log.w(TAG, "StrongBox not available, using TEE", e)
}
}
@@ -336,7 +323,6 @@ class BiometricAuthManager(private val context: Context) {
return try {
keyStore.getKey(KEY_ALIAS, null) as? SecretKey
} catch (e: Exception) {
Log.e(TAG, "Failed to get key from Keystore", e)
null
}
}
@@ -349,10 +335,8 @@ class BiometricAuthManager(private val context: Context) {
try {
if (keyStore.containsAlias(KEY_ALIAS)) {
keyStore.deleteEntry(KEY_ALIAS)
Log.d(TAG, "Biometric key removed from Keystore")
}
} catch (e: Exception) {
Log.e(TAG, "Failed to remove key from Keystore", e)
}
}
@@ -396,7 +380,6 @@ class BiometricAuthManager(private val context: Context) {
try {
certificateChain[i].verify(certificateChain[i + 1].publicKey)
} catch (e: Exception) {
Log.e(TAG, "Certificate chain verification failed at index $i", e)
return KeyAttestationResult.Invalid("Цепочка сертификатов недействительна")
}
}
@@ -406,14 +389,12 @@ class BiometricAuthManager(private val context: Context) {
if (leafCert != null) {
val attestationExtension = leafCert.getExtensionValue("1.3.6.1.4.1.11129.2.1.17")
if (attestationExtension != null) {
Log.d(TAG, "Key attestation verified - key is in secure hardware")
return KeyAttestationResult.Valid(isStrongBox = isKeyInStrongBox())
}
}
KeyAttestationResult.NotSupported
} catch (e: Exception) {
Log.e(TAG, "Key attestation verification failed", e)
KeyAttestationResult.Invalid(e.message ?: "Unknown error")
}
}
@@ -437,7 +418,6 @@ class BiometricAuthManager(private val context: Context) {
keyInfo.isInsideSecureHardware
}
} catch (e: Exception) {
Log.w(TAG, "Could not determine if key is in StrongBox", e)
false
}
}

View File

@@ -40,7 +40,6 @@ class BiometricPreferences(private val context: Context) {
try {
_isBiometricEnabled.value = encryptedPrefs.getBoolean(KEY_BIOMETRIC_ENABLED, false)
} catch (e: Exception) {
Log.e(TAG, "Failed to read biometric enabled state", e)
}
}
@@ -63,7 +62,6 @@ class BiometricPreferences(private val context: Context) {
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
)
} catch (e: Exception) {
Log.e(TAG, "Failed to create EncryptedSharedPreferences, falling back", e)
// Fallback на обычные SharedPreferences в случае ошибки (не должно произойти)
return context.getSharedPreferences(PREFS_FILE_NAME + "_fallback", Context.MODE_PRIVATE)
}
@@ -97,7 +95,6 @@ class BiometricPreferences(private val context: Context) {
suspend fun saveEncryptedPassword(publicKey: String, encryptedPassword: String) = withContext(Dispatchers.IO) {
val key = "$ENCRYPTED_PASSWORD_PREFIX$publicKey"
encryptedPrefs.edit().putString(key, encryptedPassword).apply()
Log.d(TAG, "Encrypted password saved for account")
}
/**
@@ -114,7 +111,6 @@ class BiometricPreferences(private val context: Context) {
suspend fun removeEncryptedPassword(publicKey: String) = withContext(Dispatchers.IO) {
val key = "$ENCRYPTED_PASSWORD_PREFIX$publicKey"
encryptedPrefs.edit().remove(key).apply()
Log.d(TAG, "Encrypted password removed for account")
}
/**
@@ -123,7 +119,6 @@ class BiometricPreferences(private val context: Context) {
suspend fun clearAll() = withContext(Dispatchers.IO) {
encryptedPrefs.edit().clear().apply()
_isBiometricEnabled.value = false
Log.d(TAG, "All biometric data cleared")
}
/**