aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java
diff options
context:
space:
mode:
authorDominik Schürmann <dominik@dominikschuermann.de>2013-09-09 19:46:18 +0200
committerDominik Schürmann <dominik@dominikschuermann.de>2013-09-09 19:46:18 +0200
commit6693b8b75d1180906ef860ecbfed28d486aeef90 (patch)
treead52bb2decf366076c4a6392f93a371ac124df37 /OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java
parent8a8d7c7738f62eb66e41f7598a5e23a50b2f0821 (diff)
downloadopen-keychain-6693b8b75d1180906ef860ecbfed28d486aeef90.tar.gz
open-keychain-6693b8b75d1180906ef860ecbfed28d486aeef90.tar.bz2
open-keychain-6693b8b75d1180906ef860ecbfed28d486aeef90.zip
Handle no selection of pub keys correctly
Diffstat (limited to 'OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java')
-rw-r--r--OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java20
1 files changed, 14 insertions, 6 deletions
diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java
index 8ff229af0..6d83857e7 100644
--- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java
+++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/remote_api/CryptoService.java
@@ -207,25 +207,29 @@ public class CryptoService extends Service {
pauseQueueAndStartServiceActivity(CryptoServiceActivity.ACTION_SELECT_PUB_KEYS,
messenger, extras);
- if (callback.isNewSelection()) {
+ if (callback.isSuccess()) {
Log.d(Constants.TAG, "New selection of pub keys!");
keyIdsArray = callback.getPubKeyIds();
} else {
Log.d(Constants.TAG, "Pub key selection canceled!");
+ return null;
}
}
+ if (keyIdsArray.length == 0) {
+ return null;
+ }
return keyIdsArray;
}
public class SelectPubKeysActivityCallback extends MyBaseCallback {
public static final String PUB_KEY_IDS = "pub_key_ids";
- private boolean newSelection = false;
+ private boolean success = false;
private long[] pubKeyIds;
- public boolean isNewSelection() {
- return newSelection;
+ public boolean isSuccess() {
+ return success;
}
public long[] getPubKeyIds() {
@@ -235,10 +239,10 @@ public class CryptoService extends Service {
@Override
public boolean handleMessage(Message msg) {
if (msg.arg1 == OKAY) {
- newSelection = true;
+ success = true;
pubKeyIds = msg.getData().getLongArray(PUB_KEY_IDS);
} else {
- newSelection = false;
+ success = false;
}
// resume
@@ -262,6 +266,10 @@ public class CryptoService extends Service {
OutputStream outputStream = new ByteArrayOutputStream();
long[] keyIds = getKeyIdsFromEmails(encryptionUserIds, appSettings.getKeyId());
+ if (keyIds == null) {
+ callback.onError(new CryptoError(CryptoError.ID_NO_USER_IDS, "No user ids!"));
+ return;
+ }
if (sign) {
String passphrase = getCachedPassphrase(appSettings.getKeyId());