OSDN Git Service

gd: Add local/remote acl connection initiator bit
authorChris Manton <cmanton@google.com>
Wed, 25 Nov 2020 02:38:01 +0000 (18:38 -0800)
committerChris Manton <cmanton@google.com>
Tue, 1 Dec 2020 22:19:47 +0000 (22:19 +0000)
Report the initiator of the acl connection.

Bug: 166280067
Test: gd/cert/run --host
Tag: #refactor

Change-Id: If123478fd271f9f49ff9a3d0e30be8a9a6e1abfd

gd/hci/acl_manager/acl_connection.h
gd/hci/acl_manager/classic_impl.h

index 9c2d3f3..c396b18 100644 (file)
@@ -41,6 +41,8 @@ class AclConnection {
   using QueueDownEnd = common::BidiQueueEnd<PacketView<kLittleEndian>, BasePacketBuilder>;
   virtual QueueUpEnd* GetAclQueueEnd() const;
 
+  bool locally_initiated_{false};
+
  protected:
   AclConnection(QueueUpEnd* queue_up_end, uint16_t handle) : queue_up_end_(queue_up_end), handle_(handle) {}
   QueueUpEnd* queue_up_end_;
index c5d303f..480bdd5 100644 (file)
@@ -190,9 +190,11 @@ struct classic_impl : public security::ISecurityManagerListener {
     auto status = connection_complete.GetStatus();
     auto address = connection_complete.GetBdAddr();
     Role current_role = Role::CENTRAL;
+    bool locally_initiated = true;
     if (outgoing_connecting_address_ == address) {
       outgoing_connecting_address_ = Address::kEmpty;
     } else {
+      locally_initiated = false;
       ASSERT_LOG(incoming_connecting_address_ == address, "No prior connection request for %s",
                  address.ToString().c_str());
       incoming_connecting_address_ = Address::kEmpty;
@@ -212,6 +214,7 @@ struct classic_impl : public security::ISecurityManagerListener {
     round_robin_scheduler_->Register(RoundRobinScheduler::ConnectionType::CLASSIC, handle, queue);
     std::unique_ptr<ClassicAclConnection> connection(
         new ClassicAclConnection(std::move(queue), acl_connection_interface_, handle, address));
+    connection->locally_initiated_ = locally_initiated;
     auto& connection_proxy = check_and_get_connection(handle);
     connection_proxy.connection_management_callbacks_ = connection->GetEventCallbacks();
     connection_proxy.connection_management_callbacks_->OnRoleChange(current_role);