Skip to content

Commit

Permalink
Fix for notification NPE on unknown sender.
Browse files Browse the repository at this point in the history
  • Loading branch information
moxie0 committed Feb 21, 2013
1 parent f73adfc commit 5bf5b40
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/org/thoughtcrime/securesms/notifications/MessageNotifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ private static CharSequence getBody(Context context, MasterSecret masterSecret,
private static Recipients getSmsRecipient(Context context, Cursor cursor)
throws RecipientFormattingException
{
String address = cursor.getString(cursor.getColumnIndexOrThrow(SmsDatabase.ADDRESS));
String address = cursor.getString(cursor.getColumnIndexOrThrow(SmsDatabase.ADDRESS));
return RecipientFactory.getRecipientsFromString(context, address, false);
}

Expand All @@ -305,19 +305,27 @@ private static Recipients getMmsRecipient(Context context, Cursor cursor)
}

private static Recipients getRecipients(Context context, Cursor cursor) {
String type = cursor.getString(cursor.getColumnIndexOrThrow(MmsSmsDatabase.TRANSPORT));
String type = cursor.getString(cursor.getColumnIndexOrThrow(MmsSmsDatabase.TRANSPORT));
Recipients recipients = null;

try {
if (type.equals("sms")) {
return getSmsRecipient(context, cursor);
recipients = getSmsRecipient(context, cursor);
} else {
return getMmsRecipient(context, cursor);
recipients = getMmsRecipient(context, cursor);
}
} catch (RecipientFormattingException e) {
Log.w("MessageNotifier", e);
return new Recipients(new Recipient("Unknown", "Unknown", null,
ContactPhotoFactory.getDefaultContactPhoto(context)));
}

if (recipients == null || recipients.isEmpty()) {
recipients = new Recipients(new Recipient("Unknown", "Unknown", null,
ContactPhotoFactory.getDefaultContactPhoto(context)));
}

return recipients;
}

private static void setNotificationAlarms(Context context,
Expand Down

0 comments on commit 5bf5b40

Please sign in to comment.