Diff between 390b93f90189917addc4e9c0a5670f1fe797e7ba and 3f99c59c67ad088a0ffefcf2a3ed7c0b6fb47916

Changed Files

File Additions Deletions Status
src/device.c +16 -0 modified

Full Patch

diff --git a/src/device.c b/src/device.c
index 716da53..77f94ff 100644
--- a/src/device.c
+++ b/src/device.c
@@ -5481,6 +5481,22 @@ void device_load_svc_chng_ccc(struct btd_device *device, uint16_t *ccc_le,
 	key_file = g_key_file_new();
 	g_key_file_load_from_file(key_file, filename, 0, NULL);
 
+	/*
+	 * If there is no "ServiceChanged" section we may be loading data from
+	 * old version which did not persist Service Changed CCC values. Let's
+	 * check if we are bonded and assume indications were enabled by peer
+	 * in such case - it should have done this anyway.
+	 */
+	if (!g_key_file_has_group(key_file, "ServiceChanged")) {
+		if (ccc_le)
+			*ccc_le = device->le_state.bonded ? 0x0002 : 0x0000;
+		if (ccc_bredr)
+			*ccc_bredr = device->bredr_state.bonded ?
+							0x0002 : 0x0000;
+		g_key_file_free(key_file);
+		return;
+	}
+
 	if (ccc_le)
 		*ccc_le = g_key_file_get_integer(key_file, "ServiceChanged",
 							"CCC_LE", NULL);