Loading system/bta/include/bta_api.h +34 −11 Original line number Diff line number Diff line Loading @@ -451,17 +451,40 @@ typedef void(tBTA_DM_SEC_CBACK)(tBTA_DM_SEC_EVT event, tBTA_DM_SEC* p_data); #define BTA_DM_BLE_PF_FILT_LOGIC_OR 0 /* Search callback events */ #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_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; typedef enum : uint8_t { BTA_DM_INQ_RES_EVT = 0, /* Inquiry result for a peer device. */ BTA_DM_INQ_CMPL_EVT = 1, /* Inquiry complete. */ BTA_DM_DISC_RES_EVT = 2, /* Discovery result for a peer device. */ BTA_DM_GATT_OVER_LE_RES_EVT = 3, /* GATT services over LE transport discovered */ BTA_DM_DISC_CMPL_EVT = 4, /* Discovery complete. */ BTA_DM_SEARCH_CANCEL_CMPL_EVT = 5, /* Search cancelled */ BTA_DM_DID_RES_EVT = 6, /* Vendor/Product ID search result */ BTA_DM_GATT_OVER_SDP_RES_EVT = 7, /* GATT services over SDP discovered */ } tBTA_DM_SEARCH_EVT; #ifndef CASE_RETURN_TEXT #define CASE_RETURN_TEXT(code) \ case code: \ return #code #endif inline std::string bta_dm_search_evt_text(const tBTA_DM_SEARCH_EVT& event) { switch (event) { CASE_RETURN_TEXT(BTA_DM_INQ_RES_EVT); CASE_RETURN_TEXT(BTA_DM_INQ_CMPL_EVT); CASE_RETURN_TEXT(BTA_DM_DISC_RES_EVT); CASE_RETURN_TEXT(BTA_DM_GATT_OVER_LE_RES_EVT); CASE_RETURN_TEXT(BTA_DM_DISC_CMPL_EVT); CASE_RETURN_TEXT(BTA_DM_SEARCH_CANCEL_CMPL_EVT); CASE_RETURN_TEXT(BTA_DM_DID_RES_EVT); CASE_RETURN_TEXT(BTA_DM_GATT_OVER_SDP_RES_EVT); default: return base::StringPrintf("UNKNOWN[%hhu]", event); } } #undef CASE_RETURN_TEXT /* Structure associated with BTA_DM_INQ_RES_EVT */ typedef struct { Loading system/bta/test/bta_dm_test.cc +26 −0 Original line number Diff line number Diff line Loading @@ -501,3 +501,29 @@ TEST_F(BtaDmTest, bta_dm_determine_discovery_transport__BT_TRANSPORT_AUTO) { bluetooth::legacy::testing::bta_dm_determine_discovery_transport( bd_addr)); } TEST_F(BtaDmTest, bta_dm_search_evt_text) { std::vector<std::pair<tBTA_DM_SEARCH_EVT, std::string>> events = { 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_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_DID_RES_EVT, "BTA_DM_DID_RES_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(), bta_dm_search_evt_text(event.first).c_str()); } ASSERT_STREQ( base::StringPrintf("UNKNOWN[%hhu]", std::numeric_limits<uint8_t>::max()) .c_str(), bta_dm_search_evt_text( static_cast<tBTA_DM_SEARCH_EVT>(std::numeric_limits<uint8_t>::max())) .c_str()); } system/btif/src/btif_dm.cc +6 −0 Original line number Diff line number Diff line Loading @@ -1581,6 +1581,12 @@ static void btif_dm_search_devices_evt(tBTA_DM_SEARCH_EVT event, BT_DISCOVERY_STOPPED); } } break; case BTA_DM_GATT_OVER_LE_RES_EVT: case BTA_DM_DID_RES_EVT: case BTA_DM_GATT_OVER_SDP_RES_EVT: default: LOG_WARN("Unhandled event:%s", bta_dm_search_evt_text(event).c_str()); break; } } Loading Loading
system/bta/include/bta_api.h +34 −11 Original line number Diff line number Diff line Loading @@ -451,17 +451,40 @@ typedef void(tBTA_DM_SEC_CBACK)(tBTA_DM_SEC_EVT event, tBTA_DM_SEC* p_data); #define BTA_DM_BLE_PF_FILT_LOGIC_OR 0 /* Search callback events */ #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_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; typedef enum : uint8_t { BTA_DM_INQ_RES_EVT = 0, /* Inquiry result for a peer device. */ BTA_DM_INQ_CMPL_EVT = 1, /* Inquiry complete. */ BTA_DM_DISC_RES_EVT = 2, /* Discovery result for a peer device. */ BTA_DM_GATT_OVER_LE_RES_EVT = 3, /* GATT services over LE transport discovered */ BTA_DM_DISC_CMPL_EVT = 4, /* Discovery complete. */ BTA_DM_SEARCH_CANCEL_CMPL_EVT = 5, /* Search cancelled */ BTA_DM_DID_RES_EVT = 6, /* Vendor/Product ID search result */ BTA_DM_GATT_OVER_SDP_RES_EVT = 7, /* GATT services over SDP discovered */ } tBTA_DM_SEARCH_EVT; #ifndef CASE_RETURN_TEXT #define CASE_RETURN_TEXT(code) \ case code: \ return #code #endif inline std::string bta_dm_search_evt_text(const tBTA_DM_SEARCH_EVT& event) { switch (event) { CASE_RETURN_TEXT(BTA_DM_INQ_RES_EVT); CASE_RETURN_TEXT(BTA_DM_INQ_CMPL_EVT); CASE_RETURN_TEXT(BTA_DM_DISC_RES_EVT); CASE_RETURN_TEXT(BTA_DM_GATT_OVER_LE_RES_EVT); CASE_RETURN_TEXT(BTA_DM_DISC_CMPL_EVT); CASE_RETURN_TEXT(BTA_DM_SEARCH_CANCEL_CMPL_EVT); CASE_RETURN_TEXT(BTA_DM_DID_RES_EVT); CASE_RETURN_TEXT(BTA_DM_GATT_OVER_SDP_RES_EVT); default: return base::StringPrintf("UNKNOWN[%hhu]", event); } } #undef CASE_RETURN_TEXT /* Structure associated with BTA_DM_INQ_RES_EVT */ typedef struct { Loading
system/bta/test/bta_dm_test.cc +26 −0 Original line number Diff line number Diff line Loading @@ -501,3 +501,29 @@ TEST_F(BtaDmTest, bta_dm_determine_discovery_transport__BT_TRANSPORT_AUTO) { bluetooth::legacy::testing::bta_dm_determine_discovery_transport( bd_addr)); } TEST_F(BtaDmTest, bta_dm_search_evt_text) { std::vector<std::pair<tBTA_DM_SEARCH_EVT, std::string>> events = { 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_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_DID_RES_EVT, "BTA_DM_DID_RES_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(), bta_dm_search_evt_text(event.first).c_str()); } ASSERT_STREQ( base::StringPrintf("UNKNOWN[%hhu]", std::numeric_limits<uint8_t>::max()) .c_str(), bta_dm_search_evt_text( static_cast<tBTA_DM_SEARCH_EVT>(std::numeric_limits<uint8_t>::max())) .c_str()); }
system/btif/src/btif_dm.cc +6 −0 Original line number Diff line number Diff line Loading @@ -1581,6 +1581,12 @@ static void btif_dm_search_devices_evt(tBTA_DM_SEARCH_EVT event, BT_DISCOVERY_STOPPED); } } break; case BTA_DM_GATT_OVER_LE_RES_EVT: case BTA_DM_DID_RES_EVT: case BTA_DM_GATT_OVER_SDP_RES_EVT: default: LOG_WARN("Unhandled event:%s", bta_dm_search_evt_text(event).c_str()); break; } } Loading