From 29dc806fb16d708ae5c154bd2013f7f651350a2e Mon Sep 17 00:00:00 2001 From: Daniele Gobbetti Date: Sun, 28 Oct 2018 17:58:24 +0100 Subject: [PATCH] Ignore notifications that are older than 1 second In case of grouped notifications, we get multiple notifications also if the android device shows only one. This means that with this change the most recently updated chat will get through, but others will not. This should help with #1062 and #657 --- .../gadgetbridge/externalevents/NotificationListener.java | 4 ++++ 1 file changed, 4 insertions(+) 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 18f6242bb..0c03d5c15 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/NotificationListener.java @@ -209,6 +209,10 @@ public class NotificationListener extends NotificationListenerService { String source = sbn.getPackageName().toLowerCase(); Notification notification = sbn.getNotification(); + if (notification.when < (sbn.getPostTime() - 1000)) { + LOG.info("NOT processing notification, too old. notification.when: " + notification.when + " post time: " + sbn.getPostTime() + " now: " + System.currentTimeMillis()); + return; + } NotificationSpec notificationSpec = new NotificationSpec(); notificationSpec.id = (int) sbn.getPostTime(); //FIXME: a truly unique id would be better