Initialize adapter services list

In case service records have been added to bluetoothd before a new
adapter is registered, the records which are shared by all adapters
(indicated by having the address set to BDADDR_ANY) need to be added
to the services list of the new adapter. This patch adds a function
for this on adapter initialization.

The issue could be reproduced by running bluetoothd and obexd on a
PC and briefly removing the BT dongle. The service records from
obexd would not be present in the adapter's local list (which is
used to set the class of device).
diff --git a/src/adapter.c b/src/adapter.c
index 999f369..62afc0c 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2319,6 +2319,7 @@
 		return err;
 
 	if (adapter->initialized == FALSE) {
+		sdp_init_services_list(&adapter->bdaddr);
 		load_drivers(adapter);
 		clear_blocked(adapter);
 		load_devices(adapter);
diff --git a/src/sdpd-database.c b/src/sdpd-database.c
index da3bc7d..882d567 100644
--- a/src/sdpd-database.c
+++ b/src/sdpd-database.c
@@ -306,3 +306,26 @@
 
 	return handle;
 }
+
+void sdp_init_services_list(bdaddr_t *device)
+{
+	sdp_list_t *p;
+
+	SDPDBG("");
+
+	for (p = access_db; p != NULL; p = p->next) {
+		sdp_access_t *access = p->data;
+		sdp_record_t *rec;
+
+		if (bacmp(BDADDR_ANY, &access->device))
+			continue;
+
+		rec = sdp_record_find(access->handle);
+		if (rec == NULL)
+			continue;
+
+		SDPDBG("adding record with handle %x", access->handle);
+
+		adapter_service_insert(device, rec);
+	}
+}
diff --git a/src/sdpd.h b/src/sdpd.h
index f8e6ee7..0e3dddf 100644
--- a/src/sdpd.h
+++ b/src/sdpd.h
@@ -106,3 +106,5 @@
 void create_ext_inquiry_response(const char *name,
 					int8_t tx_power, sdp_list_t *services,
 					uint8_t *data);
+
+void sdp_init_services_list(bdaddr_t *device);