From 4b4e885e55f788bd2cf05f3c83f5a4bccb6cd0c0 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Fri, 3 Oct 2014 02:10:57 +0200 Subject: [PATCH] more getActivity() checks --- .../keychain/ui/PassphraseDialogActivity.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PassphraseDialogActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PassphraseDialogActivity.java index decd1757f..4bfca9e1d 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PassphraseDialogActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/PassphraseDialogActivity.java @@ -157,8 +157,8 @@ public class PassphraseDialogActivity extends FragmentActivity { /* Get key type for message */ // find a master key id for our key - long masterKeyId = new ProviderHelper(getActivity()).getMasterKeyId(mSubKeyId); - CachedPublicKeyRing keyRing = new ProviderHelper(getActivity()).getCachedPublicKeyRing(masterKeyId); + long masterKeyId = new ProviderHelper(activity).getMasterKeyId(mSubKeyId); + CachedPublicKeyRing keyRing = new ProviderHelper(activity).getCachedPublicKeyRing(masterKeyId); // get the type of key (from the database) CanonicalizedSecretKey.SecretKeyType keyType = keyRing.getSecretKeyType(mSubKeyId); switch (keyType) { @@ -324,6 +324,11 @@ public class PassphraseDialogActivity extends FragmentActivity { } private void finishCaching(String passphrase) { + // any indication this isn't needed anymore, don't do it. + if (mIsCancelled || getActivity() == null) { + return; + } + if (mServiceIntent != null) { // TODO: Not routing passphrase through OpenPGP API currently // due to security concerns... @@ -352,6 +357,10 @@ public class PassphraseDialogActivity extends FragmentActivity { public void onDismiss(DialogInterface dialog) { super.onDismiss(dialog); + if (getActivity() == null) { + return; + } + hideKeyboard(); getActivity().setResult(RESULT_CANCELED);