Loading system/main/shim/l2c_api.cc +1 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ #include "main/shim/shim.h" #include "osi/include/log.h" static bluetooth::legacy::shim::L2cap shim_l2cap; static bluetooth::shim::legacy::L2cap shim_l2cap; /** * Classic Service Registration APIs Loading system/main/shim/l2cap.cc +33 −33 Original line number Diff line number Diff line Loading @@ -35,36 +35,36 @@ constexpr uint8_t kUnusedId = 0; constexpr uint16_t kUnusedResult = 0; } // namespace bool bluetooth::legacy::shim::PsmManager::IsPsmRegistered(uint16_t psm) const { bool bluetooth::shim::legacy::PsmManager::IsPsmRegistered(uint16_t psm) const { return psm_to_callback_map_.find(psm) != psm_to_callback_map_.end(); } bool bluetooth::legacy::shim::PsmManager::HasClient(uint16_t psm) const { bool bluetooth::shim::legacy::PsmManager::HasClient(uint16_t psm) const { return IsPsmRegistered(psm) && psm_to_callback_map_.at(psm) != nullptr; } void bluetooth::legacy::shim::PsmManager::RegisterPsm( void bluetooth::shim::legacy::PsmManager::RegisterPsm( uint16_t psm, const tL2CAP_APPL_INFO* callbacks) { CHECK(!HasClient(psm)); psm_to_callback_map_[psm] = callbacks; } void bluetooth::legacy::shim::PsmManager::RegisterPsm(uint16_t psm) { void bluetooth::shim::legacy::PsmManager::RegisterPsm(uint16_t psm) { RegisterPsm(psm, nullptr); } void bluetooth::legacy::shim::PsmManager::UnregisterPsm(uint16_t psm) { void bluetooth::shim::legacy::PsmManager::UnregisterPsm(uint16_t psm) { CHECK(IsPsmRegistered(psm)); psm_to_callback_map_.erase(psm); } const tL2CAP_APPL_INFO* bluetooth::legacy::shim::PsmManager::Callbacks( const tL2CAP_APPL_INFO* bluetooth::shim::legacy::PsmManager::Callbacks( uint16_t psm) { CHECK(HasClient(psm)); return psm_to_callback_map_[psm]; } bluetooth::legacy::shim::L2cap::L2cap() bluetooth::shim::legacy::L2cap::L2cap() : classic_dynamic_psm_(kInitialClassicDynamicPsm), le_dynamic_psm_(kInitialLeDynamicPsm), classic_virtual_psm_(kInitialClassicVirtualPsm) { Loading @@ -72,28 +72,28 @@ bluetooth::legacy::shim::L2cap::L2cap() [this](int fd) { Dump(fd); }); } bluetooth::legacy::shim::L2cap::~L2cap() { bluetooth::shim::legacy::L2cap::~L2cap() { bluetooth::shim::UnregisterDumpsysFunction(static_cast<void*>(this)); } bluetooth::legacy::shim::PsmManager& bluetooth::legacy::shim::L2cap::Le() { bluetooth::shim::legacy::PsmManager& bluetooth::shim::legacy::L2cap::Le() { return le_; } bluetooth::legacy::shim::PsmManager& bluetooth::legacy::shim::L2cap::Classic() { bluetooth::shim::legacy::PsmManager& bluetooth::shim::legacy::L2cap::Classic() { return classic_; } bool bluetooth::legacy::shim::L2cap::ConnectionExists(uint16_t cid) const { bool bluetooth::shim::legacy::L2cap::ConnectionExists(uint16_t cid) const { return cid_to_psm_map_.find(cid) != cid_to_psm_map_.end(); } uint16_t bluetooth::legacy::shim::L2cap::CidToPsm(uint16_t cid) const { uint16_t bluetooth::shim::legacy::L2cap::CidToPsm(uint16_t cid) const { CHECK(ConnectionExists(cid)); return cid_to_psm_map_.at(cid); } uint16_t bluetooth::legacy::shim::L2cap::ConvertClientToRealPsm( uint16_t bluetooth::shim::legacy::L2cap::ConvertClientToRealPsm( uint16_t client_psm, bool is_outgoing_only_connection) { if (!is_outgoing_only_connection) { return client_psm; Loading @@ -101,7 +101,7 @@ uint16_t bluetooth::legacy::shim::L2cap::ConvertClientToRealPsm( return GetNextVirtualPsm(client_psm); } uint16_t bluetooth::legacy::shim::L2cap::ConvertClientToRealPsm( uint16_t bluetooth::shim::legacy::L2cap::ConvertClientToRealPsm( uint16_t client_psm) { if (client_psm_to_real_psm_map_.find(client_psm) == client_psm_to_real_psm_map_.end()) { Loading @@ -110,14 +110,14 @@ uint16_t bluetooth::legacy::shim::L2cap::ConvertClientToRealPsm( return client_psm_to_real_psm_map_.at(client_psm); } void bluetooth::legacy::shim::L2cap::RemoveClientPsm(uint16_t client_psm) { void bluetooth::shim::legacy::L2cap::RemoveClientPsm(uint16_t client_psm) { if (client_psm_to_real_psm_map_.find(client_psm) != client_psm_to_real_psm_map_.end()) { client_psm_to_real_psm_map_.erase(client_psm); } } uint16_t bluetooth::legacy::shim::L2cap::GetNextVirtualPsm(uint16_t real_psm) { uint16_t bluetooth::shim::legacy::L2cap::GetNextVirtualPsm(uint16_t real_psm) { if (real_psm < kInitialClassicDynamicPsm) { return real_psm; } Loading @@ -131,7 +131,7 @@ uint16_t bluetooth::legacy::shim::L2cap::GetNextVirtualPsm(uint16_t real_psm) { return classic_virtual_psm_; } uint16_t bluetooth::legacy::shim::L2cap::GetNextDynamicLePsm() { uint16_t bluetooth::shim::legacy::L2cap::GetNextDynamicLePsm() { while (Le().IsPsmRegistered(le_dynamic_psm_)) { le_dynamic_psm_++; if (le_dynamic_psm_ > kFinalLeDynamicPsm) { Loading @@ -141,7 +141,7 @@ uint16_t bluetooth::legacy::shim::L2cap::GetNextDynamicLePsm() { return le_dynamic_psm_; } uint16_t bluetooth::legacy::shim::L2cap::GetNextDynamicClassicPsm() { uint16_t bluetooth::shim::legacy::L2cap::GetNextDynamicClassicPsm() { while (Classic().IsPsmRegistered(classic_dynamic_psm_)) { classic_dynamic_psm_ += 2; if (classic_dynamic_psm_ > kFinalClassicDynamicPsm) { Loading @@ -160,7 +160,7 @@ uint16_t bluetooth::legacy::shim::L2cap::GetNextDynamicClassicPsm() { return classic_dynamic_psm_; } void bluetooth::legacy::shim::L2cap::RegisterService( void bluetooth::shim::legacy::L2cap::RegisterService( uint16_t psm, const tL2CAP_APPL_INFO* callbacks, bool enable_snoop, tL2CAP_ERTM_INFO* p_ertm_info) { LOG_DEBUG(LOG_TAG, "Registering service on psm:%hd", psm); Loading @@ -181,7 +181,7 @@ void bluetooth::legacy::shim::L2cap::RegisterService( bluetooth::shim::GetL2cap()->RegisterService( psm, use_ertm, mtu, std::bind( &bluetooth::legacy::shim::L2cap::OnRemoteInitiatedConnectionCreated, &bluetooth::shim::legacy::L2cap::OnRemoteInitiatedConnectionCreated, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), std::move(register_completed)); Loading @@ -189,7 +189,7 @@ void bluetooth::legacy::shim::L2cap::RegisterService( LOG_DEBUG(LOG_TAG, "Successfully registered service on psm:%hd", psm); } void bluetooth::legacy::shim::L2cap::OnRemoteInitiatedConnectionCreated( void bluetooth::shim::legacy::L2cap::OnRemoteInitiatedConnectionCreated( std::string string_address, uint16_t psm, uint16_t cid) { RawAddress raw_address; RawAddress::FromString(string_address, raw_address); Loading @@ -206,7 +206,7 @@ void bluetooth::legacy::shim::L2cap::OnRemoteInitiatedConnectionCreated( kUnusedId); } void bluetooth::legacy::shim::L2cap::UnregisterService(uint16_t psm) { void bluetooth::shim::legacy::L2cap::UnregisterService(uint16_t psm) { if (!Classic().IsPsmRegistered(psm)) { LOG_WARN(LOG_TAG, "Service must be registered in order to unregister psm:%hd", psm); Loading @@ -225,7 +225,7 @@ void bluetooth::legacy::shim::L2cap::UnregisterService(uint16_t psm) { Classic().UnregisterPsm(psm); } uint16_t bluetooth::legacy::shim::L2cap::CreateConnection( uint16_t bluetooth::shim::legacy::L2cap::CreateConnection( uint16_t psm, const RawAddress& raw_address) { if (!Classic().IsPsmRegistered(psm)) { LOG_WARN(LOG_TAG, "Service must be registered in order to connect psm:%hd", Loading @@ -242,7 +242,7 @@ uint16_t bluetooth::legacy::shim::L2cap::CreateConnection( bluetooth::shim::GetL2cap()->CreateConnection( psm, raw_address.ToString(), std::bind( &bluetooth::legacy::shim::L2cap::OnLocalInitiatedConnectionCreated, &bluetooth::shim::legacy::L2cap::OnLocalInitiatedConnectionCreated, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), std::move(connect_completed)); Loading @@ -263,7 +263,7 @@ uint16_t bluetooth::legacy::shim::L2cap::CreateConnection( return cid; } void bluetooth::legacy::shim::L2cap::OnLocalInitiatedConnectionCreated( void bluetooth::shim::legacy::L2cap::OnLocalInitiatedConnectionCreated( std::string string_address, uint16_t psm, uint16_t cid) { LOG_DEBUG(LOG_TAG, "Sending connection confirm to the upper stack but really " Loading @@ -277,7 +277,7 @@ void bluetooth::legacy::shim::L2cap::OnLocalInitiatedConnectionCreated( Classic().Callbacks(psm)->pL2CA_ConnectCfm_Cb(cid, status); } bool bluetooth::legacy::shim::L2cap::Write(uint16_t cid, BT_HDR* bt_hdr) { bool bluetooth::shim::legacy::L2cap::Write(uint16_t cid, BT_HDR* bt_hdr) { CHECK(bt_hdr != nullptr); const uint8_t* data = bt_hdr->data + bt_hdr->offset; size_t len = bt_hdr->len; Loading @@ -289,7 +289,7 @@ bool bluetooth::legacy::shim::L2cap::Write(uint16_t cid, BT_HDR* bt_hdr) { return true; } void bluetooth::legacy::shim::L2cap::SetDownstreamCallbacks(uint16_t cid) { void bluetooth::shim::legacy::L2cap::SetDownstreamCallbacks(uint16_t cid) { bluetooth::shim::GetL2cap()->SetReadDataReadyCallback( cid, [this](uint16_t cid, std::vector<const uint8_t> data) { LOG_DEBUG(LOG_TAG, "OnDataReady cid:%hd len:%zd", cid, data.size()); Loading Loading @@ -320,7 +320,7 @@ void bluetooth::legacy::shim::L2cap::SetDownstreamCallbacks(uint16_t cid) { }); } bool bluetooth::legacy::shim::L2cap::ConnectResponse( bool bluetooth::shim::legacy::L2cap::ConnectResponse( const RawAddress& raw_address, uint8_t signal_id, uint16_t cid, uint16_t result, uint16_t status, tL2CAP_ERTM_INFO* ertm_info) { CHECK(ConnectionExists(cid)); Loading @@ -331,7 +331,7 @@ bool bluetooth::legacy::shim::L2cap::ConnectResponse( return true; } bool bluetooth::legacy::shim::L2cap::ConfigRequest( bool bluetooth::shim::legacy::L2cap::ConfigRequest( uint16_t cid, const tL2CAP_CFG_INFO* config_info) { LOG_INFO(LOG_TAG, "Received config request from upper layer cid:%hd", cid); CHECK(ConnectionExists(cid)); Loading @@ -354,7 +354,7 @@ bool bluetooth::legacy::shim::L2cap::ConfigRequest( return true; } bool bluetooth::legacy::shim::L2cap::ConfigResponse( bool bluetooth::shim::legacy::L2cap::ConfigResponse( uint16_t cid, const tL2CAP_CFG_INFO* config_info) { CHECK(ConnectionExists(cid)); LOG_DEBUG( Loading @@ -364,7 +364,7 @@ bool bluetooth::legacy::shim::L2cap::ConfigResponse( return true; } bool bluetooth::legacy::shim::L2cap::DisconnectRequest(uint16_t cid) { bool bluetooth::shim::legacy::L2cap::DisconnectRequest(uint16_t cid) { CHECK(ConnectionExists(cid)); if (cid_closing_set_.find(cid) != cid_closing_set_.end()) { LOG_WARN(LOG_TAG, "%s Channel already in closing state cid:%hu", __func__, Loading @@ -377,7 +377,7 @@ bool bluetooth::legacy::shim::L2cap::DisconnectRequest(uint16_t cid) { return true; } bool bluetooth::legacy::shim::L2cap::DisconnectResponse(uint16_t cid) { bool bluetooth::shim::legacy::L2cap::DisconnectResponse(uint16_t cid) { LOG_DEBUG(LOG_TAG, "%s Silently dropping client disconnect response as channel is " "already disconnected", Loading @@ -385,7 +385,7 @@ bool bluetooth::legacy::shim::L2cap::DisconnectResponse(uint16_t cid) { return true; } void bluetooth::legacy::shim::L2cap::Dump(int fd) { void bluetooth::shim::legacy::L2cap::Dump(int fd) { if (cid_to_psm_map_.empty()) { dprintf(fd, "%s No active l2cap channels\n", kModuleName); } else { Loading system/main/shim/l2cap.h +2 −2 Original line number Diff line number Diff line Loading @@ -24,8 +24,8 @@ #include "stack/include/l2c_api.h" namespace bluetooth { namespace legacy { namespace shim { namespace legacy { static constexpr uint16_t kInitialClassicDynamicPsm = 0x1001; static constexpr uint16_t kFinalClassicDynamicPsm = 0xfeff; Loading Loading @@ -120,6 +120,6 @@ class L2cap { std::unordered_map<uint16_t, uint16_t> client_psm_to_real_psm_map_; }; } // namespace shim } // namespace legacy } // namespace shim } // namespace bluetooth system/main/shim/l2cap_test.cc +3 −3 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ L2capTest* l2cap_test_ = nullptr; class L2capTest : public ::testing::Test { public: static shim::L2cap* l2cap_; static shim::legacy::L2cap* l2cap_; struct { int L2caConnectCfmCb; Loading Loading @@ -77,7 +77,7 @@ class L2capTest : public ::testing::Test { protected: void SetUp() override { l2cap_ = new shim::L2cap(); l2cap_ = new shim::legacy::L2cap(); l2cap_test_ = this; } Loading @@ -89,7 +89,7 @@ class L2capTest : public ::testing::Test { uint8_t data_buffer_[kDataBufferSize]; }; shim::L2cap* L2capTest::l2cap_ = nullptr; shim::legacy::L2cap* L2capTest::l2cap_ = nullptr; // Indication of remotely initiated connection response sent void L2caConnectIndCb(const RawAddress& raw_address, uint16_t a, uint16_t b, uint8_t c) { Loading Loading
system/main/shim/l2c_api.cc +1 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ #include "main/shim/shim.h" #include "osi/include/log.h" static bluetooth::legacy::shim::L2cap shim_l2cap; static bluetooth::shim::legacy::L2cap shim_l2cap; /** * Classic Service Registration APIs Loading
system/main/shim/l2cap.cc +33 −33 Original line number Diff line number Diff line Loading @@ -35,36 +35,36 @@ constexpr uint8_t kUnusedId = 0; constexpr uint16_t kUnusedResult = 0; } // namespace bool bluetooth::legacy::shim::PsmManager::IsPsmRegistered(uint16_t psm) const { bool bluetooth::shim::legacy::PsmManager::IsPsmRegistered(uint16_t psm) const { return psm_to_callback_map_.find(psm) != psm_to_callback_map_.end(); } bool bluetooth::legacy::shim::PsmManager::HasClient(uint16_t psm) const { bool bluetooth::shim::legacy::PsmManager::HasClient(uint16_t psm) const { return IsPsmRegistered(psm) && psm_to_callback_map_.at(psm) != nullptr; } void bluetooth::legacy::shim::PsmManager::RegisterPsm( void bluetooth::shim::legacy::PsmManager::RegisterPsm( uint16_t psm, const tL2CAP_APPL_INFO* callbacks) { CHECK(!HasClient(psm)); psm_to_callback_map_[psm] = callbacks; } void bluetooth::legacy::shim::PsmManager::RegisterPsm(uint16_t psm) { void bluetooth::shim::legacy::PsmManager::RegisterPsm(uint16_t psm) { RegisterPsm(psm, nullptr); } void bluetooth::legacy::shim::PsmManager::UnregisterPsm(uint16_t psm) { void bluetooth::shim::legacy::PsmManager::UnregisterPsm(uint16_t psm) { CHECK(IsPsmRegistered(psm)); psm_to_callback_map_.erase(psm); } const tL2CAP_APPL_INFO* bluetooth::legacy::shim::PsmManager::Callbacks( const tL2CAP_APPL_INFO* bluetooth::shim::legacy::PsmManager::Callbacks( uint16_t psm) { CHECK(HasClient(psm)); return psm_to_callback_map_[psm]; } bluetooth::legacy::shim::L2cap::L2cap() bluetooth::shim::legacy::L2cap::L2cap() : classic_dynamic_psm_(kInitialClassicDynamicPsm), le_dynamic_psm_(kInitialLeDynamicPsm), classic_virtual_psm_(kInitialClassicVirtualPsm) { Loading @@ -72,28 +72,28 @@ bluetooth::legacy::shim::L2cap::L2cap() [this](int fd) { Dump(fd); }); } bluetooth::legacy::shim::L2cap::~L2cap() { bluetooth::shim::legacy::L2cap::~L2cap() { bluetooth::shim::UnregisterDumpsysFunction(static_cast<void*>(this)); } bluetooth::legacy::shim::PsmManager& bluetooth::legacy::shim::L2cap::Le() { bluetooth::shim::legacy::PsmManager& bluetooth::shim::legacy::L2cap::Le() { return le_; } bluetooth::legacy::shim::PsmManager& bluetooth::legacy::shim::L2cap::Classic() { bluetooth::shim::legacy::PsmManager& bluetooth::shim::legacy::L2cap::Classic() { return classic_; } bool bluetooth::legacy::shim::L2cap::ConnectionExists(uint16_t cid) const { bool bluetooth::shim::legacy::L2cap::ConnectionExists(uint16_t cid) const { return cid_to_psm_map_.find(cid) != cid_to_psm_map_.end(); } uint16_t bluetooth::legacy::shim::L2cap::CidToPsm(uint16_t cid) const { uint16_t bluetooth::shim::legacy::L2cap::CidToPsm(uint16_t cid) const { CHECK(ConnectionExists(cid)); return cid_to_psm_map_.at(cid); } uint16_t bluetooth::legacy::shim::L2cap::ConvertClientToRealPsm( uint16_t bluetooth::shim::legacy::L2cap::ConvertClientToRealPsm( uint16_t client_psm, bool is_outgoing_only_connection) { if (!is_outgoing_only_connection) { return client_psm; Loading @@ -101,7 +101,7 @@ uint16_t bluetooth::legacy::shim::L2cap::ConvertClientToRealPsm( return GetNextVirtualPsm(client_psm); } uint16_t bluetooth::legacy::shim::L2cap::ConvertClientToRealPsm( uint16_t bluetooth::shim::legacy::L2cap::ConvertClientToRealPsm( uint16_t client_psm) { if (client_psm_to_real_psm_map_.find(client_psm) == client_psm_to_real_psm_map_.end()) { Loading @@ -110,14 +110,14 @@ uint16_t bluetooth::legacy::shim::L2cap::ConvertClientToRealPsm( return client_psm_to_real_psm_map_.at(client_psm); } void bluetooth::legacy::shim::L2cap::RemoveClientPsm(uint16_t client_psm) { void bluetooth::shim::legacy::L2cap::RemoveClientPsm(uint16_t client_psm) { if (client_psm_to_real_psm_map_.find(client_psm) != client_psm_to_real_psm_map_.end()) { client_psm_to_real_psm_map_.erase(client_psm); } } uint16_t bluetooth::legacy::shim::L2cap::GetNextVirtualPsm(uint16_t real_psm) { uint16_t bluetooth::shim::legacy::L2cap::GetNextVirtualPsm(uint16_t real_psm) { if (real_psm < kInitialClassicDynamicPsm) { return real_psm; } Loading @@ -131,7 +131,7 @@ uint16_t bluetooth::legacy::shim::L2cap::GetNextVirtualPsm(uint16_t real_psm) { return classic_virtual_psm_; } uint16_t bluetooth::legacy::shim::L2cap::GetNextDynamicLePsm() { uint16_t bluetooth::shim::legacy::L2cap::GetNextDynamicLePsm() { while (Le().IsPsmRegistered(le_dynamic_psm_)) { le_dynamic_psm_++; if (le_dynamic_psm_ > kFinalLeDynamicPsm) { Loading @@ -141,7 +141,7 @@ uint16_t bluetooth::legacy::shim::L2cap::GetNextDynamicLePsm() { return le_dynamic_psm_; } uint16_t bluetooth::legacy::shim::L2cap::GetNextDynamicClassicPsm() { uint16_t bluetooth::shim::legacy::L2cap::GetNextDynamicClassicPsm() { while (Classic().IsPsmRegistered(classic_dynamic_psm_)) { classic_dynamic_psm_ += 2; if (classic_dynamic_psm_ > kFinalClassicDynamicPsm) { Loading @@ -160,7 +160,7 @@ uint16_t bluetooth::legacy::shim::L2cap::GetNextDynamicClassicPsm() { return classic_dynamic_psm_; } void bluetooth::legacy::shim::L2cap::RegisterService( void bluetooth::shim::legacy::L2cap::RegisterService( uint16_t psm, const tL2CAP_APPL_INFO* callbacks, bool enable_snoop, tL2CAP_ERTM_INFO* p_ertm_info) { LOG_DEBUG(LOG_TAG, "Registering service on psm:%hd", psm); Loading @@ -181,7 +181,7 @@ void bluetooth::legacy::shim::L2cap::RegisterService( bluetooth::shim::GetL2cap()->RegisterService( psm, use_ertm, mtu, std::bind( &bluetooth::legacy::shim::L2cap::OnRemoteInitiatedConnectionCreated, &bluetooth::shim::legacy::L2cap::OnRemoteInitiatedConnectionCreated, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), std::move(register_completed)); Loading @@ -189,7 +189,7 @@ void bluetooth::legacy::shim::L2cap::RegisterService( LOG_DEBUG(LOG_TAG, "Successfully registered service on psm:%hd", psm); } void bluetooth::legacy::shim::L2cap::OnRemoteInitiatedConnectionCreated( void bluetooth::shim::legacy::L2cap::OnRemoteInitiatedConnectionCreated( std::string string_address, uint16_t psm, uint16_t cid) { RawAddress raw_address; RawAddress::FromString(string_address, raw_address); Loading @@ -206,7 +206,7 @@ void bluetooth::legacy::shim::L2cap::OnRemoteInitiatedConnectionCreated( kUnusedId); } void bluetooth::legacy::shim::L2cap::UnregisterService(uint16_t psm) { void bluetooth::shim::legacy::L2cap::UnregisterService(uint16_t psm) { if (!Classic().IsPsmRegistered(psm)) { LOG_WARN(LOG_TAG, "Service must be registered in order to unregister psm:%hd", psm); Loading @@ -225,7 +225,7 @@ void bluetooth::legacy::shim::L2cap::UnregisterService(uint16_t psm) { Classic().UnregisterPsm(psm); } uint16_t bluetooth::legacy::shim::L2cap::CreateConnection( uint16_t bluetooth::shim::legacy::L2cap::CreateConnection( uint16_t psm, const RawAddress& raw_address) { if (!Classic().IsPsmRegistered(psm)) { LOG_WARN(LOG_TAG, "Service must be registered in order to connect psm:%hd", Loading @@ -242,7 +242,7 @@ uint16_t bluetooth::legacy::shim::L2cap::CreateConnection( bluetooth::shim::GetL2cap()->CreateConnection( psm, raw_address.ToString(), std::bind( &bluetooth::legacy::shim::L2cap::OnLocalInitiatedConnectionCreated, &bluetooth::shim::legacy::L2cap::OnLocalInitiatedConnectionCreated, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3), std::move(connect_completed)); Loading @@ -263,7 +263,7 @@ uint16_t bluetooth::legacy::shim::L2cap::CreateConnection( return cid; } void bluetooth::legacy::shim::L2cap::OnLocalInitiatedConnectionCreated( void bluetooth::shim::legacy::L2cap::OnLocalInitiatedConnectionCreated( std::string string_address, uint16_t psm, uint16_t cid) { LOG_DEBUG(LOG_TAG, "Sending connection confirm to the upper stack but really " Loading @@ -277,7 +277,7 @@ void bluetooth::legacy::shim::L2cap::OnLocalInitiatedConnectionCreated( Classic().Callbacks(psm)->pL2CA_ConnectCfm_Cb(cid, status); } bool bluetooth::legacy::shim::L2cap::Write(uint16_t cid, BT_HDR* bt_hdr) { bool bluetooth::shim::legacy::L2cap::Write(uint16_t cid, BT_HDR* bt_hdr) { CHECK(bt_hdr != nullptr); const uint8_t* data = bt_hdr->data + bt_hdr->offset; size_t len = bt_hdr->len; Loading @@ -289,7 +289,7 @@ bool bluetooth::legacy::shim::L2cap::Write(uint16_t cid, BT_HDR* bt_hdr) { return true; } void bluetooth::legacy::shim::L2cap::SetDownstreamCallbacks(uint16_t cid) { void bluetooth::shim::legacy::L2cap::SetDownstreamCallbacks(uint16_t cid) { bluetooth::shim::GetL2cap()->SetReadDataReadyCallback( cid, [this](uint16_t cid, std::vector<const uint8_t> data) { LOG_DEBUG(LOG_TAG, "OnDataReady cid:%hd len:%zd", cid, data.size()); Loading Loading @@ -320,7 +320,7 @@ void bluetooth::legacy::shim::L2cap::SetDownstreamCallbacks(uint16_t cid) { }); } bool bluetooth::legacy::shim::L2cap::ConnectResponse( bool bluetooth::shim::legacy::L2cap::ConnectResponse( const RawAddress& raw_address, uint8_t signal_id, uint16_t cid, uint16_t result, uint16_t status, tL2CAP_ERTM_INFO* ertm_info) { CHECK(ConnectionExists(cid)); Loading @@ -331,7 +331,7 @@ bool bluetooth::legacy::shim::L2cap::ConnectResponse( return true; } bool bluetooth::legacy::shim::L2cap::ConfigRequest( bool bluetooth::shim::legacy::L2cap::ConfigRequest( uint16_t cid, const tL2CAP_CFG_INFO* config_info) { LOG_INFO(LOG_TAG, "Received config request from upper layer cid:%hd", cid); CHECK(ConnectionExists(cid)); Loading @@ -354,7 +354,7 @@ bool bluetooth::legacy::shim::L2cap::ConfigRequest( return true; } bool bluetooth::legacy::shim::L2cap::ConfigResponse( bool bluetooth::shim::legacy::L2cap::ConfigResponse( uint16_t cid, const tL2CAP_CFG_INFO* config_info) { CHECK(ConnectionExists(cid)); LOG_DEBUG( Loading @@ -364,7 +364,7 @@ bool bluetooth::legacy::shim::L2cap::ConfigResponse( return true; } bool bluetooth::legacy::shim::L2cap::DisconnectRequest(uint16_t cid) { bool bluetooth::shim::legacy::L2cap::DisconnectRequest(uint16_t cid) { CHECK(ConnectionExists(cid)); if (cid_closing_set_.find(cid) != cid_closing_set_.end()) { LOG_WARN(LOG_TAG, "%s Channel already in closing state cid:%hu", __func__, Loading @@ -377,7 +377,7 @@ bool bluetooth::legacy::shim::L2cap::DisconnectRequest(uint16_t cid) { return true; } bool bluetooth::legacy::shim::L2cap::DisconnectResponse(uint16_t cid) { bool bluetooth::shim::legacy::L2cap::DisconnectResponse(uint16_t cid) { LOG_DEBUG(LOG_TAG, "%s Silently dropping client disconnect response as channel is " "already disconnected", Loading @@ -385,7 +385,7 @@ bool bluetooth::legacy::shim::L2cap::DisconnectResponse(uint16_t cid) { return true; } void bluetooth::legacy::shim::L2cap::Dump(int fd) { void bluetooth::shim::legacy::L2cap::Dump(int fd) { if (cid_to_psm_map_.empty()) { dprintf(fd, "%s No active l2cap channels\n", kModuleName); } else { Loading
system/main/shim/l2cap.h +2 −2 Original line number Diff line number Diff line Loading @@ -24,8 +24,8 @@ #include "stack/include/l2c_api.h" namespace bluetooth { namespace legacy { namespace shim { namespace legacy { static constexpr uint16_t kInitialClassicDynamicPsm = 0x1001; static constexpr uint16_t kFinalClassicDynamicPsm = 0xfeff; Loading Loading @@ -120,6 +120,6 @@ class L2cap { std::unordered_map<uint16_t, uint16_t> client_psm_to_real_psm_map_; }; } // namespace shim } // namespace legacy } // namespace shim } // namespace bluetooth
system/main/shim/l2cap_test.cc +3 −3 Original line number Diff line number Diff line Loading @@ -47,7 +47,7 @@ L2capTest* l2cap_test_ = nullptr; class L2capTest : public ::testing::Test { public: static shim::L2cap* l2cap_; static shim::legacy::L2cap* l2cap_; struct { int L2caConnectCfmCb; Loading Loading @@ -77,7 +77,7 @@ class L2capTest : public ::testing::Test { protected: void SetUp() override { l2cap_ = new shim::L2cap(); l2cap_ = new shim::legacy::L2cap(); l2cap_test_ = this; } Loading @@ -89,7 +89,7 @@ class L2capTest : public ::testing::Test { uint8_t data_buffer_[kDataBufferSize]; }; shim::L2cap* L2capTest::l2cap_ = nullptr; shim::legacy::L2cap* L2capTest::l2cap_ = nullptr; // Indication of remotely initiated connection response sent void L2caConnectIndCb(const RawAddress& raw_address, uint16_t a, uint16_t b, uint8_t c) { Loading