Properly return unknown recipient from SMS db on empty.

This commit is contained in:
Moxie Marlinspike 2013-05-21 10:23:27 -07:00
parent 018f5eccf3
commit 3df67a1643
2 changed files with 13 additions and 6 deletions

View File

@ -434,7 +434,14 @@ public class SmsDatabase extends Database implements MmsSmsColumns {
private Recipients getRecipientsFor(String address) {
try {
return RecipientFactory.getRecipientsFromString(context, address, false);
Recipients recipients = RecipientFactory.getRecipientsFromString(context, address, false);
if (recipients == null || recipients.isEmpty()) {
return new Recipients(new Recipient("Unknown", "Unknown", null,
ContactPhotoFactory.getDefaultContactPhoto(context)));
}
return recipients;
} catch (RecipientFormattingException e) {
Log.w("EncryptingSmsDatabase", e);
return new Recipients(new Recipient("Unknown", "Unknown", null,

View File

@ -64,11 +64,11 @@ public class Recipients implements Parcelable {
this.recipients.addAll(recipients.getRecipientsList());
}
public Recipients truncateToSingleRecipient() {
assert(!this.recipients.isEmpty());
this.recipients = this.recipients.subList(0, 1);
return this;
}
// public Recipients truncateToSingleRecipient() {
// assert(!this.recipients.isEmpty());
// this.recipients = this.recipients.subList(0, 1);
// return this;
// }
public void addListener(RecipientModifiedListener listener) {
for (Recipient recipient : recipients) {