From 491440094b1f253da573a4fa2df75877a6ce5a32 Mon Sep 17 00:00:00 2001 From: Jake McGinty Date: Mon, 30 Mar 2015 10:46:14 -0700 Subject: [PATCH] Fix NPE when RetrieveConf is null Fixes #2828 Closes #2829 // FREEBIE --- src/org/thoughtcrime/securesms/jobs/MmsDownloadJob.java | 3 +++ .../securesms/mms/IncomingLegacyMmsConnection.java | 3 ++- .../securesms/mms/IncomingLollipopMmsConnection.java | 3 ++- src/org/thoughtcrime/securesms/mms/IncomingMmsConnection.java | 4 +++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/org/thoughtcrime/securesms/jobs/MmsDownloadJob.java b/src/org/thoughtcrime/securesms/jobs/MmsDownloadJob.java index e8a24abd8b..0214962c83 100644 --- a/src/org/thoughtcrime/securesms/jobs/MmsDownloadJob.java +++ b/src/org/thoughtcrime/securesms/jobs/MmsDownloadJob.java @@ -86,6 +86,9 @@ public class MmsDownloadJob extends MasterSecretJob { try { RetrieveConf retrieveConf = getMmsConnection(context).retrieve(contentLocation, transactionId); + if (retrieveConf == null) { + throw new MmsException("RetrieveConf was null"); + } storeRetrievedMms(masterSecret, contentLocation, messageId, threadId, retrieveConf); } catch (ApnUnavailableException e) { Log.w(TAG, e); diff --git a/src/org/thoughtcrime/securesms/mms/IncomingLegacyMmsConnection.java b/src/org/thoughtcrime/securesms/mms/IncomingLegacyMmsConnection.java index c96a5b005c..6839c73f5e 100644 --- a/src/org/thoughtcrime/securesms/mms/IncomingLegacyMmsConnection.java +++ b/src/org/thoughtcrime/securesms/mms/IncomingLegacyMmsConnection.java @@ -18,6 +18,7 @@ package org.thoughtcrime.securesms.mms; import android.content.Context; import android.net.Uri; +import android.support.annotation.Nullable; import android.util.Log; import org.apache.http.Header; @@ -57,7 +58,7 @@ public class IncomingLegacyMmsConnection extends LegacyMmsConnection implements } @Override - public RetrieveConf retrieve(String contentLocation, byte[] transactionId) throws MmsRadioException, ApnUnavailableException, IOException { + public @Nullable RetrieveConf retrieve(String contentLocation, byte[] transactionId) throws MmsRadioException, ApnUnavailableException, IOException { MmsRadio radio = MmsRadio.getInstance(context); Apn contentApn = new Apn(contentLocation, apn.getProxy(), Integer.toString(apn.getPort()), apn.getUsername(), apn.getPassword()); if (isCdmaDevice()) { diff --git a/src/org/thoughtcrime/securesms/mms/IncomingLollipopMmsConnection.java b/src/org/thoughtcrime/securesms/mms/IncomingLollipopMmsConnection.java index facad4ff21..b9bfafce0b 100644 --- a/src/org/thoughtcrime/securesms/mms/IncomingLollipopMmsConnection.java +++ b/src/org/thoughtcrime/securesms/mms/IncomingLollipopMmsConnection.java @@ -21,6 +21,7 @@ import android.content.Context; import android.content.Intent; import android.os.Build.VERSION; import android.os.Build.VERSION_CODES; +import android.support.annotation.Nullable; import android.telephony.SmsManager; import android.util.Log; @@ -55,7 +56,7 @@ public class IncomingLollipopMmsConnection extends LollipopMmsConnection impleme @Override @TargetApi(VERSION_CODES.LOLLIPOP) - public synchronized RetrieveConf retrieve(String contentLocation, byte[] transactionId) throws MmsException { + public synchronized @Nullable RetrieveConf retrieve(String contentLocation, byte[] transactionId) throws MmsException { beginTransaction(); try { diff --git a/src/org/thoughtcrime/securesms/mms/IncomingMmsConnection.java b/src/org/thoughtcrime/securesms/mms/IncomingMmsConnection.java index e07672e94f..1d036a0580 100644 --- a/src/org/thoughtcrime/securesms/mms/IncomingMmsConnection.java +++ b/src/org/thoughtcrime/securesms/mms/IncomingMmsConnection.java @@ -1,10 +1,12 @@ package org.thoughtcrime.securesms.mms; +import android.support.annotation.Nullable; + import java.io.IOException; import ws.com.google.android.mms.MmsException; import ws.com.google.android.mms.pdu.RetrieveConf; public interface IncomingMmsConnection { - RetrieveConf retrieve(String contentLocation, byte[] transactionId) throws MmsException, MmsRadioException, ApnUnavailableException, IOException; + @Nullable RetrieveConf retrieve(String contentLocation, byte[] transactionId) throws MmsException, MmsRadioException, ApnUnavailableException, IOException; }