Discover primary service by UUID for PTS tests (1/4)
Bug: 38123054
Test: manual
Change-Id: Ic97a964ca2a25a84c6abcf41acb0f3fb583488a2
diff --git a/bta/gatt/bta_gattc_api.cc b/bta/gatt/bta_gattc_api.cc
index e024b02..bd1738f 100644
--- a/bta/gatt/bta_gattc_api.cc
+++ b/bta/gatt/bta_gattc_api.cc
@@ -255,6 +255,16 @@
bta_sys_sendmsg(p_buf);
}
+void BTA_GATTC_DiscoverServiceByUuid(uint16_t conn_id, tBT_UUID* p_srvc_uuid) {
+ tGATT_DISC_PARAM* param = new tGATT_DISC_PARAM;
+ param->s_handle = 0x0001;
+ param->e_handle = 0xFFFF;
+ param->service = *p_srvc_uuid;
+ do_in_bta_thread(FROM_HERE,
+ base::Bind(base::IgnoreResult(&GATTC_Discover), conn_id,
+ GATT_DISC_SRVC_BY_UUID, base::Owned(param)));
+}
+
/*******************************************************************************
*
* Function BTA_GATTC_GetServices
diff --git a/bta/include/bta_gatt_api.h b/bta/include/bta_gatt_api.h
index 9e023b8..39c45b3 100644
--- a/bta/include/bta_gatt_api.h
+++ b/bta/include/bta_gatt_api.h
@@ -693,6 +693,13 @@
extern void BTA_GATTC_ServiceSearchRequest(uint16_t conn_id,
tBT_UUID* p_srvc_uuid);
+/**
+ * This function is called to send "Find service by UUID" request. Used only for
+ * PTS tests.
+ */
+extern void BTA_GATTC_DiscoverServiceByUuid(uint16_t conn_id,
+ tBT_UUID* p_srvc_uuid);
+
/*******************************************************************************
*
* Function BTA_GATTC_GetServices
diff --git a/btif/src/btif_gatt_client.cc b/btif/src/btif_gatt_client.cc
index c3db741..40d1515 100644
--- a/btif/src/btif_gatt_client.cc
+++ b/btif/src/btif_gatt_client.cc
@@ -368,6 +368,15 @@
}
}
+void btif_gattc_discover_service_by_uuid(int conn_id, bt_uuid_t* p_uuid) {
+ LOG_ASSERT(p_uuid);
+
+ tBT_UUID* uuid = new tBT_UUID;
+ btif_to_bta_uuid(uuid, p_uuid);
+ do_in_jni_thread(
+ Bind(&BTA_GATTC_DiscoverServiceByUuid, conn_id, base::Owned(uuid)));
+}
+
void btif_gattc_get_gatt_db_impl(int conn_id) {
btgatt_db_element_t* db = NULL;
int count = 0;
@@ -609,6 +618,7 @@
btif_gattc_close,
btif_gattc_refresh,
btif_gattc_search_service,
+ btif_gattc_discover_service_by_uuid,
btif_gattc_read_char,
btif_gattc_read_using_char_uuid,
btif_gattc_write_char,
diff --git a/service/hal/fake_bluetooth_gatt_interface.cc b/service/hal/fake_bluetooth_gatt_interface.cc
index f2593f5..1250e85 100644
--- a/service/hal/fake_bluetooth_gatt_interface.cc
+++ b/service/hal/fake_bluetooth_gatt_interface.cc
@@ -107,6 +107,7 @@
FakeDisconnect,
nullptr, // refresh
nullptr, // search_service
+ nullptr, // discover_service_by_uuid
nullptr, // read_characteristic
nullptr, // read_using_characteristic_uuid
nullptr, // write_characteristic