Commit fa60a1ca authored by Moxie Marlinspike's avatar Moxie Marlinspike Committed by Bastien Le Querrec
Browse files
parent 394eb521
Pipeline #192 passed with stages
in 8 minutes and 20 seconds
...@@ -489,23 +489,16 @@ public class ConversationItem extends LinearLayout ...@@ -489,23 +489,16 @@ public class ConversationItem extends LinearLayout
contactPhoto.setVisibility(View.VISIBLE); contactPhoto.setVisibility(View.VISIBLE);
} }
private IdentityKeyMismatch getKeyMismatch(final MessageRecord record) {
if (record.isIdentityMismatchFailure()) {
Log.w(TAG, "isIdentityMismatchFailure(): true");
for (final IdentityKeyMismatch mismatch : record.getIdentityKeyMismatches()) {
if (mismatch.getRecipientId() == record.getIndividualRecipient().getRecipientId()) {
return mismatch;
}
}
}
Log.w(TAG, "Returning null IdentityKeyMismatch...");
return null;
}
/// Event handlers /// Event handlers
private void handleKeyExchangeClicked() { private void handleApproveIdentity() {
new ConfirmIdentityDialog(context, masterSecret, messageRecord, getKeyMismatch(messageRecord)).show(); List<IdentityKeyMismatch> mismatches = messageRecord.getIdentityKeyMismatches();
if (mismatches.size() != 1) {
throw new AssertionError("Identity mismatch count: " + mismatches.size());
}
new ConfirmIdentityDialog(context, masterSecret, messageRecord, mismatches.get(0)).show();
} }
private void handleLegacyKeyExchangeClicked() { private void handleLegacyKeyExchangeClicked() {
...@@ -627,13 +620,8 @@ public class ConversationItem extends LinearLayout ...@@ -627,13 +620,8 @@ public class ConversationItem extends LinearLayout
intent.putExtra(MessageDetailsActivity.TYPE_EXTRA, messageRecord.isMms() ? MmsSmsDatabase.MMS_TRANSPORT : MmsSmsDatabase.SMS_TRANSPORT); intent.putExtra(MessageDetailsActivity.TYPE_EXTRA, messageRecord.isMms() ? MmsSmsDatabase.MMS_TRANSPORT : MmsSmsDatabase.SMS_TRANSPORT);
intent.putExtra(MessageDetailsActivity.RECIPIENTS_IDS_EXTRA, conversationRecipients.getIds()); intent.putExtra(MessageDetailsActivity.RECIPIENTS_IDS_EXTRA, conversationRecipients.getIds());
context.startActivity(intent); context.startActivity(intent);
} else if (messageRecord.isKeyExchange() && } else if (!messageRecord.isOutgoing() && messageRecord.isIdentityMismatchFailure()) {
!messageRecord.isOutgoing() && handleApproveIdentity();
!messageRecord.isProcessedKeyExchange() &&
!messageRecord.isStaleKeyExchange() &&
!messageRecord.isLegacyMessage())
{
handleKeyExchangeClicked();
} else if (shouldInterceptKeyExchangeMessage(messageRecord)) { } else if (shouldInterceptKeyExchangeMessage(messageRecord)) {
handleLegacyKeyExchangeClicked(); handleLegacyKeyExchangeClicked();
} }
......
...@@ -30,6 +30,27 @@ public abstract class MessagingDatabase extends Database implements MmsSmsColumn ...@@ -30,6 +30,27 @@ public abstract class MessagingDatabase extends Database implements MmsSmsColumn
protected abstract String getTableName(); protected abstract String getTableName();
public void setMismatchedIdentity(long messageId, final long recipientId, final IdentityKey identityKey) {
List<IdentityKeyMismatch> items = new ArrayList<IdentityKeyMismatch>() {{
add(new IdentityKeyMismatch(recipientId, identityKey));
}};
IdentityKeyMismatchList document = new IdentityKeyMismatchList(items);
SQLiteDatabase database = databaseHelper.getWritableDatabase();
database.beginTransaction();
try {
setDocument(database, messageId, MISMATCHED_IDENTITIES, document);
database.setTransactionSuccessful();
} catch (IOException ioe) {
Log.w(TAG, ioe);
} finally {
database.endTransaction();
}
}
public void addMismatchedIdentity(long messageId, long recipientId, IdentityKey identityKey) { public void addMismatchedIdentity(long messageId, long recipientId, IdentityKey identityKey) {
try { try {
addToDocument(messageId, MISMATCHED_IDENTITIES, addToDocument(messageId, MISMATCHED_IDENTITIES,
...@@ -133,7 +154,9 @@ public abstract class MessagingDatabase extends Database implements MmsSmsColumn ...@@ -133,7 +154,9 @@ public abstract class MessagingDatabase extends Database implements MmsSmsColumn
try { try {
return clazz.newInstance(); return clazz.newInstance();
} catch (InstantiationException | IllegalAccessException e) { } catch (InstantiationException e) {
throw new AssertionError(e);
} catch (IllegalAccessException e) {
throw new AssertionError(e); throw new AssertionError(e);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment