diff --git a/src/org/thoughtcrime/securesms/mms/MmsSendHelper.java b/src/org/thoughtcrime/securesms/mms/MmsSendHelper.java index 4ec0ca0f6..983471a94 100644 --- a/src/org/thoughtcrime/securesms/mms/MmsSendHelper.java +++ b/src/org/thoughtcrime/securesms/mms/MmsSendHelper.java @@ -18,6 +18,7 @@ package org.thoughtcrime.securesms.mms; import android.content.Context; import android.net.ConnectivityManager; +import android.net.NetworkInfo; import android.net.http.AndroidHttpClient; import android.util.Log; @@ -36,6 +37,7 @@ import ws.com.google.android.mms.pdu.PduParser; import ws.com.google.android.mms.pdu.SendConf; public class MmsSendHelper extends MmsCommunication { + private final static String TAG = MmsSendHelper.class.getSimpleName(); private static byte[] makePost(Context context, MmsConnectionParameters parameters, byte[] mms) throws IOException @@ -43,7 +45,7 @@ public class MmsSendHelper extends MmsCommunication { AndroidHttpClient client = null; try { - Log.w("MmsSender", "Sending MMS1 of length: " + (mms != null ? mms.length : "null")); + Log.w(TAG, "Sending MMS1 of length: " + (mms != null ? mms.length : "null")); client = constructHttpClient(context, parameters); URI targetUrl = new URI(parameters.getMmsc()); @@ -68,7 +70,7 @@ public class MmsSendHelper extends MmsCommunication { return parseResponse(response.getEntity()); } catch (URISyntaxException use) { - Log.w("MmsSendHelper", use); + Log.w(TAG, use); throw new IOException("Couldn't parse URI."); } finally { if (client != null) @@ -100,13 +102,13 @@ public class MmsSendHelper extends MmsCommunication { boolean usingMmsRadio, boolean useProxyIfAvailable) throws IOException { - Log.w("MmsSender", "Sending MMS of length: " + mms.length); + Log.w(TAG, "Sending MMS of length: " + mms.length); try { MmsConnectionParameters parameters = getMmsConnectionParameters(context, apn, useProxyIfAvailable); checkRouteToHost(context, parameters, parameters.getMmsc(), usingMmsRadio); return makePost(context, parameters, mms); } catch (ApnUnavailableException aue) { - Log.w("MmsSender", aue); + Log.w(TAG, aue); throw new IOException("Failed to get MMSC information..."); } } @@ -114,7 +116,12 @@ public class MmsSendHelper extends MmsCommunication { public static boolean hasNecessaryApnDetails(Context context) { try { ConnectivityManager connectivityManager = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE); - String apn = connectivityManager.getNetworkInfo(MmsRadio.TYPE_MOBILE_MMS).getExtraInfo(); + NetworkInfo networkInfo = connectivityManager.getNetworkInfo(MmsRadio.TYPE_MOBILE_MMS); + if (networkInfo == null) { + Log.w(TAG, "MMS network info was null, unsupported by this device"); + return false; + } + String apn = networkInfo.getExtraInfo(); MmsCommunication.getMmsConnectionParameters(context, apn, true); return true;