aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2014-10-26 22:00:57 +0100
committerVincent Breitmoser <valodim@mugenguild.com>2014-10-26 22:00:57 +0100
commit082722a3cfbae408ae3df1f27b191c62a212ff2b (patch)
tree147261c28d52c2477b0df036e9bedf62c52bd209 /OpenKeychain
parentb8ed54bc699978355ffb5e9802902c6bc19a2e7a (diff)
downloadopen-keychain-082722a3cfbae408ae3df1f27b191c62a212ff2b.tar.gz
open-keychain-082722a3cfbae408ae3df1f27b191c62a212ff2b.tar.bz2
open-keychain-082722a3cfbae408ae3df1f27b191c62a212ff2b.zip
prevent cancel dring consolidate, move logic into progressable
Diffstat (limited to 'OpenKeychain')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/Progressable.java2
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java3
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java8
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ProgressScaler.java6
4 files changed, 17 insertions, 2 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/Progressable.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/Progressable.java
index fd3e2db8f..5de69b887 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/Progressable.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/Progressable.java
@@ -23,4 +23,6 @@ public interface Progressable {
void setProgress(int resourceId, int current, int total);
void setProgress(int current, int total);
+
+ void setPreventCancel();
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java
index 46f294866..ce9a14a6f 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/ProviderHelper.java
@@ -938,6 +938,9 @@ public class ProviderHelper {
progress.setProgress(R.string.progress_con_saving, 0, 100);
+ // The consolidate operation can never be cancelled!
+ progress.setPreventCancel();
+
try {
log.add(LogType.MSG_CON_SAVE_SECRET, indent);
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 044656a31..a2988f2b2 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/KeychainIntentService.java
@@ -472,8 +472,7 @@ public class KeychainIntentService extends IntentService implements Progressable
// Special: consolidate on secret key import (cannot be cancelled!)
if (result.mSecret > 0) {
- // cannot cancel from here on out!
- sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_PREVENT_CANCEL);
+ // TODO move this into the import operation
providerHelper.consolidateDatabaseStep1(this);
}
@@ -676,6 +675,11 @@ public class KeychainIntentService extends IntentService implements Progressable
setProgress(null, progress, max);
}
+ @Override
+ public void setPreventCancel() {
+ sendMessageToHandler(KeychainIntentServiceHandler.MESSAGE_PREVENT_CANCEL);
+ }
+
private InputData createDecryptInputData(Bundle data) throws IOException, PgpGeneralException {
return createCryptInputData(data, DECRYPT_CIPHERTEXT_BYTES);
}
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ProgressScaler.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ProgressScaler.java
index 5256f5212..6bec9ccab 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ProgressScaler.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/util/ProgressScaler.java
@@ -60,4 +60,10 @@ public class ProgressScaler implements Progressable {
}
}
+ @Override
+ public void setPreventCancel() {
+ if (mWrapped != null) {
+ mWrapped.setPreventCancel();
+ }
+ }
}