From 3acb7fb0878afb369e5bf91db3c6a83a10e0a6ed Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Sat, 28 Jun 2014 20:12:50 +0200 Subject: fix nullpointerexception in importkeyactivity --- .../org/sufficientlysecure/keychain/pgp/PgpImportExport.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java index c50d92f7a..6fc55cfb8 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java @@ -123,11 +123,16 @@ public class PgpImportExport { } /** Imports keys from given data. If keyIds is given only those are imported */ - public ImportResult importKeyRings(List entries) - throws PgpGeneralException, PGPException, IOException { + public ImportResult importKeyRings(List entries) { updateProgress(R.string.progress_importing, 0, 100); + // If there aren't even any keys, do nothing here. + if (entries == null || entries.size() == 0) { + return new ImportResult( + ImportResult.RESULT_FAIL_NOTHING, mProviderHelper.getLog(), 0, 0, 0); + } + int newKeys = 0, oldKeys = 0, badKeys = 0; int position = 0; @@ -165,6 +170,9 @@ public class PgpImportExport { newKeys += 1; } + } catch (IOException e) { + Log.e(Constants.TAG, "Encountered bad key on import!", e); + ++badKeys; } catch (PgpGeneralException e) { Log.e(Constants.TAG, "Encountered bad key on import!", e); ++badKeys; -- cgit v1.2.3