Better UX handling on identity key mismatches.

1) Migrate from GSON to Jackson everywhere.

2) Add support for storing identity key conflicts on message rows.

3) Add limited support for surfacing identity key conflicts in UI.
This commit is contained in:
Moxie Marlinspike
2015-01-15 13:35:35 -08:00
parent 4397b55ceb
commit 00d7b5c284
76 changed files with 2395 additions and 721 deletions

View File

@@ -23,6 +23,11 @@ import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import org.thoughtcrime.securesms.recipients.Recipient;
import org.thoughtcrime.securesms.recipients.RecipientFactory;
import org.thoughtcrime.securesms.recipients.RecipientFormattingException;
import org.thoughtcrime.securesms.recipients.Recipients;
import ws.com.google.android.mms.pdu.CharacterSets;
import ws.com.google.android.mms.pdu.EncodedStringValue;
import ws.com.google.android.mms.pdu.PduHeaders;
@@ -33,6 +38,8 @@ import java.util.List;
public class MmsAddressDatabase extends Database {
private static final String TAG = MmsAddressDatabase.class.getSimpleName();
private static final String TABLE_NAME = "mms_addresses";
private static final String ID = "_id";
private static final String MMS_ID = "mms_id";
@@ -127,6 +134,25 @@ public class MmsAddressDatabase extends Database {
return results;
}
public Recipients getRecipientsForId(long messageId) {
List<String> numbers = getAddressesForId(messageId);
List<Recipient> results = new LinkedList<>();
for (String number : numbers) {
if (!PduHeaders.FROM_INSERT_ADDRESS_TOKEN_STR.equals(number)) {
try {
results.add(RecipientFactory.getRecipientsFromString(context, number, false)
.getPrimaryRecipient());
} catch (RecipientFormattingException e) {
Log.w(TAG, e);
}
}
}
return new Recipients(results);
}
public void deleteAddressesForId(long messageId) {
SQLiteDatabase database = databaseHelper.getWritableDatabase();
database.delete(TABLE_NAME, MMS_ID + " = ?", new String[] {messageId+""});