Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aa93b0df authored by Chris Manton's avatar Chris Manton
Browse files

Add Put[Le]AclConnectionInterface

Bug: 206060201
Tag: #refactor
Test: gd/cert/run
BYPASS_LONG_LINES_REASON: Bluetooth likes 120 lines

Change-Id: I5179f2e55277e39a97fc771c5e84e7e380791928
parent 1ff96518
Loading
Loading
Loading
Loading
+1 −3
Original line number Original line Diff line number Diff line
@@ -59,9 +59,7 @@ struct classic_impl : public security::ISecurityManagerListener {
  }
  }


  ~classic_impl() {
  ~classic_impl() {
    for (auto event_code : AclConnectionEvents) {
    hci_layer_->PutAclConnectionInterface();
      hci_layer_->UnregisterEventHandler(event_code);
    }
    acl_connections_.clear();
    acl_connections_.clear();
    security_manager_.reset();
    security_manager_.reset();
  }
  }
+1 −3
Original line number Original line Diff line number Diff line
@@ -79,13 +79,11 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
  }
  }


  ~le_impl() {
  ~le_impl() {
    for (auto subevent_code : LeConnectionManagementEvents) {
      hci_layer_->UnregisterLeEventHandler(subevent_code);
    }
    if (address_manager_registered) {
    if (address_manager_registered) {
      le_address_manager_->Unregister(this);
      le_address_manager_->Unregister(this);
    }
    }
    delete le_address_manager_;
    delete le_address_manager_;
    hci_layer_->PutLeAclConnectionInterface();
    le_acl_connections_.clear();
    le_acl_connections_.clear();
  }
  }


+2 −0
Original line number Original line Diff line number Diff line
@@ -112,12 +112,14 @@ class FuzzHciLayer : public HciLayer {
      common::ContextualCallback<void(uint16_t, hci::ErrorCode)> on_disconnect,
      common::ContextualCallback<void(uint16_t, hci::ErrorCode)> on_disconnect,
      common::ContextualCallback<void(hci::ErrorCode hci_status, uint16_t, uint8_t, uint16_t, uint16_t)>
      common::ContextualCallback<void(hci::ErrorCode hci_status, uint16_t, uint8_t, uint16_t, uint16_t)>
          on_read_remote_version) override;
          on_read_remote_version) override;
  void PutAclConnectionInterface() override {}


  hci::LeAclConnectionInterface* GetLeAclConnectionInterface(
  hci::LeAclConnectionInterface* GetLeAclConnectionInterface(
      common::ContextualCallback<void(hci::LeMetaEventView)> event_handler,
      common::ContextualCallback<void(hci::LeMetaEventView)> event_handler,
      common::ContextualCallback<void(uint16_t, hci::ErrorCode)> on_disconnect,
      common::ContextualCallback<void(uint16_t, hci::ErrorCode)> on_disconnect,
      common::ContextualCallback<void(hci::ErrorCode hci_status, uint16_t, uint8_t, uint16_t, uint16_t)>
      common::ContextualCallback<void(hci::ErrorCode hci_status, uint16_t, uint8_t, uint16_t, uint16_t)>
          on_read_remote_version) override;
          on_read_remote_version) override;
  void PutLeAclConnectionInterface() override {}


  hci::LeAdvertisingInterface* GetLeAdvertisingInterface(
  hci::LeAdvertisingInterface* GetLeAdvertisingInterface(
      common::ContextualCallback<void(hci::LeMetaEventView)> event_handler) override;
      common::ContextualCallback<void(hci::LeMetaEventView)> event_handler) override;
+20 −4
Original line number Original line Diff line number Diff line
@@ -511,28 +511,44 @@ AclConnectionInterface* HciLayer::GetAclConnectionInterface(
    ContextualCallback<
    ContextualCallback<
        void(hci::ErrorCode hci_status, uint16_t, uint8_t version, uint16_t manufacturer_name, uint16_t sub_version)>
        void(hci::ErrorCode hci_status, uint16_t, uint8_t version, uint16_t manufacturer_name, uint16_t sub_version)>
        on_read_remote_version) {
        on_read_remote_version) {
  disconnect_handlers_.push_back(on_disconnect);
  read_remote_version_handlers_.push_back(on_read_remote_version);
  for (const auto event : AclConnectionEvents) {
  for (const auto event : AclConnectionEvents) {
    RegisterEventHandler(event, event_handler);
    RegisterEventHandler(event, event_handler);
  }
  }
  disconnect_handlers_.push_back(on_disconnect);
  read_remote_version_handlers_.push_back(on_read_remote_version);
  return &acl_connection_manager_interface_;
  return &acl_connection_manager_interface_;
}
}


void HciLayer::PutAclConnectionInterface() {
  for (const auto event : AclConnectionEvents) {
    UnregisterEventHandler(event);
  }
  disconnect_handlers_.clear();
  read_remote_version_handlers_.clear();
}

LeAclConnectionInterface* HciLayer::GetLeAclConnectionInterface(
LeAclConnectionInterface* HciLayer::GetLeAclConnectionInterface(
    ContextualCallback<void(LeMetaEventView)> event_handler,
    ContextualCallback<void(LeMetaEventView)> event_handler,
    ContextualCallback<void(uint16_t, ErrorCode)> on_disconnect,
    ContextualCallback<void(uint16_t, ErrorCode)> on_disconnect,
    ContextualCallback<
    ContextualCallback<
        void(hci::ErrorCode hci_status, uint16_t, uint8_t version, uint16_t manufacturer_name, uint16_t sub_version)>
        void(hci::ErrorCode hci_status, uint16_t, uint8_t version, uint16_t manufacturer_name, uint16_t sub_version)>
        on_read_remote_version) {
        on_read_remote_version) {
  disconnect_handlers_.push_back(on_disconnect);
  read_remote_version_handlers_.push_back(on_read_remote_version);
  for (const auto event : LeConnectionManagementEvents) {
  for (const auto event : LeConnectionManagementEvents) {
    RegisterLeEventHandler(event, event_handler);
    RegisterLeEventHandler(event, event_handler);
  }
  }
  disconnect_handlers_.push_back(on_disconnect);
  read_remote_version_handlers_.push_back(on_read_remote_version);
  return &le_acl_connection_manager_interface_;
  return &le_acl_connection_manager_interface_;
}
}


void HciLayer::PutLeAclConnectionInterface() {
  for (const auto event : LeConnectionManagementEvents) {
    UnregisterLeEventHandler(event);
  }
  disconnect_handlers_.clear();
  read_remote_version_handlers_.clear();
}

SecurityInterface* HciLayer::GetSecurityInterface(ContextualCallback<void(EventView)> event_handler) {
SecurityInterface* HciLayer::GetSecurityInterface(ContextualCallback<void(EventView)> event_handler) {
  for (const auto event : SecurityEvents) {
  for (const auto event : SecurityEvents) {
    RegisterEventHandler(event, event_handler);
    RegisterEventHandler(event, event_handler);
+2 −0
Original line number Original line Diff line number Diff line
@@ -78,12 +78,14 @@ class HciLayer : public Module, public CommandInterface<CommandBuilder> {
      common::ContextualCallback<void(uint16_t, hci::ErrorCode)> on_disconnect,
      common::ContextualCallback<void(uint16_t, hci::ErrorCode)> on_disconnect,
      common::ContextualCallback<void(hci::ErrorCode, uint16_t, uint8_t, uint16_t, uint16_t)>
      common::ContextualCallback<void(hci::ErrorCode, uint16_t, uint8_t, uint16_t, uint16_t)>
          on_read_remote_version_complete);
          on_read_remote_version_complete);
  virtual void PutAclConnectionInterface();


  virtual LeAclConnectionInterface* GetLeAclConnectionInterface(
  virtual LeAclConnectionInterface* GetLeAclConnectionInterface(
      common::ContextualCallback<void(LeMetaEventView)> event_handler,
      common::ContextualCallback<void(LeMetaEventView)> event_handler,
      common::ContextualCallback<void(uint16_t, hci::ErrorCode)> on_disconnect,
      common::ContextualCallback<void(uint16_t, hci::ErrorCode)> on_disconnect,
      common::ContextualCallback<void(hci::ErrorCode, uint16_t, uint8_t, uint16_t, uint16_t)>
      common::ContextualCallback<void(hci::ErrorCode, uint16_t, uint8_t, uint16_t, uint16_t)>
          on_read_remote_version_complete);
          on_read_remote_version_complete);
  virtual void PutLeAclConnectionInterface();


  virtual LeAdvertisingInterface* GetLeAdvertisingInterface(
  virtual LeAdvertisingInterface* GetLeAdvertisingInterface(
      common::ContextualCallback<void(LeMetaEventView)> event_handler);
      common::ContextualCallback<void(LeMetaEventView)> event_handler);