refactor: import-alias BiometricAuthenticator.Result

This commit is contained in:
Harsh Shandilya 2024-07-24 00:28:09 +05:30
parent a064116e80
commit 8095ee4d6e
2 changed files with 9 additions and 11 deletions

View file

@ -23,7 +23,7 @@ import app.passwordstore.data.repo.PasswordRepository
import app.passwordstore.ui.crypto.BasePGPActivity import app.passwordstore.ui.crypto.BasePGPActivity
import app.passwordstore.ui.crypto.PasswordDialog import app.passwordstore.ui.crypto.PasswordDialog
import app.passwordstore.util.auth.BiometricAuthenticator import app.passwordstore.util.auth.BiometricAuthenticator
import app.passwordstore.util.auth.BiometricAuthenticator.Result import app.passwordstore.util.auth.BiometricAuthenticator.Result as BiometricResult
import app.passwordstore.util.autofill.AutofillPreferences import app.passwordstore.util.autofill.AutofillPreferences
import app.passwordstore.util.autofill.AutofillResponseBuilder import app.passwordstore.util.autofill.AutofillResponseBuilder
import app.passwordstore.util.autofill.DirectoryStructure import app.passwordstore.util.autofill.DirectoryStructure
@ -87,7 +87,7 @@ class AutofillDecryptActivity : BasePGPActivity() {
decrypt(filePath, clientState, action, authResult) decrypt(filePath, clientState, action, authResult)
} }
} else { } else {
decrypt(filePath, clientState, action, Result.CanceledByUser) decrypt(filePath, clientState, action, BiometricResult.CanceledByUser)
} }
} }
} }
@ -96,7 +96,7 @@ class AutofillDecryptActivity : BasePGPActivity() {
filePath: String, filePath: String,
clientState: Bundle, clientState: Bundle,
action: AutofillAction, action: AutofillAction,
authResult: Result, authResult: BiometricResult,
) { ) {
val gpgIdentifiers = val gpgIdentifiers =
getPGPIdentifiers( getPGPIdentifiers(
@ -105,15 +105,14 @@ class AutofillDecryptActivity : BasePGPActivity() {
lifecycleScope.launch(dispatcherProvider.main()) { lifecycleScope.launch(dispatcherProvider.main()) {
when (authResult) { when (authResult) {
// Internally handled by the prompt dialog // Internally handled by the prompt dialog
is Result.Retry -> {} is BiometricResult.Retry -> {}
// If the dialog is dismissed for any reason, prompt for passphrase // If the dialog is dismissed for any reason, prompt for passphrase
is Result.CanceledBySystem, is BiometricResult.CanceledBySystem,
is Result.CanceledByUser, is BiometricResult.CanceledByUser,
is Result.Failure, is BiometricResult.Failure,
is Result.HardwareUnavailableOrDisabled -> is BiometricResult.HardwareUnavailableOrDisabled ->
askPassphrase(filePath, gpgIdentifiers, clientState, action) askPassphrase(filePath, gpgIdentifiers, clientState, action)
// is BiometricResult.Success -> {
is Result.Success -> {
/* clear passphrase cache on first use after application startup or if screen was off; /* clear passphrase cache on first use after application startup or if screen was off;
also make sure to purge a stale cache after caching has been disabled via PGP settings */ also make sure to purge a stale cache after caching has been disabled via PGP settings */
clearCache = settings.getBoolean(PreferenceKeys.CLEAR_PASSPHRASE_CACHE, true) clearCache = settings.getBoolean(PreferenceKeys.CLEAR_PASSPHRASE_CACHE, true)

View file

@ -168,7 +168,6 @@ class DecryptActivity : BasePGPActivity() {
is BiometricResult.Failure, is BiometricResult.Failure,
is BiometricResult.HardwareUnavailableOrDisabled -> is BiometricResult.HardwareUnavailableOrDisabled ->
askPassphrase(isError, gpgIdentifiers, authResult) askPassphrase(isError, gpgIdentifiers, authResult)
//
is BiometricResult.Success -> { is BiometricResult.Success -> {
/* clear passphrase cache on first use after application startup or if screen was off; /* clear passphrase cache on first use after application startup or if screen was off;
also make sure to purge a stale cache after caching has been disabled via PGP settings */ also make sure to purge a stale cache after caching has been disabled via PGP settings */