From dfa710a6fce08eb2c87498873c97d232de0e9e95 Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Fri, 12 Jul 2013 15:25:34 -0700 Subject: [PATCH] Don't use ConnectivityManager checkRouteToHost for IPv6 T-Mobile LTE now uses IPv6 addresses for their MMSC, which are incompatible with ConnectivityManager's checkRouteToHost. --- .../securesms/mms/MmsCommunication.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/org/thoughtcrime/securesms/mms/MmsCommunication.java b/src/org/thoughtcrime/securesms/mms/MmsCommunication.java index 206959da91..60d90c84fc 100644 --- a/src/org/thoughtcrime/securesms/mms/MmsCommunication.java +++ b/src/org/thoughtcrime/securesms/mms/MmsCommunication.java @@ -148,15 +148,17 @@ public class MmsCommunication { return; } - byte[] ipAddressBytes = inetAddress.getAddress(); - int ipAddress = Conversions.byteArrayToIntLittleEndian(ipAddressBytes, 0); - ConnectivityManager manager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); + Log.w("MmsCommunication", "Checking route to address: " + host + " , " + inetAddress.getHostAddress()); - if (!manager.requestRouteToHost(MmsDownloader.TYPE_MOBILE_MMS, ipAddress)) - throw new IOException("Connection manager could not obtain route to host."); - // if (!manager.requestRouteToHost(ConnectivityManager.TYPE_MOBILE, ipAddress)) - // throw new IOException("Connection manager could not obtain route to host."); + byte[] ipAddressBytes = inetAddress.getAddress(); + if (ipAddressBytes != null && ipAddressBytes.length == 4) { + int ipAddress = Conversions.byteArrayToIntLittleEndian(ipAddressBytes, 0); + ConnectivityManager manager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); + + if (!manager.requestRouteToHost(MmsDownloader.TYPE_MOBILE_MMS, ipAddress)) + throw new IOException("Connection manager could not obtain route to host."); + } } protected static AndroidHttpClient constructHttpClient(Context context, MmsConnectionParameters mmsConfig) {