Loading system/main/shim/acl.cc +62 −69 Original line number Diff line number Diff line Loading @@ -99,10 +99,10 @@ struct ConnectionDescriptor { " creation_time:%s teardown_time:%s disconnect_reason:%s", GetPrivateRemoteAddress().c_str(), handle_, logbool(is_locally_initiated_).c_str(), bluetooth::common::StringFormatTimeWithMilliseconds( common::StringFormatTimeWithMilliseconds( kConnectionDescriptorTimeFormat, creation_time_) .c_str(), bluetooth::common::StringFormatTimeWithMilliseconds( common::StringFormatTimeWithMilliseconds( kConnectionDescriptorTimeFormat, teardown_time_) .c_str(), hci::ErrorCodeText(disconnect_reason_).c_str()); Loading Loading @@ -167,8 +167,7 @@ constexpr size_t kConnectionHistorySize = 40; inline uint8_t LowByte(uint16_t val) { return val & 0xff; } inline uint8_t HighByte(uint16_t val) { return val >> 8; } void ValidateAclInterface( const bluetooth::shim::legacy::acl_interface_t& acl_interface) { void ValidateAclInterface(const shim::legacy::acl_interface_t& acl_interface) { ASSERT_LOG(acl_interface.on_send_data_upwards != nullptr, "Must provide to receive data on acl links"); ASSERT_LOG(acl_interface.on_packets_completed != nullptr, Loading Loading @@ -223,13 +222,13 @@ class ShimAclConnection { "Shim Acl was not properly disconnected handle:0x%04x", handle_); } void EnqueuePacket(std::unique_ptr<bluetooth::packet::RawBuilder> packet) { void EnqueuePacket(std::unique_ptr<packet::RawBuilder> packet) { // TODO Handle queue size exceeds some threshold queue_.push(std::move(packet)); RegisterEnqueue(); } std::unique_ptr<bluetooth::packet::BasePacketBuilder> handle_enqueue() { std::unique_ptr<packet::BasePacketBuilder> handle_enqueue() { auto packet = std::move(queue_.front()); queue_.pop(); if (queue_.empty()) { Loading Loading @@ -285,7 +284,7 @@ class ShimAclConnection { SendDataUpwards send_data_upwards_; hci::acl_manager::AclConnection::QueueUpEnd* queue_up_end_; std::queue<std::unique_ptr<bluetooth::packet::RawBuilder>> queue_; std::queue<std::unique_ptr<packet::RawBuilder>> queue_; bool is_enqueue_registered_{false}; bool is_disconnected_{false}; CreationTime creation_time_; Loading Loading @@ -582,7 +581,7 @@ class LeShimAclConnection std::unique_ptr<hci::acl_manager::LeAclConnection> connection_; }; struct bluetooth::shim::legacy::Acl::impl { struct shim::legacy::Acl::impl { std::map<HciHandle, std::unique_ptr<ClassicShimAclConnection>> handle_to_classic_connection_map_; std::map<HciHandle, std::unique_ptr<LeShimAclConnection>> Loading @@ -596,8 +595,8 @@ struct bluetooth::shim::legacy::Acl::impl { handle_to_classic_connection_map_.end(); } void EnqueueClassicPacket( HciHandle handle, std::unique_ptr<bluetooth::packet::RawBuilder> packet) { void EnqueueClassicPacket(HciHandle handle, std::unique_ptr<packet::RawBuilder> packet) { ASSERT_LOG(IsClassicAcl(handle), "handle %d is not a classic connection", handle); handle_to_classic_connection_map_[handle]->EnqueuePacket(std::move(packet)); Loading @@ -609,7 +608,7 @@ struct bluetooth::shim::legacy::Acl::impl { } void EnqueueLePacket(HciHandle handle, std::unique_ptr<bluetooth::packet::RawBuilder> packet) { std::unique_ptr<packet::RawBuilder> packet) { ASSERT_LOG(IsLeAcl(handle), "handle %d is not a LE connection", handle); handle_to_le_connection_map_[handle]->EnqueuePacket(std::move(packet)); } Loading Loading @@ -716,7 +715,7 @@ void DumpsysAcl(int fd) { LOG_DUMPSYS_TITLE(fd, DUMPSYS_TAG); bluetooth::shim::Stack::GetInstance()->GetAcl()->DumpConnectionHistory(fd); shim::Stack::GetInstance()->GetAcl()->DumpConnectionHistory(fd); for (int i = 0; i < MAX_L2CAP_LINKS; i++) { const tACL_CONN& acl_conn = acl_cb.acl_db[i]; Loading Loading @@ -760,7 +759,7 @@ void DumpsysAcl(int fd) { } #undef DUMPSYS_TAG using Record = bluetooth::common::TimestampedEntry<std::string>; using Record = common::TimestampedEntry<std::string>; const std::string kTimeFormat("%Y-%m-%d %H:%M:%S"); #define DUMPSYS_TAG "shim::legacy::btm" Loading Loading @@ -802,14 +801,14 @@ void DumpsysRecord(int fd) { } #undef DUMPSYS_TAG void bluetooth::shim::legacy::Acl::Dump(int fd) const { void shim::legacy::Acl::Dump(int fd) const { DumpsysRecord(fd); DumpsysAcl(fd); DumpsysL2cap(fd); DumpsysBtm(fd); } bluetooth::shim::legacy::Acl::Acl(os::Handler* handler, shim::legacy::Acl::Acl(os::Handler* handler, const acl_interface_t& acl_interface) : handler_(handler), acl_interface_(acl_interface) { ValidateAclInterface(acl_interface_); Loading @@ -818,7 +817,7 @@ bluetooth::shim::legacy::Acl::Acl(os::Handler* handler, GetAclManager()->RegisterLeCallbacks(this, handler_); GetController()->RegisterCompletedMonitorAclPacketsCallback( handler->BindOn(this, &Acl::on_incoming_acl_credits)); bluetooth::shim::RegisterDumpsysFunction(static_cast<void*>(this), shim::RegisterDumpsysFunction(static_cast<void*>(this), [this](int fd) { Dump(fd); }); Stack::GetInstance()->GetBtm()->Register_HACK_SetScoDisconnectCallback( [this](uint16_t handle, uint8_t reason) { Loading @@ -827,8 +826,8 @@ bluetooth::shim::legacy::Acl::Acl(os::Handler* handler, }); } bluetooth::shim::legacy::Acl::~Acl() { bluetooth::shim::UnregisterDumpsysFunction(static_cast<void*>(this)); shim::legacy::Acl::~Acl() { shim::UnregisterDumpsysFunction(static_cast<void*>(this)); GetController()->UnregisterCompletedMonitorAclPacketsCallback(); if (CheckForOrphanedAclConnections()) { Loading @@ -836,7 +835,7 @@ bluetooth::shim::legacy::Acl::~Acl() { } } bool bluetooth::shim::legacy::Acl::CheckForOrphanedAclConnections() const { bool shim::legacy::Acl::CheckForOrphanedAclConnections() const { bool orphaned_acl_connections = false; if (!pimpl_->handle_to_classic_connection_map_.empty()) { Loading @@ -845,7 +844,7 @@ bool bluetooth::shim::legacy::Acl::CheckForOrphanedAclConnections() const { LOG_ERROR(" Orphaned classic ACL handle:0x%04x bd_addr:%s created:%s", connection.second->Handle(), PRIVATE_ADDRESS(connection.second->GetRemoteAddress()), bluetooth::common::StringFormatTimeWithMilliseconds( common::StringFormatTimeWithMilliseconds( kConnectionDescriptorTimeFormat, connection.second->GetCreationTime()) .c_str()); Loading @@ -859,7 +858,7 @@ bool bluetooth::shim::legacy::Acl::CheckForOrphanedAclConnections() const { LOG_ERROR(" Orphaned le ACL handle:0x%04x bd_addr:%s created:%s", connection.second->Handle(), PRIVATE_ADDRESS(connection.second->GetRemoteAddressWithType()), bluetooth::common::StringFormatTimeWithMilliseconds( common::StringFormatTimeWithMilliseconds( kConnectionDescriptorTimeFormat, connection.second->GetCreationTime()) .c_str()); Loading @@ -869,13 +868,13 @@ bool bluetooth::shim::legacy::Acl::CheckForOrphanedAclConnections() const { return orphaned_acl_connections; } void bluetooth::shim::legacy::Acl::on_incoming_acl_credits(uint16_t handle, void shim::legacy::Acl::on_incoming_acl_credits(uint16_t handle, uint16_t credits) { TRY_POSTING_ON_MAIN(acl_interface_.on_packets_completed, handle, credits); } void bluetooth::shim::legacy::Acl::write_data_sync( HciHandle handle, std::unique_ptr<bluetooth::packet::RawBuilder> packet) { void shim::legacy::Acl::write_data_sync( HciHandle handle, std::unique_ptr<packet::RawBuilder> packet) { if (pimpl_->IsClassicAcl(handle)) { pimpl_->EnqueueClassicPacket(handle, std::move(packet)); } else if (pimpl_->IsLeAcl(handle)) { Loading @@ -885,15 +884,14 @@ void bluetooth::shim::legacy::Acl::write_data_sync( } } void bluetooth::shim::legacy::Acl::WriteData( HciHandle handle, std::unique_ptr<bluetooth::packet::RawBuilder> packet) { void shim::legacy::Acl::WriteData(HciHandle handle, std::unique_ptr<packet::RawBuilder> packet) { handler_->Post(common::BindOnce(&Acl::write_data_sync, common::Unretained(this), handle, std::move(packet))); } void bluetooth::shim::legacy::Acl::CreateClassicConnection( const bluetooth::hci::Address& address) { void shim::legacy::Acl::CreateClassicConnection(const hci::Address& address) { GetAclManager()->CreateConnection(address); LOG_DEBUG("Connection initiated for classic to remote:%s", PRIVATE_ADDRESS(address)); Loading @@ -901,8 +899,8 @@ void bluetooth::shim::legacy::Acl::CreateClassicConnection( "classic"); } void bluetooth::shim::legacy::Acl::CreateLeConnection( const bluetooth::hci::AddressWithType& address_with_type) { void shim::legacy::Acl::CreateLeConnection( const hci::AddressWithType& address_with_type) { GetAclManager()->CreateLeConnection(address_with_type); LOG_DEBUG("Connection initiated for le connection to remote:%s", PRIVATE_ADDRESS(address_with_type)); Loading @@ -910,8 +908,8 @@ void bluetooth::shim::legacy::Acl::CreateLeConnection( "Initiated connection", "le"); } void bluetooth::shim::legacy::Acl::CancelLeConnection( const bluetooth::hci::AddressWithType& address_with_type) { void shim::legacy::Acl::CancelLeConnection( const hci::AddressWithType& address_with_type) { GetAclManager()->CancelLeConnect(address_with_type); LOG_DEBUG("Cancelled le connection to remote:%s", PRIVATE_ADDRESS(address_with_type)); Loading @@ -919,9 +917,9 @@ void bluetooth::shim::legacy::Acl::CancelLeConnection( "Cancelled connection", "le"); } void bluetooth::shim::legacy::Acl::OnClassicLinkDisconnected( HciHandle handle, hci::ErrorCode reason) { bluetooth::hci::Address remote_address = void shim::legacy::Acl::OnClassicLinkDisconnected(HciHandle handle, hci::ErrorCode reason) { hci::Address remote_address = pimpl_->handle_to_classic_connection_map_[handle]->GetRemoteAddress(); CreationTime creation_time = pimpl_->handle_to_classic_connection_map_[handle]->GetCreationTime(); Loading @@ -946,7 +944,7 @@ void bluetooth::shim::legacy::Acl::OnClassicLinkDisconnected( is_locally_initiated, reason))); } void bluetooth::shim::legacy::Acl::OnLeLinkDisconnected(HciHandle handle, void shim::legacy::Acl::OnLeLinkDisconnected(HciHandle handle, hci::ErrorCode reason) { hci::AddressWithType remote_address_with_type = pimpl_->handle_to_le_connection_map_[handle]->GetRemoteAddressWithType(); Loading Loading @@ -974,7 +972,7 @@ void bluetooth::shim::legacy::Acl::OnLeLinkDisconnected(HciHandle handle, is_locally_initiated, reason))); } void bluetooth::shim::legacy::Acl::OnConnectSuccess( void shim::legacy::Acl::OnConnectSuccess( std::unique_ptr<hci::acl_manager::ClassicAclConnection> connection) { ASSERT(connection != nullptr); auto handle = connection->GetHandle(); Loading Loading @@ -1003,7 +1001,7 @@ void bluetooth::shim::legacy::Acl::OnConnectSuccess( (locally_initiated) ? "Local initiated" : "Remote initiated"); } void bluetooth::shim::legacy::Acl::OnConnectFail(hci::Address address, void shim::legacy::Acl::OnConnectFail(hci::Address address, hci::ErrorCode reason) { const RawAddress bd_addr = ToRawAddress(address); TRY_POSTING_ON_MAIN(acl_interface_.connection.classic.on_failed, bd_addr, Loading @@ -1015,13 +1013,13 @@ void bluetooth::shim::legacy::Acl::OnConnectFail(hci::Address address, hci::ErrorCodeText(reason).c_str())); } void bluetooth::shim::legacy::Acl::OnLeConnectSuccess( void shim::legacy::Acl::OnLeConnectSuccess( hci::AddressWithType address_with_type, std::unique_ptr<hci::acl_manager::LeAclConnection> connection) { ASSERT(connection != nullptr); auto handle = connection->GetHandle(); bluetooth::hci::Role connection_role = connection->GetRole(); hci::Role connection_role = connection->GetRole(); bool locally_initiated = connection->locally_initiated_; pimpl_->handle_to_le_connection_map_.emplace( Loading Loading @@ -1059,8 +1057,8 @@ void bluetooth::shim::legacy::Acl::OnLeConnectSuccess( "Connection successful", "le"); } void bluetooth::shim::legacy::Acl::OnLeConnectFail( hci::AddressWithType address_with_type, hci::ErrorCode reason) { void shim::legacy::Acl::OnLeConnectFail(hci::AddressWithType address_with_type, hci::ErrorCode reason) { tBLE_BD_ADDR legacy_address_with_type = ToLegacyAddressWithType(address_with_type); Loading @@ -1078,8 +1076,7 @@ void bluetooth::shim::legacy::Acl::OnLeConnectFail( base::StringPrintf("le reason:%s", hci::ErrorCodeText(reason).c_str())); } void bluetooth::shim::legacy::Acl::ConfigureLePrivacy( bool is_le_privacy_enabled) { void shim::legacy::Acl::ConfigureLePrivacy(bool is_le_privacy_enabled) { LOG_INFO("Configuring Le privacy:%s", (is_le_privacy_enabled) ? "true" : "false"); ASSERT_LOG(is_le_privacy_enabled, Loading @@ -1100,8 +1097,7 @@ void bluetooth::shim::legacy::Acl::ConfigureLePrivacy( maximum_rotation_time); } void bluetooth::shim::legacy::Acl::DisconnectClassic(uint16_t handle, tHCI_STATUS reason) { void shim::legacy::Acl::DisconnectClassic(uint16_t handle, tHCI_STATUS reason) { auto connection = pimpl_->handle_to_classic_connection_map_.find(handle); if (connection != pimpl_->handle_to_classic_connection_map_.end()) { auto remote_address = connection->second->GetRemoteAddress(); Loading @@ -1117,8 +1113,7 @@ void bluetooth::shim::legacy::Acl::DisconnectClassic(uint16_t handle, } } void bluetooth::shim::legacy::Acl::DisconnectLe(uint16_t handle, tHCI_STATUS reason) { void shim::legacy::Acl::DisconnectLe(uint16_t handle, tHCI_STATUS reason) { auto connection = pimpl_->handle_to_le_connection_map_.find(handle); if (connection != pimpl_->handle_to_le_connection_map_.end()) { auto remote_address_with_type = Loading @@ -1135,49 +1130,47 @@ void bluetooth::shim::legacy::Acl::DisconnectLe(uint16_t handle, handle); } } bool bluetooth::shim::legacy::Acl::HoldMode(uint16_t hci_handle, uint16_t max_interval, bool shim::legacy::Acl::HoldMode(uint16_t hci_handle, uint16_t max_interval, uint16_t min_interval) { handler_->CallOn(pimpl_.get(), &Acl::impl::HoldMode, hci_handle, max_interval, min_interval); return false; // TODO void } bool bluetooth::shim::legacy::Acl::SniffMode(uint16_t hci_handle, uint16_t max_interval, uint16_t min_interval, uint16_t attempt, bool shim::legacy::Acl::SniffMode(uint16_t hci_handle, uint16_t max_interval, uint16_t min_interval, uint16_t attempt, uint16_t timeout) { handler_->CallOn(pimpl_.get(), &Acl::impl::SniffMode, hci_handle, max_interval, min_interval, attempt, timeout); return false; } bool bluetooth::shim::legacy::Acl::ExitSniffMode(uint16_t hci_handle) { bool shim::legacy::Acl::ExitSniffMode(uint16_t hci_handle) { handler_->CallOn(pimpl_.get(), &Acl::impl::ExitSniffMode, hci_handle); return false; } bool bluetooth::shim::legacy::Acl::SniffSubrating( uint16_t hci_handle, uint16_t maximum_latency, uint16_t minimum_remote_timeout, uint16_t minimum_local_timeout) { bool shim::legacy::Acl::SniffSubrating(uint16_t hci_handle, uint16_t maximum_latency, uint16_t minimum_remote_timeout, uint16_t minimum_local_timeout) { handler_->CallOn(pimpl_.get(), &Acl::impl::SniffSubrating, hci_handle, maximum_latency, minimum_remote_timeout, minimum_local_timeout); return false; } void bluetooth::shim::legacy::Acl::HACK_OnScoDisconnected(uint16_t handle, void shim::legacy::Acl::HACK_OnScoDisconnected(uint16_t handle, uint8_t reason) { TRY_POSTING_ON_MAIN(acl_interface_.connection.sco.on_disconnected, handle, static_cast<tHCI_REASON>(reason)); } void bluetooth::shim::legacy::Acl::DumpConnectionHistory(int fd) const { void shim::legacy::Acl::DumpConnectionHistory(int fd) const { pimpl_->DumpConnectionHistory(fd); } void bluetooth::shim::legacy::Acl::Shutdown() { void shim::legacy::Acl::Shutdown() { if (CheckForOrphanedAclConnections()) { std::promise<void> shutdown_promise; auto shutdown_future = shutdown_promise.get_future(); Loading Loading
system/main/shim/acl.cc +62 −69 Original line number Diff line number Diff line Loading @@ -99,10 +99,10 @@ struct ConnectionDescriptor { " creation_time:%s teardown_time:%s disconnect_reason:%s", GetPrivateRemoteAddress().c_str(), handle_, logbool(is_locally_initiated_).c_str(), bluetooth::common::StringFormatTimeWithMilliseconds( common::StringFormatTimeWithMilliseconds( kConnectionDescriptorTimeFormat, creation_time_) .c_str(), bluetooth::common::StringFormatTimeWithMilliseconds( common::StringFormatTimeWithMilliseconds( kConnectionDescriptorTimeFormat, teardown_time_) .c_str(), hci::ErrorCodeText(disconnect_reason_).c_str()); Loading Loading @@ -167,8 +167,7 @@ constexpr size_t kConnectionHistorySize = 40; inline uint8_t LowByte(uint16_t val) { return val & 0xff; } inline uint8_t HighByte(uint16_t val) { return val >> 8; } void ValidateAclInterface( const bluetooth::shim::legacy::acl_interface_t& acl_interface) { void ValidateAclInterface(const shim::legacy::acl_interface_t& acl_interface) { ASSERT_LOG(acl_interface.on_send_data_upwards != nullptr, "Must provide to receive data on acl links"); ASSERT_LOG(acl_interface.on_packets_completed != nullptr, Loading Loading @@ -223,13 +222,13 @@ class ShimAclConnection { "Shim Acl was not properly disconnected handle:0x%04x", handle_); } void EnqueuePacket(std::unique_ptr<bluetooth::packet::RawBuilder> packet) { void EnqueuePacket(std::unique_ptr<packet::RawBuilder> packet) { // TODO Handle queue size exceeds some threshold queue_.push(std::move(packet)); RegisterEnqueue(); } std::unique_ptr<bluetooth::packet::BasePacketBuilder> handle_enqueue() { std::unique_ptr<packet::BasePacketBuilder> handle_enqueue() { auto packet = std::move(queue_.front()); queue_.pop(); if (queue_.empty()) { Loading Loading @@ -285,7 +284,7 @@ class ShimAclConnection { SendDataUpwards send_data_upwards_; hci::acl_manager::AclConnection::QueueUpEnd* queue_up_end_; std::queue<std::unique_ptr<bluetooth::packet::RawBuilder>> queue_; std::queue<std::unique_ptr<packet::RawBuilder>> queue_; bool is_enqueue_registered_{false}; bool is_disconnected_{false}; CreationTime creation_time_; Loading Loading @@ -582,7 +581,7 @@ class LeShimAclConnection std::unique_ptr<hci::acl_manager::LeAclConnection> connection_; }; struct bluetooth::shim::legacy::Acl::impl { struct shim::legacy::Acl::impl { std::map<HciHandle, std::unique_ptr<ClassicShimAclConnection>> handle_to_classic_connection_map_; std::map<HciHandle, std::unique_ptr<LeShimAclConnection>> Loading @@ -596,8 +595,8 @@ struct bluetooth::shim::legacy::Acl::impl { handle_to_classic_connection_map_.end(); } void EnqueueClassicPacket( HciHandle handle, std::unique_ptr<bluetooth::packet::RawBuilder> packet) { void EnqueueClassicPacket(HciHandle handle, std::unique_ptr<packet::RawBuilder> packet) { ASSERT_LOG(IsClassicAcl(handle), "handle %d is not a classic connection", handle); handle_to_classic_connection_map_[handle]->EnqueuePacket(std::move(packet)); Loading @@ -609,7 +608,7 @@ struct bluetooth::shim::legacy::Acl::impl { } void EnqueueLePacket(HciHandle handle, std::unique_ptr<bluetooth::packet::RawBuilder> packet) { std::unique_ptr<packet::RawBuilder> packet) { ASSERT_LOG(IsLeAcl(handle), "handle %d is not a LE connection", handle); handle_to_le_connection_map_[handle]->EnqueuePacket(std::move(packet)); } Loading Loading @@ -716,7 +715,7 @@ void DumpsysAcl(int fd) { LOG_DUMPSYS_TITLE(fd, DUMPSYS_TAG); bluetooth::shim::Stack::GetInstance()->GetAcl()->DumpConnectionHistory(fd); shim::Stack::GetInstance()->GetAcl()->DumpConnectionHistory(fd); for (int i = 0; i < MAX_L2CAP_LINKS; i++) { const tACL_CONN& acl_conn = acl_cb.acl_db[i]; Loading Loading @@ -760,7 +759,7 @@ void DumpsysAcl(int fd) { } #undef DUMPSYS_TAG using Record = bluetooth::common::TimestampedEntry<std::string>; using Record = common::TimestampedEntry<std::string>; const std::string kTimeFormat("%Y-%m-%d %H:%M:%S"); #define DUMPSYS_TAG "shim::legacy::btm" Loading Loading @@ -802,14 +801,14 @@ void DumpsysRecord(int fd) { } #undef DUMPSYS_TAG void bluetooth::shim::legacy::Acl::Dump(int fd) const { void shim::legacy::Acl::Dump(int fd) const { DumpsysRecord(fd); DumpsysAcl(fd); DumpsysL2cap(fd); DumpsysBtm(fd); } bluetooth::shim::legacy::Acl::Acl(os::Handler* handler, shim::legacy::Acl::Acl(os::Handler* handler, const acl_interface_t& acl_interface) : handler_(handler), acl_interface_(acl_interface) { ValidateAclInterface(acl_interface_); Loading @@ -818,7 +817,7 @@ bluetooth::shim::legacy::Acl::Acl(os::Handler* handler, GetAclManager()->RegisterLeCallbacks(this, handler_); GetController()->RegisterCompletedMonitorAclPacketsCallback( handler->BindOn(this, &Acl::on_incoming_acl_credits)); bluetooth::shim::RegisterDumpsysFunction(static_cast<void*>(this), shim::RegisterDumpsysFunction(static_cast<void*>(this), [this](int fd) { Dump(fd); }); Stack::GetInstance()->GetBtm()->Register_HACK_SetScoDisconnectCallback( [this](uint16_t handle, uint8_t reason) { Loading @@ -827,8 +826,8 @@ bluetooth::shim::legacy::Acl::Acl(os::Handler* handler, }); } bluetooth::shim::legacy::Acl::~Acl() { bluetooth::shim::UnregisterDumpsysFunction(static_cast<void*>(this)); shim::legacy::Acl::~Acl() { shim::UnregisterDumpsysFunction(static_cast<void*>(this)); GetController()->UnregisterCompletedMonitorAclPacketsCallback(); if (CheckForOrphanedAclConnections()) { Loading @@ -836,7 +835,7 @@ bluetooth::shim::legacy::Acl::~Acl() { } } bool bluetooth::shim::legacy::Acl::CheckForOrphanedAclConnections() const { bool shim::legacy::Acl::CheckForOrphanedAclConnections() const { bool orphaned_acl_connections = false; if (!pimpl_->handle_to_classic_connection_map_.empty()) { Loading @@ -845,7 +844,7 @@ bool bluetooth::shim::legacy::Acl::CheckForOrphanedAclConnections() const { LOG_ERROR(" Orphaned classic ACL handle:0x%04x bd_addr:%s created:%s", connection.second->Handle(), PRIVATE_ADDRESS(connection.second->GetRemoteAddress()), bluetooth::common::StringFormatTimeWithMilliseconds( common::StringFormatTimeWithMilliseconds( kConnectionDescriptorTimeFormat, connection.second->GetCreationTime()) .c_str()); Loading @@ -859,7 +858,7 @@ bool bluetooth::shim::legacy::Acl::CheckForOrphanedAclConnections() const { LOG_ERROR(" Orphaned le ACL handle:0x%04x bd_addr:%s created:%s", connection.second->Handle(), PRIVATE_ADDRESS(connection.second->GetRemoteAddressWithType()), bluetooth::common::StringFormatTimeWithMilliseconds( common::StringFormatTimeWithMilliseconds( kConnectionDescriptorTimeFormat, connection.second->GetCreationTime()) .c_str()); Loading @@ -869,13 +868,13 @@ bool bluetooth::shim::legacy::Acl::CheckForOrphanedAclConnections() const { return orphaned_acl_connections; } void bluetooth::shim::legacy::Acl::on_incoming_acl_credits(uint16_t handle, void shim::legacy::Acl::on_incoming_acl_credits(uint16_t handle, uint16_t credits) { TRY_POSTING_ON_MAIN(acl_interface_.on_packets_completed, handle, credits); } void bluetooth::shim::legacy::Acl::write_data_sync( HciHandle handle, std::unique_ptr<bluetooth::packet::RawBuilder> packet) { void shim::legacy::Acl::write_data_sync( HciHandle handle, std::unique_ptr<packet::RawBuilder> packet) { if (pimpl_->IsClassicAcl(handle)) { pimpl_->EnqueueClassicPacket(handle, std::move(packet)); } else if (pimpl_->IsLeAcl(handle)) { Loading @@ -885,15 +884,14 @@ void bluetooth::shim::legacy::Acl::write_data_sync( } } void bluetooth::shim::legacy::Acl::WriteData( HciHandle handle, std::unique_ptr<bluetooth::packet::RawBuilder> packet) { void shim::legacy::Acl::WriteData(HciHandle handle, std::unique_ptr<packet::RawBuilder> packet) { handler_->Post(common::BindOnce(&Acl::write_data_sync, common::Unretained(this), handle, std::move(packet))); } void bluetooth::shim::legacy::Acl::CreateClassicConnection( const bluetooth::hci::Address& address) { void shim::legacy::Acl::CreateClassicConnection(const hci::Address& address) { GetAclManager()->CreateConnection(address); LOG_DEBUG("Connection initiated for classic to remote:%s", PRIVATE_ADDRESS(address)); Loading @@ -901,8 +899,8 @@ void bluetooth::shim::legacy::Acl::CreateClassicConnection( "classic"); } void bluetooth::shim::legacy::Acl::CreateLeConnection( const bluetooth::hci::AddressWithType& address_with_type) { void shim::legacy::Acl::CreateLeConnection( const hci::AddressWithType& address_with_type) { GetAclManager()->CreateLeConnection(address_with_type); LOG_DEBUG("Connection initiated for le connection to remote:%s", PRIVATE_ADDRESS(address_with_type)); Loading @@ -910,8 +908,8 @@ void bluetooth::shim::legacy::Acl::CreateLeConnection( "Initiated connection", "le"); } void bluetooth::shim::legacy::Acl::CancelLeConnection( const bluetooth::hci::AddressWithType& address_with_type) { void shim::legacy::Acl::CancelLeConnection( const hci::AddressWithType& address_with_type) { GetAclManager()->CancelLeConnect(address_with_type); LOG_DEBUG("Cancelled le connection to remote:%s", PRIVATE_ADDRESS(address_with_type)); Loading @@ -919,9 +917,9 @@ void bluetooth::shim::legacy::Acl::CancelLeConnection( "Cancelled connection", "le"); } void bluetooth::shim::legacy::Acl::OnClassicLinkDisconnected( HciHandle handle, hci::ErrorCode reason) { bluetooth::hci::Address remote_address = void shim::legacy::Acl::OnClassicLinkDisconnected(HciHandle handle, hci::ErrorCode reason) { hci::Address remote_address = pimpl_->handle_to_classic_connection_map_[handle]->GetRemoteAddress(); CreationTime creation_time = pimpl_->handle_to_classic_connection_map_[handle]->GetCreationTime(); Loading @@ -946,7 +944,7 @@ void bluetooth::shim::legacy::Acl::OnClassicLinkDisconnected( is_locally_initiated, reason))); } void bluetooth::shim::legacy::Acl::OnLeLinkDisconnected(HciHandle handle, void shim::legacy::Acl::OnLeLinkDisconnected(HciHandle handle, hci::ErrorCode reason) { hci::AddressWithType remote_address_with_type = pimpl_->handle_to_le_connection_map_[handle]->GetRemoteAddressWithType(); Loading Loading @@ -974,7 +972,7 @@ void bluetooth::shim::legacy::Acl::OnLeLinkDisconnected(HciHandle handle, is_locally_initiated, reason))); } void bluetooth::shim::legacy::Acl::OnConnectSuccess( void shim::legacy::Acl::OnConnectSuccess( std::unique_ptr<hci::acl_manager::ClassicAclConnection> connection) { ASSERT(connection != nullptr); auto handle = connection->GetHandle(); Loading Loading @@ -1003,7 +1001,7 @@ void bluetooth::shim::legacy::Acl::OnConnectSuccess( (locally_initiated) ? "Local initiated" : "Remote initiated"); } void bluetooth::shim::legacy::Acl::OnConnectFail(hci::Address address, void shim::legacy::Acl::OnConnectFail(hci::Address address, hci::ErrorCode reason) { const RawAddress bd_addr = ToRawAddress(address); TRY_POSTING_ON_MAIN(acl_interface_.connection.classic.on_failed, bd_addr, Loading @@ -1015,13 +1013,13 @@ void bluetooth::shim::legacy::Acl::OnConnectFail(hci::Address address, hci::ErrorCodeText(reason).c_str())); } void bluetooth::shim::legacy::Acl::OnLeConnectSuccess( void shim::legacy::Acl::OnLeConnectSuccess( hci::AddressWithType address_with_type, std::unique_ptr<hci::acl_manager::LeAclConnection> connection) { ASSERT(connection != nullptr); auto handle = connection->GetHandle(); bluetooth::hci::Role connection_role = connection->GetRole(); hci::Role connection_role = connection->GetRole(); bool locally_initiated = connection->locally_initiated_; pimpl_->handle_to_le_connection_map_.emplace( Loading Loading @@ -1059,8 +1057,8 @@ void bluetooth::shim::legacy::Acl::OnLeConnectSuccess( "Connection successful", "le"); } void bluetooth::shim::legacy::Acl::OnLeConnectFail( hci::AddressWithType address_with_type, hci::ErrorCode reason) { void shim::legacy::Acl::OnLeConnectFail(hci::AddressWithType address_with_type, hci::ErrorCode reason) { tBLE_BD_ADDR legacy_address_with_type = ToLegacyAddressWithType(address_with_type); Loading @@ -1078,8 +1076,7 @@ void bluetooth::shim::legacy::Acl::OnLeConnectFail( base::StringPrintf("le reason:%s", hci::ErrorCodeText(reason).c_str())); } void bluetooth::shim::legacy::Acl::ConfigureLePrivacy( bool is_le_privacy_enabled) { void shim::legacy::Acl::ConfigureLePrivacy(bool is_le_privacy_enabled) { LOG_INFO("Configuring Le privacy:%s", (is_le_privacy_enabled) ? "true" : "false"); ASSERT_LOG(is_le_privacy_enabled, Loading @@ -1100,8 +1097,7 @@ void bluetooth::shim::legacy::Acl::ConfigureLePrivacy( maximum_rotation_time); } void bluetooth::shim::legacy::Acl::DisconnectClassic(uint16_t handle, tHCI_STATUS reason) { void shim::legacy::Acl::DisconnectClassic(uint16_t handle, tHCI_STATUS reason) { auto connection = pimpl_->handle_to_classic_connection_map_.find(handle); if (connection != pimpl_->handle_to_classic_connection_map_.end()) { auto remote_address = connection->second->GetRemoteAddress(); Loading @@ -1117,8 +1113,7 @@ void bluetooth::shim::legacy::Acl::DisconnectClassic(uint16_t handle, } } void bluetooth::shim::legacy::Acl::DisconnectLe(uint16_t handle, tHCI_STATUS reason) { void shim::legacy::Acl::DisconnectLe(uint16_t handle, tHCI_STATUS reason) { auto connection = pimpl_->handle_to_le_connection_map_.find(handle); if (connection != pimpl_->handle_to_le_connection_map_.end()) { auto remote_address_with_type = Loading @@ -1135,49 +1130,47 @@ void bluetooth::shim::legacy::Acl::DisconnectLe(uint16_t handle, handle); } } bool bluetooth::shim::legacy::Acl::HoldMode(uint16_t hci_handle, uint16_t max_interval, bool shim::legacy::Acl::HoldMode(uint16_t hci_handle, uint16_t max_interval, uint16_t min_interval) { handler_->CallOn(pimpl_.get(), &Acl::impl::HoldMode, hci_handle, max_interval, min_interval); return false; // TODO void } bool bluetooth::shim::legacy::Acl::SniffMode(uint16_t hci_handle, uint16_t max_interval, uint16_t min_interval, uint16_t attempt, bool shim::legacy::Acl::SniffMode(uint16_t hci_handle, uint16_t max_interval, uint16_t min_interval, uint16_t attempt, uint16_t timeout) { handler_->CallOn(pimpl_.get(), &Acl::impl::SniffMode, hci_handle, max_interval, min_interval, attempt, timeout); return false; } bool bluetooth::shim::legacy::Acl::ExitSniffMode(uint16_t hci_handle) { bool shim::legacy::Acl::ExitSniffMode(uint16_t hci_handle) { handler_->CallOn(pimpl_.get(), &Acl::impl::ExitSniffMode, hci_handle); return false; } bool bluetooth::shim::legacy::Acl::SniffSubrating( uint16_t hci_handle, uint16_t maximum_latency, uint16_t minimum_remote_timeout, uint16_t minimum_local_timeout) { bool shim::legacy::Acl::SniffSubrating(uint16_t hci_handle, uint16_t maximum_latency, uint16_t minimum_remote_timeout, uint16_t minimum_local_timeout) { handler_->CallOn(pimpl_.get(), &Acl::impl::SniffSubrating, hci_handle, maximum_latency, minimum_remote_timeout, minimum_local_timeout); return false; } void bluetooth::shim::legacy::Acl::HACK_OnScoDisconnected(uint16_t handle, void shim::legacy::Acl::HACK_OnScoDisconnected(uint16_t handle, uint8_t reason) { TRY_POSTING_ON_MAIN(acl_interface_.connection.sco.on_disconnected, handle, static_cast<tHCI_REASON>(reason)); } void bluetooth::shim::legacy::Acl::DumpConnectionHistory(int fd) const { void shim::legacy::Acl::DumpConnectionHistory(int fd) const { pimpl_->DumpConnectionHistory(fd); } void bluetooth::shim::legacy::Acl::Shutdown() { void shim::legacy::Acl::Shutdown() { if (CheckForOrphanedAclConnections()) { std::promise<void> shutdown_promise; auto shutdown_future = shutdown_promise.get_future(); Loading