Fix for MMS decoding when no SIM is available.

This commit is contained in:
Moxie Marlinspike 2014-02-20 17:32:01 -08:00
parent ff238a1ce9
commit 3ca25de034

View File

@ -28,6 +28,7 @@ import android.util.Pair;
import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.mms.OutgoingGroupMediaMessage; import org.thoughtcrime.securesms.mms.OutgoingGroupMediaMessage;
import org.thoughtcrime.securesms.mms.OutgoingMediaMessage; import org.thoughtcrime.securesms.mms.OutgoingMediaMessage;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.whispersystems.textsecure.crypto.InvalidMessageException; import org.whispersystems.textsecure.crypto.InvalidMessageException;
import org.whispersystems.textsecure.crypto.MasterCipher; import org.whispersystems.textsecure.crypto.MasterCipher;
import org.whispersystems.textsecure.crypto.MasterSecret; import org.whispersystems.textsecure.crypto.MasterSecret;
@ -203,13 +204,18 @@ public class MmsDatabase extends Database implements MmsSmsColumns {
} }
} }
if (encodedToList != null) { if (encodedToList != null && (encodedToList.length > 1 || group.size() > 1)) {
String localNumber = Util.getDeviceE164Number(context); String localNumber = Util.getDeviceE164Number(context);
if (localNumber == null) {
localNumber = TextSecurePreferences.getLocalNumber(context);
}
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);
if (!localNumber.equals(to)) { /// TODO format numbers before comparing.
if (localNumber == null || !localNumber.equals(to)) {
group.add(to); group.add(to);
} }
} }