diff options
Diffstat (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java')
-rw-r--r-- | OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java index 138e54f71..3ce9fa7c5 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java @@ -42,6 +42,7 @@ import org.sufficientlysecure.keychain.ui.adapter.ImportKeysListEntry; import org.sufficientlysecure.keychain.util.HkpKeyServer; import org.sufficientlysecure.keychain.util.IterableIterator; import org.sufficientlysecure.keychain.util.KeyServer.AddKeyException; +import org.sufficientlysecure.keychain.util.KeychainServiceListener; import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.ProgressDialogUpdater; @@ -50,15 +51,25 @@ import android.os.Bundle; import android.os.Environment; public class PgpImportExport { + private Context mContext; private ProgressDialogUpdater mProgress; + private KeychainServiceListener mKeychainServiceListener; + public PgpImportExport(Context context, ProgressDialogUpdater progress) { super(); this.mContext = context; this.mProgress = progress; } + public PgpImportExport(Context context, ProgressDialogUpdater progress, KeychainServiceListener keychainListener){ + super(); + this.mContext = context; + this.mProgress = progress; + this.mKeychainServiceListener = keychainListener; + } + public void updateProgress(int message, int current, int total) { if (mProgress != null) { mProgress.setProgress(message, current, total); @@ -188,8 +199,10 @@ public class PgpImportExport { if (secretKeyRing != null) { secretKeyRing.encode(arOutStream); } - // Else if it's a public key get the PGPPublicKeyRing - // and encode that to the output + if(mKeychainServiceListener.hasServiceStopped()){ + arOutStream.close(); + return null; + } } else { updateProgress(i * 100 / rowIdsSize, 100); PGPPublicKeyRing publicKeyRing = @@ -198,6 +211,11 @@ public class PgpImportExport { if (publicKeyRing != null) { publicKeyRing.encode(arOutStream); } + + if(mKeychainServiceListener.hasServiceStopped()){ + arOutStream.close(); + return null; + } } arOutStream.close(); |