From b1ceb9610096ac8300c69f89c639ed1e788122f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Sun, 23 Jul 2023 21:02:46 +0100 Subject: [PATCH] Fix notification filters by title if notification does not contain a body --- CHANGELOG.md | 1 + .../gadgetbridge/externalevents/NotificationListener.java | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5caacc23..18c768962 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ * Zepp OS: Fix reminder creation * Bump target SDK version to 31 * Fix media button control for some applications +* Fix notification filters by title if notification does not contain a body * Fix opening screenshots from notification on external apps * Fix reconnect delay reset after all devices are initialized * Fix transliteration of emoji 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 6760869c9..93df781fc 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java @@ -96,6 +96,7 @@ import java.util.concurrent.TimeUnit; import static nodomain.freeyourgadget.gadgetbridge.activities.NotificationFilterActivity.NOTIFICATION_FILTER_MODE_BLACKLIST; import static nodomain.freeyourgadget.gadgetbridge.activities.NotificationFilterActivity.NOTIFICATION_FILTER_MODE_WHITELIST; import static nodomain.freeyourgadget.gadgetbridge.activities.NotificationFilterActivity.NOTIFICATION_FILTER_SUBMODE_ALL; +import static nodomain.freeyourgadget.gadgetbridge.util.StringUtils.ensureNotNull; public class NotificationListener extends NotificationListenerService { @@ -387,8 +388,9 @@ public class NotificationListener extends NotificationListenerService { dissectNotificationTo(notification, notificationSpec, preferBigText); - if (notificationSpec.body != null) { - if (!checkNotificationContentForWhiteAndBlackList(sbn.getPackageName().toLowerCase(), notificationSpec.title + " " + notificationSpec.body)) { + if (notificationSpec.title != null || notificationSpec.body != null) { + final String textToCheck = ensureNotNull(notificationSpec.title) + " " + ensureNotNull(notificationSpec.body); + if (!checkNotificationContentForWhiteAndBlackList(sbn.getPackageName().toLowerCase(), textToCheck)) { return; } }