1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2025-01-14 11:47:32 +01:00

Avoid potential, but very unlikely NPE

This commit is contained in:
cpfeiffer 2015-11-23 21:59:13 +01:00
parent 4622b384f2
commit 394a0905dc

View File

@ -36,13 +36,15 @@ public class SMSReceiver extends BroadcastReceiver {
Bundle bundle = intent.getExtras(); Bundle bundle = intent.getExtras();
if (bundle != null) { if (bundle != null) {
Object[] pdus = (Object[]) bundle.get("pdus"); Object[] pdus = (Object[]) bundle.get("pdus");
for (Object pdu1 : pdus) { if (pdus != null) {
byte[] pdu = (byte[]) pdu1; for (Object pdu1 : pdus) {
SmsMessage message = SmsMessage.createFromPdu(pdu); byte[] pdu = (byte[]) pdu1;
notificationSpec.body = message.getDisplayMessageBody(); SmsMessage message = SmsMessage.createFromPdu(pdu);
notificationSpec.phoneNumber = message.getOriginatingAddress(); notificationSpec.body = message.getDisplayMessageBody();
if (notificationSpec.phoneNumber != null) { notificationSpec.phoneNumber = message.getOriginatingAddress();
GBApplication.deviceService().onNotification(notificationSpec); if (notificationSpec.phoneNumber != null) {
GBApplication.deviceService().onNotification(notificationSpec);
}
} }
} }
} }