aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2020-03-18 20:58:46 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2020-03-19 11:37:29 -0700
commit16d68fe2622f1dec5897115dee0eeddf7b76254b (patch)
treea1932f1cb61247b5f93a98fd31dfee9ab67b31ff
parent924ce6a801a12b656a0ceb193dde5acb529c2ee7 (diff)
bluetooth-map: prevent double message events
Some messaging applications create notifications when opened even if already been sent out. So we keep a hash map of already sent notifications. This likely needs a better solution in the future. Bug-AGL: SPEC-3267 Change-Id: I1daba04f99819bd7f83bff428131cced0d6d97e6 Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
-rw-r--r--binding/bluetooth-map-api.c11
-rw-r--r--binding/bluetooth-map-common.h3
2 files changed, 14 insertions, 0 deletions
diff --git a/binding/bluetooth-map-api.c b/binding/bluetooth-map-api.c
index 7874181..b0a97d7 100644
--- a/binding/bluetooth-map-api.c
+++ b/binding/bluetooth-map-api.c
@@ -654,7 +654,17 @@ static void bluez_map_signal_callback(
if (!map_notification_check(var))
return;
+ /* Some messaging applications send out
+ * notifications on startup, even if already
+ * sent
+ */
+ if (g_hash_table_contains(ns->already_notified, path))
+ return;
+
map_request_message(ns, path);
+
+ g_hash_table_insert(ns->already_notified, g_strdup(path), NULL);
+
continue;
}
@@ -790,6 +800,7 @@ static struct map_state *map_init(GMainLoop *loop)
}
ns->xfer_queue = g_hash_table_new(g_str_hash, g_str_equal);
+ ns->already_notified = g_hash_table_new(g_str_hash, g_str_equal);
ns->message_sub = g_dbus_connection_signal_subscribe(
ns->conn,
BLUEZ_OBEX_SERVICE,
diff --git a/binding/bluetooth-map-common.h b/binding/bluetooth-map-common.h
index 6e93b9f..bcaa88d 100644
--- a/binding/bluetooth-map-common.h
+++ b/binding/bluetooth-map-common.h
@@ -55,6 +55,9 @@ struct map_state {
/* xfer queue table */
GHashTable *xfer_queue;
+
+ /* message notify blacklist */
+ GHashTable *already_notified;
};
enum xfer_types {