mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 08:47:46 +00:00
Merge pull request #1821 from mcginty/mms-npe
prevent MMS notification NPE
This commit is contained in:
commit
b80593b5f5
@ -0,0 +1,28 @@
|
|||||||
|
package org.thoughtcrime.securesms.service;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.test.InstrumentationTestCase;
|
||||||
|
|
||||||
|
import static org.fest.assertions.api.Assertions.*;
|
||||||
|
|
||||||
|
public class MmsReceiverTest extends InstrumentationTestCase {
|
||||||
|
|
||||||
|
private MmsReceiver mmsReceiver;
|
||||||
|
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
super.setUp();
|
||||||
|
mmsReceiver = new MmsReceiver(getInstrumentation().getContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void tearDown() throws Exception {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testProcessMalformedData() throws Exception {
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.setAction(SendReceiveService.RECEIVE_MMS_ACTION);
|
||||||
|
intent.putExtra("data", new byte[]{0x00});
|
||||||
|
mmsReceiver.process(null, intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -58,7 +58,7 @@ public class MmsReceiver {
|
|||||||
PduParser parser = new PduParser(mmsData);
|
PduParser parser = new PduParser(mmsData);
|
||||||
GenericPdu pdu = parser.parse();
|
GenericPdu pdu = parser.parse();
|
||||||
|
|
||||||
if (pdu.getMessageType() == PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND) {
|
if (pdu != null && pdu.getMessageType() == PduHeaders.MESSAGE_TYPE_NOTIFICATION_IND) {
|
||||||
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
MmsDatabase database = DatabaseFactory.getMmsDatabase(context);
|
||||||
Pair<Long, Long> messageAndThreadId = database.insertMessageInbox((NotificationInd)pdu);
|
Pair<Long, Long> messageAndThreadId = database.insertMessageInbox((NotificationInd)pdu);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user