Only attempt MMS "direct connect" on Sprint MCCMNCs.

Fixes #5134
// FREEBIE
This commit is contained in:
Moxie Marlinspike 2016-01-30 14:16:50 -08:00
parent cf223e9ba2
commit 873a0ab249
3 changed files with 21 additions and 10 deletions

View File

@ -65,7 +65,8 @@ public class IncomingLegacyMmsConnection extends LegacyMmsConnection implements
{
MmsRadio radio = MmsRadio.getInstance(context);
Apn contentApn = new Apn(contentLocation, apn.getProxy(), Integer.toString(apn.getPort()), apn.getUsername(), apn.getPassword());
if (isCdmaDevice()) {
if (isDirectConnect()) {
Log.w(TAG, "Connecting directly...");
try {
return retrieve(contentApn, transactionId, false, false);

View File

@ -18,8 +18,6 @@ package org.thoughtcrime.securesms.mms;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.support.annotation.Nullable;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
@ -39,14 +37,12 @@ import org.apache.http.impl.client.LaxRedirectStrategy;
import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
import org.apache.http.message.BasicHeader;
import org.thoughtcrime.securesms.database.ApnDatabase;
import org.thoughtcrime.securesms.util.TelephonyUtil;
import org.thoughtcrime.securesms.util.Conversions;
import org.thoughtcrime.securesms.util.ServiceUtil;
import org.thoughtcrime.securesms.util.TelephonyUtil;
import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.thoughtcrime.securesms.util.Util;
import org.whispersystems.libaxolotl.util.guava.Optional;
import com.google.i18n.phonenumbers.PhoneNumberUtil;
import com.google.i18n.phonenumbers.NumberParseException;
import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;
import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
@ -56,8 +52,10 @@ import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.InetAddress;
import java.net.URL;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
@SuppressWarnings("deprecation")
public abstract class LegacyMmsConnection {
@ -91,8 +89,20 @@ public abstract class LegacyMmsConnection {
}
}
protected boolean isCdmaDevice() {
return ((TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE)).getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA;
protected boolean isDirectConnect() {
// We think Sprint supports direct connection over wifi/data, but not Verizon
Set<String> sprintMccMncs = new HashSet<String>() {{
add("312530");
add("311880");
add("311870");
add("311490");
add("310120");
add("316010");
add("312190");
}};
return ServiceUtil.getTelephonyManager(context).getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA &&
sprintMccMncs.contains(TelephonyUtil.getMccMnc(context));
}
@SuppressWarnings("TryWithIdenticalCatches")

View File

@ -76,7 +76,7 @@ public class OutgoingLegacyMmsConnection extends LegacyMmsConnection implements
try {
MmsRadio radio = MmsRadio.getInstance(context);
if (isCdmaDevice()) {
if (isDirectConnect()) {
Log.w(TAG, "Sending MMS directly without radio change...");
try {
return send(pduBytes, false, false);