Fixed notification race condition

pull/162/head
M66B 5 years ago
parent a233a1c9a4
commit ebf783e159

@ -2083,8 +2083,11 @@ class Core {
if (message.notifying != 0) {
long id = message.id * message.notifying;
if (!groupNotifying.get(group).contains(id))
if (!groupNotifying.get(group).contains(id) &&
!groupNotifying.get(group).contains(-id)) {
Log.i("Notify database=" + id);
groupNotifying.get(group).add(id);
}
}
if (!(message.ui_seen || message.ui_ignored || message.ui_hide != 0)) {
@ -2143,7 +2146,7 @@ class Core {
for (Long id : remove) {
String tag = "unseen." + group + "." + Math.abs(id);
Log.i("Notify cancel tag=" + tag);
Log.i("Notify cancel tag=" + tag + " id=" + id);
nm.cancel(tag, 1);
groupNotifying.get(group).remove(id);
@ -2154,7 +2157,7 @@ class Core {
long id = notification.extras.getLong("id", 0);
if ((id == 0 && add.size() + remove.size() > 0) || add.contains(id)) {
String tag = "unseen." + group + "." + Math.abs(id);
Log.i("Notifying tag=" + tag +
Log.i("Notifying tag=" + tag + " id=" + id +
(Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? "" : " channel=" + notification.getChannelId()));
nm.notify(tag, 1, notification);

@ -169,13 +169,13 @@ public class ServiceSynchronize extends ServiceBase {
if (tag != null && tag.startsWith("unseen.")) {
String[] p = tag.split(("\\."));
long group = Long.parseLong(p[1]);
long id = Long.parseLong(p[2]);
long id = sbn.getNotification().extras.getLong("id", 0);
if (!groupNotifying.containsKey(group))
groupNotifying.put(group, new ArrayList<>());
if (id > 0) {
Log.i("Notify restore " + tag);
Log.i("Notify restore " + tag + " id=" + id);
groupNotifying.get(group).add(id);
}
}

Loading…
Cancel
Save