add "external" state for keys from non-autocrypt inputs
This commit is contained in:
@@ -309,12 +309,30 @@ public class OpenPgpService extends Service {
|
||||
|
||||
AutocryptState combinedAutocryptState = keyIdResult.getCombinedAutocryptState();
|
||||
if (combinedAutocryptState == null) {
|
||||
result.putExtra(OpenPgpApi.RESULT_AUTOCRYPT_STATUS, OpenPgpApi.AUTOCRYPT_STATUS_UNAVAILABLE);
|
||||
switch (keyIdResult.getStatus()) {
|
||||
case NO_KEYS:
|
||||
case NO_KEYS_ERROR:
|
||||
case MISSING: {
|
||||
result.putExtra(OpenPgpApi.RESULT_AUTOCRYPT_STATUS, OpenPgpApi.AUTOCRYPT_STATUS_UNAVAILABLE);
|
||||
break;
|
||||
}
|
||||
case DUPLICATE: {
|
||||
if (keyIdResult.hasKeySelectionPendingIntent()) {
|
||||
result.putExtra(OpenPgpApi.RESULT_INTENT, keyIdResult.getKeySelectionPendingIntent());
|
||||
}
|
||||
result.putExtra(OpenPgpApi.RESULT_AUTOCRYPT_STATUS, OpenPgpApi.AUTOCRYPT_STATUS_DISCOURAGE);
|
||||
break;
|
||||
}
|
||||
case OK: {
|
||||
result.putExtra(OpenPgpApi.RESULT_AUTOCRYPT_STATUS, OpenPgpApi.AUTOCRYPT_STATUS_DISCOURAGE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
switch (combinedAutocryptState) {
|
||||
case EXTERNAL:
|
||||
case GOSSIP:
|
||||
case RESET: {
|
||||
result.putExtra(OpenPgpApi.RESULT_AUTOCRYPT_STATUS, OpenPgpApi.AUTOCRYPT_STATUS_DISCOURAGE);
|
||||
@@ -325,7 +343,7 @@ public class OpenPgpService extends Service {
|
||||
break;
|
||||
}
|
||||
case MUTUAL: {
|
||||
result.putExtra(OpenPgpApi.RESULT_AUTOCRYPT_STATUS, OpenPgpApi.AUTOCRYPT_STATUS_RECOMMEND);
|
||||
result.putExtra(OpenPgpApi.RESULT_AUTOCRYPT_STATUS, OpenPgpApi.AUTOCRYPT_STATUS_MUTUAL);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
||||
@@ -123,6 +123,7 @@ class OpenPgpServiceKeyIdExtractor {
|
||||
|
||||
if (addressQueryResult.uidMasterKeyId != null) {
|
||||
keyIds.add(addressQueryResult.uidMasterKeyId);
|
||||
combinedAutocryptState = AutocryptState.EXTERNAL;
|
||||
|
||||
if (addressQueryResult.uidHasMultipleCandidates) {
|
||||
duplicateEmails.add(queriedAddress);
|
||||
@@ -219,7 +220,7 @@ class OpenPgpServiceKeyIdExtractor {
|
||||
}
|
||||
|
||||
enum AutocryptState {
|
||||
RESET, GOSSIP, AVAILABLE, MUTUAL;
|
||||
EXTERNAL, RESET, GOSSIP, AVAILABLE, MUTUAL;
|
||||
|
||||
static AutocryptState fromDbValue(int state) {
|
||||
switch (state) {
|
||||
@@ -237,6 +238,9 @@ class OpenPgpServiceKeyIdExtractor {
|
||||
}
|
||||
|
||||
public AutocryptState combineWith(AutocryptState other) {
|
||||
if (this == EXTERNAL || other == EXTERNAL) {
|
||||
return EXTERNAL;
|
||||
}
|
||||
if (this == RESET || other == RESET) {
|
||||
return RESET;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user