Merge pull request #2564 from yushijinhun/fix-decryption-blocked

Give up PGP decryption when intent is cancelled
This commit is contained in:
Daniel Gultsch 2017-07-25 09:20:51 +02:00 committed by GitHub
commit d6e51288c3
2 changed files with 26 additions and 0 deletions

View File

@ -69,6 +69,27 @@ public class PgpDecryptionService {
this.pendingNotifications.remove(message); this.pendingNotifications.remove(message);
} }
public void giveUpCurrentDecryption(){
Message message;
synchronized (this) {
if(currentMessage != null) {
return;
}
message = messages.peekFirst();
if (message == null) {
return;
}
discard(message);
}
synchronized (message){
if (message.getEncryption() == Message.ENCRYPTION_PGP) {
message.setEncryption(Message.ENCRYPTION_DECRYPTION_FAILED);
}
}
mXmppConnectionService.updateMessage(message);
continueDecryption(true);
}
protected synchronized void decryptNext() { protected synchronized void decryptNext() {
if (pendingIntent == null if (pendingIntent == null
&& getOpenPgpApi() != null && getOpenPgpApi() != null

View File

@ -1658,6 +1658,11 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
int choice = data.getIntExtra("choice", ConversationActivity.ATTACHMENT_CHOICE_INVALID); int choice = data.getIntExtra("choice", ConversationActivity.ATTACHMENT_CHOICE_INVALID);
activity.selectPresenceToAttachFile(choice, conversation.getNextEncryption()); activity.selectPresenceToAttachFile(choice, conversation.getNextEncryption());
} }
} else if (resultCode == Activity.RESULT_CANCELED) {
if (requestCode == ConversationActivity.REQUEST_DECRYPT_PGP) {
// discard the message to prevent decryption being blocked
conversation.getAccount().getPgpDecryptionService().giveUpCurrentDecryption();
}
} }
} }