From 029ca81bbf10580d3ee720f10bd1e667ba94a225 Mon Sep 17 00:00:00 2001 From: Alexander Bakker Date: Mon, 22 Aug 2022 19:14:51 +0200 Subject: [PATCH] Don't catch the IllegalArgumentException when calling getMissingIndices We always call isSingleBatch beforehand, so if the exception occurs, it's a bug. --- .../aegis/ui/MainActivity.java | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/beemdevelopment/aegis/ui/MainActivity.java b/app/src/main/java/com/beemdevelopment/aegis/ui/MainActivity.java index 5f3e7b7f..1c7714ba 100644 --- a/app/src/main/java/com/beemdevelopment/aegis/ui/MainActivity.java +++ b/app/src/main/java/com/beemdevelopment/aegis/ui/MainActivity.java @@ -367,31 +367,27 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene VaultEntry entry = new VaultEntry(info); entries.add(entry); } - } catch (GoogleAuthInfoException | IllegalArgumentException e) { + } catch (GoogleAuthInfoException e) { errors.add(buildImportError(res.getFileName(), e)); } } final DialogInterface.OnClickListener dialogDismissHandler = (dialog, which) -> importScannedEntries(entries); if (!googleAuthExports.isEmpty()) { - try { - if (!GoogleAuthInfo.Export.isSingleBatch(googleAuthExports) && errors.size() > 0) { - errors.add(getString(R.string.unrelated_google_auth_batches_error)); - Dialogs.showMultiMessageDialog(this, R.string.import_error_title, getString(R.string.no_tokens_can_be_imported), errors, null); - return; - } else if (!GoogleAuthInfo.Export.isSingleBatch(googleAuthExports)) { - Dialogs.showErrorDialog(this, R.string.import_google_auth_failure, getString(R.string.unrelated_google_auth_batches_error)); - return; - } else { - List missingIndices = GoogleAuthInfo.Export.getMissingIndices(googleAuthExports); - if (missingIndices.size() != 0) { - Dialogs.showPartialGoogleAuthImportWarningDialog(this, missingIndices, entries.size(), errors, dialogDismissHandler); - return; - } - } - } catch (IllegalArgumentException e) { - Dialogs.showErrorDialog(this, getString(R.string.import_google_auth_failure), e); + boolean isSingleBatch = GoogleAuthInfo.Export.isSingleBatch(googleAuthExports); + if (!isSingleBatch && errors.size() > 0) { + errors.add(getString(R.string.unrelated_google_auth_batches_error)); + Dialogs.showMultiMessageDialog(this, R.string.import_error_title, getString(R.string.no_tokens_can_be_imported), errors, null); return; + } else if (!isSingleBatch) { + Dialogs.showErrorDialog(this, R.string.import_google_auth_failure, getString(R.string.unrelated_google_auth_batches_error)); + return; + } else { + List missingIndices = GoogleAuthInfo.Export.getMissingIndices(googleAuthExports); + if (missingIndices.size() != 0) { + Dialogs.showPartialGoogleAuthImportWarningDialog(this, missingIndices, entries.size(), errors, dialogDismissHandler); + return; + } } }