From e453855e8859a547e3524b3b291ec4de51bbfe12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Rebelo?= Date: Sat, 16 Nov 2024 21:46:18 +0000 Subject: [PATCH] Do not suppress repeated notifications if timestamp is in the future (#4327) --- .../externalevents/NotificationListener.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 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 8a9e2c980..303e7b46d 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java @@ -455,10 +455,14 @@ public class NotificationListener extends NotificationListenerService { mPackageLookup.add(notificationSpec.getId(), sbn.getPackageName()); // for MUTE notificationBurstPrevention.put(source, curTime); - if (0 != notification.when) { - notificationOldRepeatPrevention.put(source, notification.when); + if (notification.when == 0) { + LOG.info("This app might show old/duplicate notifications. notification.when is 0 for {}", source); + } else if ((notification.when - System.currentTimeMillis()) > 30_000L) { + // #4327 - Some apps such as outlook send reminder notifications in the future + // If we add them to the oldRepeatPrevention, they never show up again + LOG.info("This app might show old/duplicate notifications. notification.when is in the future for {}", source); } else { - LOG.info("This app might show old/duplicate notifications. notification.when is 0 for " + source); + notificationOldRepeatPrevention.put(source, notification.when); } notificationsActive.add(notificationSpec.getId()); // NOTE for future developers: this call goes to implementations of DeviceService.onNotification(NotificationSpec), like in GBDeviceService @@ -813,10 +817,11 @@ public class NotificationListener extends NotificationListenerService { private void logNotification(StatusBarNotification sbn, boolean posted) { LOG.debug( - "Notification {} {}: packageName={}, priority={}, category={}", + "Notification {} {}: packageName={}, when={}, priority={}, category={}", sbn.getId(), posted ? "posted" : "removed", sbn.getPackageName(), + sbn.getNotification().when, sbn.getNotification().priority, sbn.getNotification().category );