Skip to content

Commit dfa710a

Browse files
committed
Don't use ConnectivityManager checkRouteToHost for IPv6
T-Mobile LTE now uses IPv6 addresses for their MMSC, which are incompatible with ConnectivityManager's checkRouteToHost.
1 parent bccf489 commit dfa710a

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

src/org/thoughtcrime/securesms/mms/MmsCommunication.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,17 @@ private static void checkRouteToHost(Context context, String host, boolean using
148148
return;
149149
}
150150

151-
byte[] ipAddressBytes = inetAddress.getAddress();
152-
int ipAddress = Conversions.byteArrayToIntLittleEndian(ipAddressBytes, 0);
153-
ConnectivityManager manager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
151+
Log.w("MmsCommunication", "Checking route to address: " + host + " , " + inetAddress.getHostAddress());
154152

155-
if (!manager.requestRouteToHost(MmsDownloader.TYPE_MOBILE_MMS, ipAddress))
156-
throw new IOException("Connection manager could not obtain route to host.");
157-
// if (!manager.requestRouteToHost(ConnectivityManager.TYPE_MOBILE, ipAddress))
158-
// throw new IOException("Connection manager could not obtain route to host.");
153+
byte[] ipAddressBytes = inetAddress.getAddress();
159154

155+
if (ipAddressBytes != null && ipAddressBytes.length == 4) {
156+
int ipAddress = Conversions.byteArrayToIntLittleEndian(ipAddressBytes, 0);
157+
ConnectivityManager manager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
158+
159+
if (!manager.requestRouteToHost(MmsDownloader.TYPE_MOBILE_MMS, ipAddress))
160+
throw new IOException("Connection manager could not obtain route to host.");
161+
}
160162
}
161163

162164
protected static AndroidHttpClient constructHttpClient(Context context, MmsConnectionParameters mmsConfig) {

0 commit comments

Comments
 (0)