more getActivity() checks

This commit is contained in:
Vincent Breitmoser 2014-10-03 02:10:57 +02:00
parent 34e4dabea9
commit 4b4e885e55

View File

@ -157,8 +157,8 @@ public class PassphraseDialogActivity extends FragmentActivity {
/* Get key type for message */ /* Get key type for message */
// find a master key id for our key // find a master key id for our key
long masterKeyId = new ProviderHelper(getActivity()).getMasterKeyId(mSubKeyId); long masterKeyId = new ProviderHelper(activity).getMasterKeyId(mSubKeyId);
CachedPublicKeyRing keyRing = new ProviderHelper(getActivity()).getCachedPublicKeyRing(masterKeyId); CachedPublicKeyRing keyRing = new ProviderHelper(activity).getCachedPublicKeyRing(masterKeyId);
// get the type of key (from the database) // get the type of key (from the database)
CanonicalizedSecretKey.SecretKeyType keyType = keyRing.getSecretKeyType(mSubKeyId); CanonicalizedSecretKey.SecretKeyType keyType = keyRing.getSecretKeyType(mSubKeyId);
switch (keyType) { switch (keyType) {
@ -324,6 +324,11 @@ public class PassphraseDialogActivity extends FragmentActivity {
} }
private void finishCaching(String passphrase) { private void finishCaching(String passphrase) {
// any indication this isn't needed anymore, don't do it.
if (mIsCancelled || getActivity() == null) {
return;
}
if (mServiceIntent != null) { if (mServiceIntent != null) {
// TODO: Not routing passphrase through OpenPGP API currently // TODO: Not routing passphrase through OpenPGP API currently
// due to security concerns... // due to security concerns...
@ -352,6 +357,10 @@ public class PassphraseDialogActivity extends FragmentActivity {
public void onDismiss(DialogInterface dialog) { public void onDismiss(DialogInterface dialog) {
super.onDismiss(dialog); super.onDismiss(dialog);
if (getActivity() == null) {
return;
}
hideKeyboard(); hideKeyboard();
getActivity().setResult(RESULT_CANCELED); getActivity().setResult(RESULT_CANCELED);