mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 12:56:49 +01: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:
parent
6b136210a1
commit
b9999edf2a
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user