Fix NPE when RetrieveConf is null

Fixes #2828
Closes #2829
// FREEBIE
This commit is contained in:
Jake McGinty 2015-03-30 10:46:14 -07:00 committed by Moxie Marlinspike
parent e6b2d31db7
commit 491440094b
4 changed files with 10 additions and 3 deletions

View File

@ -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);

View File

@ -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()) {

View File

@ -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 {

View File

@ -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;
}