1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-07-09 07:01:33 +02:00

Ignore notifications that are older than the last forwarded one for the

same source.

This reuses the data structure populated to prevent overflow, but avoids
to forward notifications that are older than the reference.
This commit is contained in:
Daniele Gobbetti 2018-10-29 18:39:38 +01:00
parent 6b136210a1
commit b9999edf2a

View File

@ -209,9 +209,12 @@ 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;
if (notificationTimes.containsKey(source)) {
long last_time = notificationTimes.get(source);
if (notification.when <= last_time) {
LOG.info("NOT processing notification, too old. notification.when: " + notification.when + " last notification for this source: " + last_time);
return;
}
}
NotificationSpec notificationSpec = new NotificationSpec();
notificationSpec.id = (int) sbn.getPostTime(); //FIXME: a truly unique id would be better