UPSTREAM: core/gatt: Don't register attribute handler until core service are registered
Wait until GAP and GATT service are registered to register attribute
handlers otherwise it may attempt to generate service changed without
having service changed registered which leads to print errors:
bluetoothd[2376]: Failed to obtain handles for "Service Changed" characteristic
BUG=none
TEST=emerge bluez and observe that the errors are not printed during creating a
GATT database.
Change-Id: Ib50b4895ce6d9c2657d9369d8fd351d9baa2321d
Reviewed-on: https://chromium-review.googlesource.com/410901
Commit-Ready: Miao-chen Chou <mcchou@chromium.org>
Tested-by: François Beaufort <fbeaufort@chromium.org>
Tested-by: Miao-chen Chou <mcchou@chromium.org>
Reviewed-by: Shyh-In Hwang <josephsih@chromium.org>
Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
diff --git a/src/gatt-database.c b/src/gatt-database.c
index dd6b365..d252b37 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -2606,12 +2606,6 @@
database->profiles = queue_new();
database->ccc_callbacks = queue_new();
- database->db_id = gatt_db_register(database->db, gatt_db_service_added,
- gatt_db_service_removed,
- database, NULL);
- if (!database->db_id)
- goto fail;
-
addr = btd_adapter_get_address(adapter);
database->le_io = bt_io_listen(connect_cb, NULL, NULL, NULL, &gerr,
BT_IO_OPT_SOURCE_BDADDR, addr,
@@ -2647,6 +2641,13 @@
register_core_services(database);
+ database->db_id = gatt_db_register(database->db, gatt_db_service_added,
+ gatt_db_service_removed,
+ database, NULL);
+ if (!database->db_id)
+ goto fail;
+
+
return database;
fail: