From 8e9fed1ef996277bc192bddbeb07747a2b9981fa Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Fri, 21 Sep 2018 17:33:21 +0800 Subject: binding: bluetooth: don't send empty PropertiesChanged messages Possible to have an PropertiesChanged events that produces no changes that are useful to report. Bug-AGL: SPEC-1630 Change-Id: I09b25943e3676abd5dd0f1c8caa2c0a2414f409f Signed-off-by: Matt Ranostay --- binding/bluetooth-api.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/binding/bluetooth-api.c b/binding/bluetooth-api.c index 762a8c0..28ac6fb 100644 --- a/binding/bluetooth-api.c +++ b/binding/bluetooth-api.c @@ -317,6 +317,7 @@ static void bluez_devices_signal_callback( g_variant_get(parameters, "(&sa{sv}as)", &path, &array, &array1); if (!g_strcmp0(path, BLUEZ_DEVICE_INTERFACE)) { + int cnt = 0; jresp = json_object_new_object(); @@ -336,10 +337,19 @@ static void bluez_devices_signal_callback( "devices", key, error->message); g_clear_error(&error); + continue; } + cnt++; } - json_object_object_add(jresp, "properties", jobj); + // NOTE: Possible to get a changed property for something we don't care about + if (cnt > 0) { + json_object_object_add(jresp, "properties", jobj); + } else { + json_object_put(jobj); + json_object_put(jresp); + jresp = NULL; + } } g_variant_iter_free(array); -- cgit 1.2.3-korg