mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 08:47:46 +00:00
prevent MMS notification NPE
// FREEBIE
This commit is contained in:
parent
7b41b1492e
commit
b61e7839f4
@ -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