diff options
author | Vincent Breitmoser <valodim@mugenguild.com> | 2014-08-31 20:12:46 +0200 |
---|---|---|
committer | Vincent Breitmoser <valodim@mugenguild.com> | 2014-09-01 21:23:05 +0200 |
commit | 16a93038dda4d51f48a32b12695b1e32e5ca7801 (patch) | |
tree | 600bf630648ec384c24cd78cd0776029d919879c /OpenKeychain/src | |
parent | 42acb120596ffa423a22e70be3edc017a2435ef8 (diff) | |
download | open-keychain-16a93038dda4d51f48a32b12695b1e32e5ca7801.tar.gz open-keychain-16a93038dda4d51f48a32b12695b1e32e5ca7801.tar.bz2 open-keychain-16a93038dda4d51f48a32b12695b1e32e5ca7801.zip |
remove broken(?) cancellation code
Diffstat (limited to 'OpenKeychain/src')
2 files changed, 7 insertions, 59 deletions
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 f5b2280c9..511086489 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpImportExport.java @@ -52,23 +52,12 @@ import java.util.concurrent.atomic.AtomicBoolean; public class PgpImportExport { - // TODO: is this really used? - public interface KeychainServiceListener { - boolean hasServiceStopped(); - } - private Context mContext; private Progressable mProgressable; private AtomicBoolean mCancelled; - private KeychainServiceListener mKeychainServiceListener; - private ProviderHelper mProviderHelper; - public PgpImportExport(Context context, Progressable progressable) { - this(context, new ProviderHelper(context), progressable); - } - public PgpImportExport(Context context, ProviderHelper providerHelper, Progressable progressable) { super(); this.mContext = context; @@ -84,15 +73,6 @@ public class PgpImportExport { mCancelled = cancelled; } - public PgpImportExport(Context context, - Progressable progressable, KeychainServiceListener keychainListener) { - super(); - this.mContext = context; - this.mProgressable = progressable; - this.mProviderHelper = new ProviderHelper(context); - this.mKeychainServiceListener = keychainListener; - } - public void updateProgress(int message, int current, int total) { if (mProgressable != null) { mProgressable.setProgress(message, current, total); @@ -277,11 +257,6 @@ public class PgpImportExport { // TODO: inform user? } - if (mKeychainServiceListener.hasServiceStopped()) { - arOutStream.close(); - return null; - } - arOutStream.close(); } @@ -306,11 +281,6 @@ public class PgpImportExport { // TODO: inform user? } - if (mKeychainServiceListener.hasServiceStopped()) { - arOutStream.close(); - return null; - } - arOutStream.close(); } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 2073d6a6c..a5b672e7e 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -82,8 +82,7 @@ import java.util.concurrent.atomic.AtomicBoolean; * data from the activities or other apps, queues these intents, executes them, and stops itself * after doing them. */ -public class KeychainIntentService extends IntentService - implements Progressable, PgpImportExport.KeychainServiceListener { +public class KeychainIntentService extends IntentService implements Progressable { /* extras that can be given by intent */ public static final String EXTRA_MESSENGER = "messenger"; @@ -201,7 +200,6 @@ public class KeychainIntentService extends IntentService Messenger mMessenger; - private boolean mIsCanceled; // this attribute can possibly merged with the one above? not sure... private AtomicBoolean mActionCanceled = new AtomicBoolean(false); @@ -209,12 +207,6 @@ public class KeychainIntentService extends IntentService super("KeychainIntentService"); } - @Override - public void onDestroy() { - super.onDestroy(); - this.mIsCanceled = true; - } - /** * The IntentService calls this method from the default worker thread with the intent that * started the service. When this method returns, IntentService stops the service, as @@ -598,12 +590,11 @@ public class KeychainIntentService extends IntentService outStream = getContentResolver().openOutputStream(outputUri); } - PgpImportExport pgpImportExport = new PgpImportExport(this, this, this); + PgpImportExport pgpImportExport = new PgpImportExport(this, new ProviderHelper(this), this); Bundle resultData = pgpImportExport - .exportKeyRings(publicMasterKeyIds, secretMasterKeyIds, - outStream); + .exportKeyRings(publicMasterKeyIds, secretMasterKeyIds, outStream); - if (mIsCanceled && outputFile != null) { + if (mActionCanceled.get() && outputFile != null) { new File(outputFile).delete(); } @@ -623,7 +614,7 @@ public class KeychainIntentService extends IntentService ProviderHelper providerHelper = new ProviderHelper(this); CanonicalizedPublicKeyRing keyring = providerHelper.getCanonicalizedPublicKeyRing(dataUri); - PgpImportExport pgpImportExport = new PgpImportExport(this, null); + PgpImportExport pgpImportExport = new PgpImportExport(this, new ProviderHelper(this), this); try { pgpImportExport.uploadKeyRingToServer(server, keyring); @@ -740,8 +731,7 @@ public class KeychainIntentService extends IntentService } if (isSecret && success) { - ConsolidateResult result = - new ProviderHelper(this).consolidateDatabaseStep1(this); + new ProviderHelper(this).consolidateDatabaseStep1(this); } if (success) { @@ -768,10 +758,6 @@ public class KeychainIntentService extends IntentService } private void sendErrorToHandler(Exception e) { - // Service was canceled. Do not send error to handler. - if (this.mIsCanceled) { - return; - } // TODO: Implement a better exception handling here // contextualize the exception, if necessary String message; @@ -806,10 +792,7 @@ public class KeychainIntentService extends IntentService } private void sendMessageToHandler(Integer arg1, Integer arg2, Bundle data) { - // Service was canceled. Do not send message to handler. - if (this.mIsCanceled) { - return; - } + Message msg = Message.obtain(); assert msg != null; msg.arg1 = arg1; @@ -868,11 +851,6 @@ public class KeychainIntentService extends IntentService setProgress(null, progress, max); } - @Override - public boolean hasServiceStopped() { - return mIsCanceled; - } - private InputData createDecryptInputData(Bundle data) throws IOException, PgpGeneralException { return createCryptInputData(data, DECRYPT_CIPHERTEXT_BYTES); } |