Fix null-response NPE in outgoing MMS
Fixes #2839 Closes #2840 // FREEBIE
This commit is contained in:
parent
e70298e624
commit
c04b675a1a
3 changed files with 11 additions and 3 deletions
|
@ -20,6 +20,7 @@ import android.content.Context;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import org.apache.http.Header;
|
import org.apache.http.Header;
|
||||||
|
@ -70,7 +71,7 @@ public class OutgoingLegacyMmsConnection extends LegacyMmsConnection implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SendConf send(byte[] pduBytes) throws UndeliverableMessageException {
|
public SendConf send(@NonNull byte[] pduBytes) throws UndeliverableMessageException {
|
||||||
try {
|
try {
|
||||||
MmsRadio radio = MmsRadio.getInstance(context);
|
MmsRadio radio = MmsRadio.getInstance(context);
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Build.VERSION;
|
import android.os.Build.VERSION;
|
||||||
import android.os.Build.VERSION_CODES;
|
import android.os.Build.VERSION_CODES;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.telephony.SmsManager;
|
import android.telephony.SmsManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
@ -57,7 +58,7 @@ public class OutgoingLollipopMmsConnection extends LollipopMmsConnection impleme
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@TargetApi(VERSION_CODES.LOLLIPOP)
|
@TargetApi(VERSION_CODES.LOLLIPOP)
|
||||||
public synchronized SendConf send(byte[] pduBytes) throws UndeliverableMessageException {
|
public synchronized SendConf send(@NonNull byte[] pduBytes) throws UndeliverableMessageException {
|
||||||
beginTransaction();
|
beginTransaction();
|
||||||
try {
|
try {
|
||||||
MmsBodyProvider.Pointer pointer = MmsBodyProvider.makeTemporaryPointer(getContext());
|
MmsBodyProvider.Pointer pointer = MmsBodyProvider.makeTemporaryPointer(getContext());
|
||||||
|
@ -74,6 +75,10 @@ public class OutgoingLollipopMmsConnection extends LollipopMmsConnection impleme
|
||||||
Log.w(TAG, "MMS broadcast received and processed.");
|
Log.w(TAG, "MMS broadcast received and processed.");
|
||||||
pointer.close();
|
pointer.close();
|
||||||
|
|
||||||
|
if (response == null) {
|
||||||
|
throw new UndeliverableMessageException("Null response.");
|
||||||
|
}
|
||||||
|
|
||||||
return (SendConf) new PduParser(response).parse();
|
return (SendConf) new PduParser(response).parse();
|
||||||
} catch (IOException | TimeoutException e) {
|
} catch (IOException | TimeoutException e) {
|
||||||
throw new UndeliverableMessageException(e);
|
throw new UndeliverableMessageException(e);
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package org.thoughtcrime.securesms.mms;
|
package org.thoughtcrime.securesms.mms;
|
||||||
|
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.transport.UndeliverableMessageException;
|
import org.thoughtcrime.securesms.transport.UndeliverableMessageException;
|
||||||
|
|
||||||
import ws.com.google.android.mms.pdu.SendConf;
|
import ws.com.google.android.mms.pdu.SendConf;
|
||||||
|
|
||||||
public interface OutgoingMmsConnection {
|
public interface OutgoingMmsConnection {
|
||||||
SendConf send(byte[] pduBytes) throws UndeliverableMessageException;
|
SendConf send(@NonNull byte[] pduBytes) throws UndeliverableMessageException;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue