From d31146f153c9a532fe0b7bf2546211786743c77e Mon Sep 17 00:00:00 2001 From: Jakub Pawlowski <jpawlowski@google.com> Date: Mon, 24 Oct 2022 21:55:08 +0200 Subject: [PATCH] BTA_DM_DISC_BLE_RES_EVT -> BTA_DM_GATT_OVER_LE_RES_EVT and BTA_DM_GATT_OVER_SDP_RES_EVT Differentiate between services disovered by SDP and LE GATT discovery. Service avaliability differs between transports. This patch is not making any functional changes, just making code clearer. Test: perform LE and Classic pairing to dual mode device Bug: 248340112 Merged-In: I7be9d2c0549f8c33eff16b70d6f54dd1f08a71a0 Change-Id: I7be9d2c0549f8c33eff16b70d6f54dd1f08a71a0 --- system/bta/dm/bta_dm_act.cc | 5 +++-- system/bta/include/bta_api.h | 6 ++++-- system/btif/src/btif_dm.cc | 12 +++++++++--- system/btif/src/btif_util.cc | 3 ++- system/btif/test/btif_core_test.cc | 5 ++++- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/system/bta/dm/bta_dm_act.cc b/system/bta/dm/bta_dm_act.cc index 661504b7af5..2e6669dfd20 100644 --- a/system/bta/dm/bta_dm_act.cc +++ b/system/bta/dm/bta_dm_act.cc @@ -1143,7 +1143,8 @@ void bta_dm_sdp_result(tBTA_DM_MSG* p_data) { BD_NAME_LEN + 1); result.disc_ble_res.services = &gatt_uuids; - bta_dm_search_cb.p_search_cback(BTA_DM_DISC_BLE_RES_EVT, &result); + bta_dm_search_cb.p_search_cback(BTA_DM_GATT_OVER_SDP_RES_EVT, + &result); } } else { /* SDP_DB_FULL means some records with the @@ -1336,7 +1337,7 @@ void bta_dm_search_cmpl() { LOG_INFO("GATT services discovered using LE Transport"); // send all result back to app - bta_dm_search_cb.p_search_cback(BTA_DM_DISC_BLE_RES_EVT, &result); + bta_dm_search_cb.p_search_cback(BTA_DM_GATT_OVER_LE_RES_EVT, &result); bta_dm_search_cb.p_search_cback(BTA_DM_DISC_CMPL_EVT, nullptr); diff --git a/system/bta/include/bta_api.h b/system/bta/include/bta_api.h index 18a71f327fc..f5caac33b98 100644 --- a/system/bta/include/bta_api.h +++ b/system/bta/include/bta_api.h @@ -419,10 +419,12 @@ typedef void(tBTA_DM_SEC_CBACK)(tBTA_DM_SEC_EVT event, tBTA_DM_SEC* p_data); #define BTA_DM_INQ_RES_EVT 0 /* Inquiry result for a peer device. */ #define BTA_DM_INQ_CMPL_EVT 1 /* Inquiry complete. */ #define BTA_DM_DISC_RES_EVT 2 /* Discovery result for a peer device. */ -#define BTA_DM_DISC_BLE_RES_EVT \ - 3 /* Discovery result for BLE GATT based servoce on a peer device. */ +#define BTA_DM_GATT_OVER_LE_RES_EVT \ + 3 /* GATT services over LE transport discovered */ #define BTA_DM_DISC_CMPL_EVT 4 /* Discovery complete. */ #define BTA_DM_SEARCH_CANCEL_CMPL_EVT 6 /* Search cancelled */ +#define BTA_DM_DID_RES_EVT 7 /* Vendor/Product ID search result */ +#define BTA_DM_GATT_OVER_SDP_RES_EVT 8 /* GATT services over SDP discovered */ typedef uint8_t tBTA_DM_SEARCH_EVT; diff --git a/system/btif/src/btif_dm.cc b/system/btif/src/btif_dm.cc index 8ee07ad8162..2b8031a6f61 100644 --- a/system/btif/src/btif_dm.cc +++ b/system/btif/src/btif_dm.cc @@ -1530,14 +1530,20 @@ static void btif_dm_search_services_evt(tBTA_DM_SEARCH_EVT event, /* no-op */ break; - case BTA_DM_DISC_BLE_RES_EVT: { + case BTA_DM_GATT_OVER_SDP_RES_EVT: + case BTA_DM_GATT_OVER_LE_RES_EVT: { int num_properties = 0; bt_property_t prop[2]; std::vector<uint8_t> property_value; std::set<Uuid> uuids; RawAddress& bd_addr = p_data->disc_ble_res.bd_addr; - LOG_INFO("New BLE UUIDs for %s:", bd_addr.ToString().c_str()); + if (event == BTA_DM_GATT_OVER_LE_RES_EVT) { + LOG_INFO("New GATT over LE UUIDs for %s:", bd_addr.ToString().c_str()); + } else { + LOG_INFO("New GATT over SDP UUIDs for %s:", bd_addr.ToString().c_str()); + } + for (Uuid uuid : *p_data->disc_ble_res.services) { if (btif_is_interesting_le_service(uuid)) { if (btif_should_ignore_uuid(uuid)) { @@ -1550,7 +1556,7 @@ static void btif_dm_search_services_evt(tBTA_DM_SEARCH_EVT event, } if (uuids.empty()) { - LOG_INFO("No well known BLE services discovered"); + LOG_INFO("No well known GATT services discovered"); return; } diff --git a/system/btif/src/btif_util.cc b/system/btif/src/btif_util.cc index bcd0ef96fc9..00776d99fa3 100644 --- a/system/btif/src/btif_util.cc +++ b/system/btif/src/btif_util.cc @@ -112,9 +112,10 @@ const char* dump_dm_search_event(uint16_t event) { CASE_RETURN_STR(BTA_DM_INQ_RES_EVT) CASE_RETURN_STR(BTA_DM_INQ_CMPL_EVT) CASE_RETURN_STR(BTA_DM_DISC_RES_EVT) - CASE_RETURN_STR(BTA_DM_DISC_BLE_RES_EVT) + CASE_RETURN_STR(BTA_DM_GATT_OVER_LE_RES_EVT) CASE_RETURN_STR(BTA_DM_DISC_CMPL_EVT) CASE_RETURN_STR(BTA_DM_SEARCH_CANCEL_CMPL_EVT) + CASE_RETURN_STR(BTA_DM_GATT_OVER_SDP_RES_EVT) default: return "UNKNOWN MSG ID"; diff --git a/system/btif/test/btif_core_test.cc b/system/btif/test/btif_core_test.cc index 2ecdd2f659c..832ba455fae 100644 --- a/system/btif/test/btif_core_test.cc +++ b/system/btif/test/btif_core_test.cc @@ -225,10 +225,13 @@ TEST_F(BtifCoreTest, dump_dm_search_event) { std::make_pair(BTA_DM_INQ_RES_EVT, "BTA_DM_INQ_RES_EVT"), std::make_pair(BTA_DM_INQ_CMPL_EVT, "BTA_DM_INQ_CMPL_EVT"), std::make_pair(BTA_DM_DISC_RES_EVT, "BTA_DM_DISC_RES_EVT"), - std::make_pair(BTA_DM_DISC_BLE_RES_EVT, "BTA_DM_DISC_BLE_RES_EVT"), + std::make_pair(BTA_DM_GATT_OVER_LE_RES_EVT, + "BTA_DM_GATT_OVER_LE_RES_EVT"), std::make_pair(BTA_DM_DISC_CMPL_EVT, "BTA_DM_DISC_CMPL_EVT"), std::make_pair(BTA_DM_SEARCH_CANCEL_CMPL_EVT, "BTA_DM_SEARCH_CANCEL_CMPL_EVT"), + std::make_pair(BTA_DM_GATT_OVER_SDP_RES_EVT, + "BTA_DM_GATT_OVER_SDP_RES_EVT"), }; for (const auto& event : events) { ASSERT_STREQ(event.second.c_str(), dump_dm_search_event(event.first)); -- GitLab