From c800a18a46cd4e4ae3bfe9dda079356235d24e4b Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Tue, 18 Aug 2020 15:58:18 +0200 Subject: [PATCH] Prevent NPE in notification filter code Closes #1984 --- .../gadgetbridge/externalevents/NotificationListener.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java index dab18111c..cabc10d0a 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java @@ -352,11 +352,12 @@ public class NotificationListener extends NotificationListenerService { dissectNotificationTo(notification, notificationSpec, preferBigText); - if (!checkNotificationContentForWhiteAndBlackList(sbn.getPackageName().toLowerCase(), notificationSpec.body)) { - return; + if (notificationSpec.body != null) { + if (!checkNotificationContentForWhiteAndBlackList(sbn.getPackageName().toLowerCase(), notificationSpec.body)) { + return; + } } - // ignore Gadgetbridge's very own notifications, except for those from the debug screen if (getApplicationContext().getPackageName().equals(source)) { if (!getApplicationContext().getString(R.string.test_notification).equals(notificationSpec.title)) {