mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-16 05:45:04 -05:00
Handle no selection of pub keys correctly
This commit is contained in:
parent
8a8d7c7738
commit
6693b8b75d
@ -21,6 +21,7 @@ import android.os.Parcelable;
|
|||||||
|
|
||||||
public class CryptoError implements Parcelable {
|
public class CryptoError implements Parcelable {
|
||||||
public static final int ID_NO_WRONG_PASSPHRASE = 1;
|
public static final int ID_NO_WRONG_PASSPHRASE = 1;
|
||||||
|
public static final int ID_NO_USER_IDS = 2;
|
||||||
|
|
||||||
int errorId;
|
int errorId;
|
||||||
String message;
|
String message;
|
||||||
|
@ -207,25 +207,29 @@ public class CryptoService extends Service {
|
|||||||
pauseQueueAndStartServiceActivity(CryptoServiceActivity.ACTION_SELECT_PUB_KEYS,
|
pauseQueueAndStartServiceActivity(CryptoServiceActivity.ACTION_SELECT_PUB_KEYS,
|
||||||
messenger, extras);
|
messenger, extras);
|
||||||
|
|
||||||
if (callback.isNewSelection()) {
|
if (callback.isSuccess()) {
|
||||||
Log.d(Constants.TAG, "New selection of pub keys!");
|
Log.d(Constants.TAG, "New selection of pub keys!");
|
||||||
keyIdsArray = callback.getPubKeyIds();
|
keyIdsArray = callback.getPubKeyIds();
|
||||||
} else {
|
} else {
|
||||||
Log.d(Constants.TAG, "Pub key selection canceled!");
|
Log.d(Constants.TAG, "Pub key selection canceled!");
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (keyIdsArray.length == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return keyIdsArray;
|
return keyIdsArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SelectPubKeysActivityCallback extends MyBaseCallback {
|
public class SelectPubKeysActivityCallback extends MyBaseCallback {
|
||||||
public static final String PUB_KEY_IDS = "pub_key_ids";
|
public static final String PUB_KEY_IDS = "pub_key_ids";
|
||||||
|
|
||||||
private boolean newSelection = false;
|
private boolean success = false;
|
||||||
private long[] pubKeyIds;
|
private long[] pubKeyIds;
|
||||||
|
|
||||||
public boolean isNewSelection() {
|
public boolean isSuccess() {
|
||||||
return newSelection;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long[] getPubKeyIds() {
|
public long[] getPubKeyIds() {
|
||||||
@ -235,10 +239,10 @@ public class CryptoService extends Service {
|
|||||||
@Override
|
@Override
|
||||||
public boolean handleMessage(Message msg) {
|
public boolean handleMessage(Message msg) {
|
||||||
if (msg.arg1 == OKAY) {
|
if (msg.arg1 == OKAY) {
|
||||||
newSelection = true;
|
success = true;
|
||||||
pubKeyIds = msg.getData().getLongArray(PUB_KEY_IDS);
|
pubKeyIds = msg.getData().getLongArray(PUB_KEY_IDS);
|
||||||
} else {
|
} else {
|
||||||
newSelection = false;
|
success = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// resume
|
// resume
|
||||||
@ -262,6 +266,10 @@ public class CryptoService extends Service {
|
|||||||
OutputStream outputStream = new ByteArrayOutputStream();
|
OutputStream outputStream = new ByteArrayOutputStream();
|
||||||
|
|
||||||
long[] keyIds = getKeyIdsFromEmails(encryptionUserIds, appSettings.getKeyId());
|
long[] keyIds = getKeyIdsFromEmails(encryptionUserIds, appSettings.getKeyId());
|
||||||
|
if (keyIds == null) {
|
||||||
|
callback.onError(new CryptoError(CryptoError.ID_NO_USER_IDS, "No user ids!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (sign) {
|
if (sign) {
|
||||||
String passphrase = getCachedPassphrase(appSettings.getKeyId());
|
String passphrase = getCachedPassphrase(appSettings.getKeyId());
|
||||||
|
Loading…
Reference in New Issue
Block a user