diff options
author | Jessica Yuen <jyuen@ualberta.ca> | 2014-03-03 23:04:55 -0500 |
---|---|---|
committer | Jessica Yuen <jyuen@ualberta.ca> | 2014-03-03 23:04:55 -0500 |
commit | af6713dc78448b7686a546d77c022f4aacd58dfb (patch) | |
tree | 3356f29381767602bd97e436c9444b1a6bc01dd7 /OpenPGP-Keychain/src | |
parent | e4e3c555e9ac89cffad594dfc922715309b3b299 (diff) | |
download | open-keychain-af6713dc78448b7686a546d77c022f4aacd58dfb.tar.gz open-keychain-af6713dc78448b7686a546d77c022f4aacd58dfb.tar.bz2 open-keychain-af6713dc78448b7686a546d77c022f4aacd58dfb.zip |
#226: Small fix to prevent message from being sent if IntentService is canceled
Diffstat (limited to 'OpenPGP-Keychain/src')
-rw-r--r-- | OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java index 3904a91d8..302dbea0b 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java @@ -203,10 +203,18 @@ public class KeychainIntentService extends IntentService implements ProgressDial Messenger mMessenger; + private boolean mIsCanceled; + public KeychainIntentService() { super("ApgService"); } + @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 @@ -815,6 +823,10 @@ public class KeychainIntentService extends IntentService implements ProgressDial } private void sendErrorToHandler(Exception e) { + // Service was canceled. Do not send error to handler. + if (this.mIsCanceled) + return; + Log.e(Constants.TAG, "ApgService Exception: ", e); e.printStackTrace(); @@ -824,6 +836,10 @@ public class KeychainIntentService extends IntentService implements ProgressDial } 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(); msg.arg1 = arg1; if (arg2 != null) { |