OSDN Git Service

Reduce unneeded namespace resolution main/shim/acl
authorChris Manton <cmanton@google.com>
Thu, 11 Feb 2021 06:02:34 +0000 (22:02 -0800)
committerChris Manton <cmanton@google.com>
Tue, 16 Feb 2021 16:27:18 +0000 (08:27 -0800)
Bug: 173985410
Tag: #refactor
Test: gd/cert/run

Change-Id: Ic0587e34be24597c4ed318459817ad68aced8ebc

main/shim/acl.cc

index 00b1761..87bac42 100644 (file)
@@ -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());
@@ -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,
@@ -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()) {
@@ -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_;
@@ -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>>
@@ -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));
@@ -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));
   }
@@ -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];
@@ -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"
@@ -802,15 +801,15 @@ 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,
-                                  const acl_interface_t& acl_interface)
+shim::legacy::Acl::Acl(os::Handler* handler,
+                       const acl_interface_t& acl_interface)
     : handler_(handler), acl_interface_(acl_interface) {
   ValidateAclInterface(acl_interface_);
   pimpl_ = std::make_unique<Acl::impl>();
@@ -818,8 +817,8 @@ 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),
-                                           [this](int fd) { Dump(fd); });
+  shim::RegisterDumpsysFunction(static_cast<void*>(this),
+                                [this](int fd) { Dump(fd); });
   Stack::GetInstance()->GetBtm()->Register_HACK_SetScoDisconnectCallback(
       [this](uint16_t handle, uint8_t reason) {
         TRY_POSTING_ON_MAIN(acl_interface_.connection.sco.on_disconnected,
@@ -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()) {
@@ -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()) {
@@ -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());
@@ -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());
@@ -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,
-                                                           uint16_t credits) {
+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)) {
@@ -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));
@@ -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));
@@ -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));
@@ -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();
@@ -946,8 +944,8 @@ void bluetooth::shim::legacy::Acl::OnClassicLinkDisconnected(
           is_locally_initiated, reason)));
 }
 
-void bluetooth::shim::legacy::Acl::OnLeLinkDisconnected(HciHandle handle,
-                                                        hci::ErrorCode reason) {
+void shim::legacy::Acl::OnLeLinkDisconnected(HciHandle handle,
+                                             hci::ErrorCode reason) {
   hci::AddressWithType remote_address_with_type =
       pimpl_->handle_to_le_connection_map_[handle]->GetRemoteAddressWithType();
   CreationTime creation_time =
@@ -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();
@@ -1003,8 +1001,8 @@ void bluetooth::shim::legacy::Acl::OnConnectSuccess(
                  (locally_initiated) ? "Local initiated" : "Remote initiated");
 }
 
-void bluetooth::shim::legacy::Acl::OnConnectFail(hci::Address address,
-                                                 hci::ErrorCode reason) {
+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,
                       ToLegacyHciErrorCode(reason));
@@ -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(
@@ -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);
 
@@ -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,
@@ -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();
@@ -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 =
@@ -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,
-                                            uint16_t min_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,
-                                             uint16_t timeout) {
+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,
-                                                          uint8_t reason) {
+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();