mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-30 13:35:18 +00:00
Only attempt MMS "direct connect" on Sprint MCCMNCs.
Fixes #5134 // FREEBIE
This commit is contained in:
parent
cf223e9ba2
commit
873a0ab249
@ -65,7 +65,8 @@ public class IncomingLegacyMmsConnection extends LegacyMmsConnection implements
|
|||||||
{
|
{
|
||||||
MmsRadio radio = MmsRadio.getInstance(context);
|
MmsRadio radio = MmsRadio.getInstance(context);
|
||||||
Apn contentApn = new Apn(contentLocation, apn.getProxy(), Integer.toString(apn.getPort()), apn.getUsername(), apn.getPassword());
|
Apn contentApn = new Apn(contentLocation, apn.getProxy(), Integer.toString(apn.getPort()), apn.getUsername(), apn.getPassword());
|
||||||
if (isCdmaDevice()) {
|
|
||||||
|
if (isDirectConnect()) {
|
||||||
Log.w(TAG, "Connecting directly...");
|
Log.w(TAG, "Connecting directly...");
|
||||||
try {
|
try {
|
||||||
return retrieve(contentApn, transactionId, false, false);
|
return retrieve(contentApn, transactionId, false, false);
|
||||||
|
@ -18,8 +18,6 @@ package org.thoughtcrime.securesms.mms;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.NetworkInfo;
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
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.impl.conn.BasicHttpClientConnectionManager;
|
||||||
import org.apache.http.message.BasicHeader;
|
import org.apache.http.message.BasicHeader;
|
||||||
import org.thoughtcrime.securesms.database.ApnDatabase;
|
import org.thoughtcrime.securesms.database.ApnDatabase;
|
||||||
import org.thoughtcrime.securesms.util.TelephonyUtil;
|
|
||||||
import org.thoughtcrime.securesms.util.Conversions;
|
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.TextSecurePreferences;
|
||||||
import org.thoughtcrime.securesms.util.Util;
|
import org.thoughtcrime.securesms.util.Util;
|
||||||
import org.whispersystems.libaxolotl.util.guava.Optional;
|
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.BufferedInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
@ -56,8 +52,10 @@ import java.lang.reflect.InvocationTargetException;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public abstract class LegacyMmsConnection {
|
public abstract class LegacyMmsConnection {
|
||||||
@ -91,8 +89,20 @@ public abstract class LegacyMmsConnection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isCdmaDevice() {
|
protected boolean isDirectConnect() {
|
||||||
return ((TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE)).getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA;
|
// 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")
|
@SuppressWarnings("TryWithIdenticalCatches")
|
||||||
|
@ -76,7 +76,7 @@ public class OutgoingLegacyMmsConnection extends LegacyMmsConnection implements
|
|||||||
try {
|
try {
|
||||||
MmsRadio radio = MmsRadio.getInstance(context);
|
MmsRadio radio = MmsRadio.getInstance(context);
|
||||||
|
|
||||||
if (isCdmaDevice()) {
|
if (isDirectConnect()) {
|
||||||
Log.w(TAG, "Sending MMS directly without radio change...");
|
Log.w(TAG, "Sending MMS directly without radio change...");
|
||||||
try {
|
try {
|
||||||
return send(pduBytes, false, false);
|
return send(pduBytes, false, false);
|
||||||
|
Loading…
Reference in New Issue
Block a user