Loading system/btif/src/bluetooth.cc +2 −1 Original line number Diff line number Diff line Loading @@ -102,7 +102,6 @@ #include "stack/gatt/connection_manager.h" #include "stack/include/a2dp_api.h" #include "stack/include/avdt_api.h" #include "stack/include/btm_api.h" #include "stack/include/btm_client_interface.h" #include "stack/include/hfp_lc3_decoder.h" #include "stack/include/hfp_lc3_encoder.h" Loading @@ -111,6 +110,7 @@ #include "stack/include/hidh_api.h" #include "stack/include/main_thread.h" #include "stack/include/pan_api.h" #include "stack/include/sdp_api.h" #include "storage/config_keys.h" #include "types/raw_address.h" Loading Loading @@ -876,6 +876,7 @@ static void dump(int fd, const char** arguments) { PAN_Dumpsys(fd); DumpsysHid(fd); DumpsysBtaDm(fd); SDP_Dumpsys(fd); bluetooth::shim::Dump(fd, arguments); power_telemetry::GetInstance().Dumpsys(fd); log::debug("Finished bluetooth dumpsys"); Loading system/stack/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -1417,6 +1417,7 @@ cc_test { ":LegacyStackSdp", ":TestCommonMainHandler", ":TestCommonMockFunctions", ":TestMockBta", ":TestMockBtif", ":TestMockDevice", ":TestMockRustFfi", Loading Loading @@ -2241,6 +2242,7 @@ cc_test { ":LegacyStackSdp", ":TestCommonMockFunctions", ":TestFakeOsi", ":TestMockBta", ":TestMockBtif", ":TestMockStackBtm", ":TestMockStackL2cap", Loading system/stack/include/sdp_api.h +13 −0 Original line number Diff line number Diff line Loading @@ -577,3 +577,16 @@ struct tLegacyStackSdbCallback { } // namespace stack } // namespace legacy } // namespace bluetooth /******************************************************************************* * * Function SDP_Dumpsys * * Description Dumps readable content of the module to the filedescriptor * * Parameters: fd - Valid file descriptor * * Returns None * ******************************************************************************/ void SDP_Dumpsys(int fd); system/stack/sdp/sdp_api.cc +49 −1 Original line number Diff line number Diff line Loading @@ -26,13 +26,14 @@ #include "stack/include/sdp_api.h" #include <base/strings/stringprintf.h> #include <bluetooth/log.h> #include <string.h> #include <cstdint> #include "internal_include/bt_target.h" #include "os/log.h" #include "main/shim/dumpsys.h" #include "stack/include/bt_types.h" #include "stack/include/bt_uuid16.h" #include "stack/include/sdp_api.h" Loading @@ -45,6 +46,11 @@ using bluetooth::Uuid; using namespace bluetooth; namespace { constexpr unsigned kMaxSdpConnections = static_cast<unsigned>(SDP_MAX_CONNECTIONS); constexpr unsigned kMaxSdpRecords = static_cast<unsigned>(SDP_MAX_DISC_SERVER_RECS); } // namespace /******************************************************************************* * * Function SDP_InitDiscoveryDb Loading Loading @@ -1106,3 +1112,45 @@ const bluetooth::legacy::stack::sdp::tSdpApi* bluetooth::legacy::stack::sdp::get_legacy_stack_sdp_api() { return &api_; } extern void BTA_SdpDumpsys(int fd); #define DUMPSYS_TAG "shim::legacy::sdp" namespace { void SDP_DumpConnectionControlBlock(int fd, const tCONN_CB& conn_cb) { if (conn_cb.device_address == RawAddress::kEmpty) { return; } LOG_DUMPSYS(fd, "peer:%s discovery_state:%s", fmt::format("{}", conn_cb.device_address).c_str(), sdp_disc_wait_text(conn_cb.disc_state).c_str()); LOG_DUMPSYS(fd, " connection_state:%s connection_flags:0x%02x mtu:%hu l2cap_cid:%hu", sdp_state_text(conn_cb.con_state).c_str(), conn_cb.con_flags, conn_cb.rem_mtu_size, conn_cb.connection_id); const uint64_t remaining_ms = alarm_get_remaining_ms(conn_cb.sdp_conn_timer); if (remaining_ms) { LOG_DUMPSYS(fd, " timer_set:%Lu ms", static_cast<long long>(remaining_ms)); } if (conn_cb.num_handles >= kMaxSdpRecords) { LOG_DUMPSYS(fd, " WARNING - Number handles:%hu exceeds max handles:%u", conn_cb.num_handles, kMaxSdpRecords); } else { for (int i = 0; i < conn_cb.num_handles; i++) { LOG_DUMPSYS(fd, " handle:%u", conn_cb.handles[i]); } } } } // namespace void SDP_Dumpsys(int fd) { LOG_DUMPSYS_TITLE(fd, DUMPSYS_TAG); LOG_DUMPSYS(fd, "max_attribute_list_size:%hu max_records_per_search:%hu", sdp_cb.max_attr_list_size, sdp_cb.max_recs_per_search); for (unsigned i = 0; i < kMaxSdpConnections; i++) { SDP_DumpConnectionControlBlock(fd, sdp_cb.ccb[i]); } } #undef DUMPSYS_TAG system/stack/test/sdp/stack_sdp_test.cc +12 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include "include/macros.h" #include "osi/include/allocator.h" #include "stack/include/bt_uuid16.h" #include "stack/include/sdp_api.h" #include "stack/include/sdpdefs.h" #include "stack/sdp/internal/sdp_api.h" #include "stack/sdp/sdpint.h" Loading Loading @@ -415,3 +416,14 @@ TEST_F(StackSdpInitTest, sdpu_dump_all_ccb) { sdpu_dump_all_ccb(); } TEST_F(StackSdpInitTest, SDP_Dumpsys) { SDP_Dumpsys(1); } TEST_F(StackSdpInitTest, SDP_Dumpsys_ccb) { ASSERT_NE(nullptr, sdp_conn_originate(addr)); ASSERT_NE(nullptr, sdp_conn_originate(addr2)); ASSERT_NE(nullptr, sdp_conn_originate(addr3)); ASSERT_NE(nullptr, sdp_conn_originate(addr4)); ASSERT_EQ(nullptr, sdp_conn_originate(addr5)); SDP_Dumpsys(1); } Loading
system/btif/src/bluetooth.cc +2 −1 Original line number Diff line number Diff line Loading @@ -102,7 +102,6 @@ #include "stack/gatt/connection_manager.h" #include "stack/include/a2dp_api.h" #include "stack/include/avdt_api.h" #include "stack/include/btm_api.h" #include "stack/include/btm_client_interface.h" #include "stack/include/hfp_lc3_decoder.h" #include "stack/include/hfp_lc3_encoder.h" Loading @@ -111,6 +110,7 @@ #include "stack/include/hidh_api.h" #include "stack/include/main_thread.h" #include "stack/include/pan_api.h" #include "stack/include/sdp_api.h" #include "storage/config_keys.h" #include "types/raw_address.h" Loading Loading @@ -876,6 +876,7 @@ static void dump(int fd, const char** arguments) { PAN_Dumpsys(fd); DumpsysHid(fd); DumpsysBtaDm(fd); SDP_Dumpsys(fd); bluetooth::shim::Dump(fd, arguments); power_telemetry::GetInstance().Dumpsys(fd); log::debug("Finished bluetooth dumpsys"); Loading
system/stack/Android.bp +2 −0 Original line number Diff line number Diff line Loading @@ -1417,6 +1417,7 @@ cc_test { ":LegacyStackSdp", ":TestCommonMainHandler", ":TestCommonMockFunctions", ":TestMockBta", ":TestMockBtif", ":TestMockDevice", ":TestMockRustFfi", Loading Loading @@ -2241,6 +2242,7 @@ cc_test { ":LegacyStackSdp", ":TestCommonMockFunctions", ":TestFakeOsi", ":TestMockBta", ":TestMockBtif", ":TestMockStackBtm", ":TestMockStackL2cap", Loading
system/stack/include/sdp_api.h +13 −0 Original line number Diff line number Diff line Loading @@ -577,3 +577,16 @@ struct tLegacyStackSdbCallback { } // namespace stack } // namespace legacy } // namespace bluetooth /******************************************************************************* * * Function SDP_Dumpsys * * Description Dumps readable content of the module to the filedescriptor * * Parameters: fd - Valid file descriptor * * Returns None * ******************************************************************************/ void SDP_Dumpsys(int fd);
system/stack/sdp/sdp_api.cc +49 −1 Original line number Diff line number Diff line Loading @@ -26,13 +26,14 @@ #include "stack/include/sdp_api.h" #include <base/strings/stringprintf.h> #include <bluetooth/log.h> #include <string.h> #include <cstdint> #include "internal_include/bt_target.h" #include "os/log.h" #include "main/shim/dumpsys.h" #include "stack/include/bt_types.h" #include "stack/include/bt_uuid16.h" #include "stack/include/sdp_api.h" Loading @@ -45,6 +46,11 @@ using bluetooth::Uuid; using namespace bluetooth; namespace { constexpr unsigned kMaxSdpConnections = static_cast<unsigned>(SDP_MAX_CONNECTIONS); constexpr unsigned kMaxSdpRecords = static_cast<unsigned>(SDP_MAX_DISC_SERVER_RECS); } // namespace /******************************************************************************* * * Function SDP_InitDiscoveryDb Loading Loading @@ -1106,3 +1112,45 @@ const bluetooth::legacy::stack::sdp::tSdpApi* bluetooth::legacy::stack::sdp::get_legacy_stack_sdp_api() { return &api_; } extern void BTA_SdpDumpsys(int fd); #define DUMPSYS_TAG "shim::legacy::sdp" namespace { void SDP_DumpConnectionControlBlock(int fd, const tCONN_CB& conn_cb) { if (conn_cb.device_address == RawAddress::kEmpty) { return; } LOG_DUMPSYS(fd, "peer:%s discovery_state:%s", fmt::format("{}", conn_cb.device_address).c_str(), sdp_disc_wait_text(conn_cb.disc_state).c_str()); LOG_DUMPSYS(fd, " connection_state:%s connection_flags:0x%02x mtu:%hu l2cap_cid:%hu", sdp_state_text(conn_cb.con_state).c_str(), conn_cb.con_flags, conn_cb.rem_mtu_size, conn_cb.connection_id); const uint64_t remaining_ms = alarm_get_remaining_ms(conn_cb.sdp_conn_timer); if (remaining_ms) { LOG_DUMPSYS(fd, " timer_set:%Lu ms", static_cast<long long>(remaining_ms)); } if (conn_cb.num_handles >= kMaxSdpRecords) { LOG_DUMPSYS(fd, " WARNING - Number handles:%hu exceeds max handles:%u", conn_cb.num_handles, kMaxSdpRecords); } else { for (int i = 0; i < conn_cb.num_handles; i++) { LOG_DUMPSYS(fd, " handle:%u", conn_cb.handles[i]); } } } } // namespace void SDP_Dumpsys(int fd) { LOG_DUMPSYS_TITLE(fd, DUMPSYS_TAG); LOG_DUMPSYS(fd, "max_attribute_list_size:%hu max_records_per_search:%hu", sdp_cb.max_attr_list_size, sdp_cb.max_recs_per_search); for (unsigned i = 0; i < kMaxSdpConnections; i++) { SDP_DumpConnectionControlBlock(fd, sdp_cb.ccb[i]); } } #undef DUMPSYS_TAG
system/stack/test/sdp/stack_sdp_test.cc +12 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include "include/macros.h" #include "osi/include/allocator.h" #include "stack/include/bt_uuid16.h" #include "stack/include/sdp_api.h" #include "stack/include/sdpdefs.h" #include "stack/sdp/internal/sdp_api.h" #include "stack/sdp/sdpint.h" Loading Loading @@ -415,3 +416,14 @@ TEST_F(StackSdpInitTest, sdpu_dump_all_ccb) { sdpu_dump_all_ccb(); } TEST_F(StackSdpInitTest, SDP_Dumpsys) { SDP_Dumpsys(1); } TEST_F(StackSdpInitTest, SDP_Dumpsys_ccb) { ASSERT_NE(nullptr, sdp_conn_originate(addr)); ASSERT_NE(nullptr, sdp_conn_originate(addr2)); ASSERT_NE(nullptr, sdp_conn_originate(addr3)); ASSERT_NE(nullptr, sdp_conn_originate(addr4)); ASSERT_EQ(nullptr, sdp_conn_originate(addr5)); SDP_Dumpsys(1); }