Fix for old-skool SMS key exchange UI behavior.

Also fixes SMS "end session" messages failing to end session.

// FREEBIE
This commit is contained in:
Moxie Marlinspike 2014-12-29 15:09:13 -08:00
parent 4d8004ab21
commit bec5e45605
2 changed files with 8 additions and 4 deletions

View File

@ -70,10 +70,10 @@ public class SmsDecryptJob extends MasterSecretJob {
long messageId = record.getId(); long messageId = record.getId();
long threadId = record.getThreadId(); long threadId = record.getThreadId();
if (message.isSecureMessage()) handleSecureMessage(masterSecret, messageId, message); if (message.isSecureMessage()) handleSecureMessage(masterSecret, messageId, threadId, message);
else if (message.isPreKeyBundle()) handlePreKeyWhisperMessage(masterSecret, messageId, threadId, (IncomingPreKeyBundleMessage) message); else if (message.isPreKeyBundle()) handlePreKeyWhisperMessage(masterSecret, messageId, threadId, (IncomingPreKeyBundleMessage) message);
else if (message.isKeyExchange()) handleKeyExchangeMessage(masterSecret, messageId, threadId, (IncomingKeyExchangeMessage) message); else if (message.isKeyExchange()) handleKeyExchangeMessage(masterSecret, messageId, threadId, (IncomingKeyExchangeMessage) message);
else if (message.isEndSession()) handleSecureMessage(masterSecret, messageId, message); else if (message.isEndSession()) handleSecureMessage(masterSecret, messageId, threadId, message);
else database.updateMessageBody(masterSecret, messageId, message.getMessageBody()); else database.updateMessageBody(masterSecret, messageId, message.getMessageBody());
MessageNotifier.updateNotification(context, masterSecret); MessageNotifier.updateNotification(context, masterSecret);
@ -102,7 +102,8 @@ public class SmsDecryptJob extends MasterSecretJob {
// TODO // TODO
} }
private void handleSecureMessage(MasterSecret masterSecret, long messageId, IncomingTextMessage message) private void handleSecureMessage(MasterSecret masterSecret, long messageId, long threadId,
IncomingTextMessage message)
throws NoSessionException, DuplicateMessageException, throws NoSessionException, DuplicateMessageException,
InvalidMessageException, LegacyMessageException InvalidMessageException, LegacyMessageException
{ {
@ -111,6 +112,8 @@ public class SmsDecryptJob extends MasterSecretJob {
IncomingTextMessage plaintext = cipher.decrypt(context, message); IncomingTextMessage plaintext = cipher.decrypt(context, message);
database.updateMessageBody(masterSecret, messageId, plaintext.getMessageBody()); database.updateMessageBody(masterSecret, messageId, plaintext.getMessageBody());
if (message.isEndSession()) SecurityEvent.broadcastSecurityUpdateEvent(context, threadId);
} }
private void handlePreKeyWhisperMessage(MasterSecret masterSecret, long messageId, long threadId, private void handlePreKeyWhisperMessage(MasterSecret masterSecret, long messageId, long threadId,
@ -147,6 +150,7 @@ public class SmsDecryptJob extends MasterSecretJob {
database.markAsProcessedKeyExchange(messageId); database.markAsProcessedKeyExchange(messageId);
SecurityEvent.broadcastSecurityUpdateEvent(context, threadId);
if (response != null) { if (response != null) {
MessageSender.send(context, masterSecret, response, threadId, true); MessageSender.send(context, masterSecret, response, threadId, true);

View File

@ -73,7 +73,7 @@ public class SmsReceiveJob extends ContextJob {
messageAndThreadId = database.insertMessageInbox(masterSecret, message); messageAndThreadId = database.insertMessageInbox(masterSecret, message);
} }
if (masterSecret == null || message.isSecureMessage() || message.isKeyExchange()) { if (masterSecret == null || message.isSecureMessage() || message.isKeyExchange() || message.isEndSession()) {
ApplicationContext.getInstance(context) ApplicationContext.getInstance(context)
.getJobManager() .getJobManager()
.add(new SmsDecryptJob(context, messageAndThreadId.first)); .add(new SmsDecryptJob(context, messageAndThreadId.first));