enforce NonNull on incoming MMS content location

Fixes #2959
Closes #2975

// FREEBIE
This commit is contained in:
Jake McGinty 2015-04-13 10:56:41 -07:00 committed by Moxie Marlinspike
parent 4a9028aedd
commit a28408b29f
4 changed files with 22 additions and 10 deletions

View file

@ -77,14 +77,18 @@ public class MmsDownloadJob extends MasterSecretJob {
return;
}
database.markDownloadState(messageId, MmsDatabase.Status.DOWNLOAD_CONNECTING);
String contentLocation = new String(notification.get().getContentLocation());
byte[] transactionId = notification.get().getTransactionId();
Log.w(TAG, "Downloading mms at " + Uri.parse(contentLocation).getHost());
try {
if (notification.get().getContentLocation() == null) {
throw new MmsException("Notification content location was null.");
}
database.markDownloadState(messageId, MmsDatabase.Status.DOWNLOAD_CONNECTING);
String contentLocation = new String(notification.get().getContentLocation());
byte[] transactionId = notification.get().getTransactionId();
Log.w(TAG, "Downloading mms at " + Uri.parse(contentLocation).getHost());
RetrieveConf retrieveConf = getMmsConnection(context).retrieve(contentLocation, transactionId);
if (retrieveConf == null) {
throw new MmsException("RetrieveConf was null");

View file

@ -18,6 +18,7 @@ package org.thoughtcrime.securesms.mms;
import android.content.Context;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;
@ -58,7 +59,10 @@ public class IncomingLegacyMmsConnection extends LegacyMmsConnection implements
}
@Override
public @Nullable RetrieveConf retrieve(String contentLocation, byte[] transactionId) throws MmsRadioException, ApnUnavailableException, IOException {
public @Nullable RetrieveConf retrieve(@NonNull 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.NonNull;
import android.support.annotation.Nullable;
import android.telephony.SmsManager;
import android.util.Log;
@ -56,7 +57,9 @@ public class IncomingLollipopMmsConnection extends LollipopMmsConnection impleme
@Override
@TargetApi(VERSION_CODES.LOLLIPOP)
public synchronized @Nullable RetrieveConf retrieve(String contentLocation, byte[] transactionId) throws MmsException {
public synchronized @Nullable RetrieveConf retrieve(@NonNull String contentLocation,
byte[] transactionId) throws MmsException
{
beginTransaction();
try {

View file

@ -1,5 +1,6 @@
package org.thoughtcrime.securesms.mms;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import java.io.IOException;
@ -8,5 +9,5 @@ import ws.com.google.android.mms.MmsException;
import ws.com.google.android.mms.pdu.RetrieveConf;
public interface IncomingMmsConnection {
@Nullable RetrieveConf retrieve(String contentLocation, byte[] transactionId) throws MmsException, MmsRadioException, ApnUnavailableException, IOException;
@Nullable RetrieveConf retrieve(@NonNull String contentLocation, byte[] transactionId) throws MmsException, MmsRadioException, ApnUnavailableException, IOException;
}