CHROMIUM: fix breakage of Bluetooth pairing

This patch adds parsing of old property containing list of services
available on remote devices. Without that previously paired devices,
i.e. keyboards, will not work properly.

BUG=chrome-os-partner:48447
TEST=pair keyboard at chrome R47, update to R48, try using keyboard

Change-Id: Id2fac496520e1ec6b24c0957f892d085dae53840
Reviewed-on: https://chromium-review.googlesource.com/320771
Commit-Ready: Jakub x Jakub Pawlowski <jpawlowski@chromium.org>
Tested-by: Jakub x Jakub Pawlowski <jpawlowski@chromium.org>
Reviewed-by: Arman Uguray <armansito@chromium.org>
diff --git a/src/device.c b/src/device.c
index c260c22..0e95227 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2700,13 +2700,23 @@
 	return NULL;
 }
 
+static bool device_add_uuid(struct btd_device *device, const char *uuid)
+{
+       if (g_slist_find_custom(device->uuids, uuid, bt_uuid_strcmp))
+               return false;
+
+       device->uuids = g_slist_insert_sorted(device->uuids, g_strdup(uuid), bt_uuid_strcmp);
+
+       return true;
+}
+
 static void load_info(struct btd_device *device, const char *local,
 			const char *peer, GKeyFile *key_file)
 {
 	char *str;
 	gboolean store_needed = FALSE;
 	gboolean blocked;
-	char **uuids;
+	char **uuids, **sdp_uuids, **gatt_uuids;
 	int source, vendor, product, version;
 	char **techno, **t;
 
@@ -2816,6 +2826,33 @@
 		device->bredr_state.svc_resolved = true;
 	}
 
+	/* Load device profile list from legacy property */
+	sdp_uuids = g_key_file_get_string_list(key_file, "General", "SDPServices",
+						NULL, NULL);
+	if (sdp_uuids) {
+		char **uuid;
+
+		for (uuid = sdp_uuids; *uuid; uuid++)
+			device_add_uuid(device, *uuid);
+
+		g_strfreev(sdp_uuids);
+
+		/* Discovered services restored from storage */
+		device->bredr_state.svc_resolved = true;
+	}
+
+	/* Load device profile list from legacy property */
+	gatt_uuids = g_key_file_get_string_list(key_file, "General", "GATTServices",
+						NULL, NULL);
+	if (gatt_uuids) {
+		char **uuid;
+
+		for (uuid = gatt_uuids; *uuid; uuid++)
+			device_add_uuid(device, *uuid);
+
+		g_strfreev(gatt_uuids);
+	}
+
 	/* Load device id */
 	source = g_key_file_get_integer(key_file, "DeviceID", "Source", NULL);
 	if (source) {