Also check cc for duplicates

This commit is contained in:
Pat McLaughlin 2014-03-12 20:45:21 -04:00 committed by Patrick McLaughlin
parent 64711771f0
commit d229a4274c

View File

@ -201,13 +201,6 @@ public class MmsDatabase extends Database implements MmsSmsColumns {
group.add(new String(encodedFrom.getTextString(), CharacterSets.MIMENAME_ISO_8859_1)); group.add(new String(encodedFrom.getTextString(), CharacterSets.MIMENAME_ISO_8859_1));
if (encodedCcList != null) {
for (EncodedStringValue encodedCc : encodedCcList) {
group.add(new String(encodedCc.getTextString(), CharacterSets.MIMENAME_ISO_8859_1));
}
}
if (encodedToList != null && (encodedToList.length > 1 || group.size() > 1)) {
TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE); TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
String localNumber = telephonyManager.getLine1Number(); String localNumber = telephonyManager.getLine1Number();
@ -215,6 +208,24 @@ public class MmsDatabase extends Database implements MmsSmsColumns {
localNumber = TextSecurePreferences.getLocalNumber(context); localNumber = TextSecurePreferences.getLocalNumber(context);
} }
if (encodedCcList != null) {
for (EncodedStringValue encodedCc : encodedCcList) {
String cc = new String(encodedCc.getTextString(), CharacterSets.MIMENAME_ISO_8859_1);
PhoneNumberUtil.MatchType match;
if (localNumber == null) match = PhoneNumberUtil.MatchType.NO_MATCH;
else match = PhoneNumberUtil.getInstance().isNumberMatch(localNumber, cc);
if (match == PhoneNumberUtil.MatchType.NO_MATCH ||
match == PhoneNumberUtil.MatchType.NOT_A_NUMBER)
{
group.add(cc);
}
}
}
if (encodedToList != null && (encodedToList.length > 1 || group.size() > 1)) {
for (EncodedStringValue encodedTo : encodedToList) { for (EncodedStringValue encodedTo : encodedToList) {
String to = new String(encodedTo.getTextString(), CharacterSets.MIMENAME_ISO_8859_1); String to = new String(encodedTo.getTextString(), CharacterSets.MIMENAME_ISO_8859_1);