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

Commit 30c7eda3 authored by Chris Manton's avatar Chris Manton
Browse files

gd: Pull out READ_REMOTE_VERSION shared between classic and le

Test: atest --host bluetooth_test_gd
Test: acts.py BleCocTest ## With gd_hci=false
Test: acts.py BleCocTest ## With gd_acl=true
Bug: 171634583
Tag: #refactor

Change-Id: I53a49fec950755c13e4786be9aae936c0c2b242a
parent c6c2b25e
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ constexpr EventCode AclConnectionEvents[] = {
    EventCode::FLUSH_OCCURRED,
    EventCode::READ_REMOTE_SUPPORTED_FEATURES_COMPLETE,
    EventCode::READ_REMOTE_EXTENDED_FEATURES_COMPLETE,
    EventCode::READ_REMOTE_VERSION_INFORMATION_COMPLETE,
    EventCode::LINK_SUPERVISION_TIMEOUT_CHANGED,
};

+10 −18
Original line number Diff line number Diff line
@@ -46,9 +46,10 @@ struct classic_impl : public DisconnectorForLe, public security::ISecurityManage
    controller_ = controller;
    handler_ = handler;
    should_accept_connection_ = common::Bind([](Address, ClassOfDevice) { return true; });
    acl_connection_interface_ =
        hci_layer_->GetAclConnectionInterface(handler_->BindOn(this, &classic_impl::on_classic_event),
                                              handler_->BindOn(this, &classic_impl::on_classic_disconnect));
    acl_connection_interface_ = hci_layer_->GetAclConnectionInterface(
        handler_->BindOn(this, &classic_impl::on_classic_event),
        handler_->BindOn(this, &classic_impl::on_classic_disconnect),
        handler_->BindOn(this, &classic_impl::on_read_remote_version_information));
  }

  ~classic_impl() override {
@@ -98,9 +99,6 @@ struct classic_impl : public DisconnectorForLe, public security::ISecurityManage
      case EventCode::READ_REMOTE_EXTENDED_FEATURES_COMPLETE:
        on_read_remote_extended_features_complete(event_packet);
        break;
      case EventCode::READ_REMOTE_VERSION_INFORMATION_COMPLETE:
        on_read_remote_version_information_complete(event_packet);
        break;
      case EventCode::LINK_SUPERVISION_TIMEOUT_CHANGED:
        on_link_supervision_timeout_changed(event_packet);
        break;
@@ -448,19 +446,13 @@ struct classic_impl : public DisconnectorForLe, public security::ISecurityManage
    acl_connection.connection_management_callbacks_->OnFlushOccurred();
  }

  void on_read_remote_version_information_complete(EventPacketView packet) {
    auto view = ReadRemoteVersionInformationCompleteView::Create(packet);
    ASSERT_LOG(view.IsValid(), "Read remote version information packet invalid");
    if (view.GetStatus() != ErrorCode::SUCCESS) {
      auto status = view.GetStatus();
      std::string error_code = ErrorCodeText(status);
      LOG_ERROR("Received on_read_remote_version_information_complete with error code %s", error_code.c_str());
      return;
  void on_read_remote_version_information(
      uint16_t handle, uint8_t version, uint16_t manufacturer_name, uint16_t sub_version) {
    auto acl_connection = acl_connections_.find(handle);
    if (acl_connection != acl_connections_.end()) {
      acl_connection->second.connection_management_callbacks_->OnReadRemoteVersionInformationComplete(
          version, manufacturer_name, sub_version);
    }
    uint16_t handle = view.GetConnectionHandle();
    auto& acl_connection = acl_connections_.find(handle)->second;
    acl_connection.connection_management_callbacks_->OnReadRemoteVersionInformationComplete(
        view.GetVersion(), view.GetManufacturerName(), view.GetSubVersion());
  }

  void on_read_remote_supported_features_complete(EventPacketView packet) {
+4 −0
Original line number Diff line number Diff line
@@ -56,6 +56,10 @@ class LeAclConnectionTracker : public LeConnectionManagementCallbacks {
    SAVE_OR_CALL(OnDataLengthChange, tx_octets, tx_time, rx_octets, rx_time)
  }

  void OnReadRemoteVersionInformationComplete(uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) {
    SAVE_OR_CALL(OnReadRemoteVersionInformationComplete, lmp_version, manufacturer_name, sub_version);
  }

  void OnDisconnection(ErrorCode reason) override {
    SAVE_OR_CALL(OnDisconnection, reason);
  }
+2 −0
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ class LeConnectionManagementCallbacks {
                                  uint16_t supervision_timeout) = 0;
  virtual void OnDataLengthChange(uint16_t tx_octets, uint16_t tx_time, uint16_t rx_octets, uint16_t rx_time) = 0;
  virtual void OnDisconnection(ErrorCode reason) = 0;
  virtual void OnReadRemoteVersionInformationComplete(
      uint8_t lmp_version, uint16_t manufacturer_name, uint16_t sub_version) = 0;
};

}  // namespace acl_manager
+12 −1
Original line number Diff line number Diff line
@@ -52,7 +52,9 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
    controller_ = controller;
    handler_ = handler;
    le_acl_connection_interface_ = hci_layer_->GetLeAclConnectionInterface(
        handler_->BindOn(this, &le_impl::on_le_event), handler_->BindOn(this, &le_impl::on_le_disconnect));
        handler_->BindOn(this, &le_impl::on_le_event),
        handler_->BindOn(this, &le_impl::on_le_disconnect),
        handler_->BindOn(this, &le_impl::on_le_read_remote_version_information));
    le_address_manager_ = new LeAddressManager(
        common::Bind(&le_impl::enqueue_command, common::Unretained(this)),
        handler_,
@@ -253,6 +255,15 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
        complete_view.GetConnInterval(), complete_view.GetConnLatency(), complete_view.GetSupervisionTimeout());
  }

  void on_le_read_remote_version_information(
      uint16_t handle, uint8_t version, uint16_t manufacturer_name, uint16_t sub_version) {
    auto connection = le_acl_connections_.find(handle);
    if (connection != le_acl_connections_.end()) {
      connection->second.le_connection_management_callbacks_->OnReadRemoteVersionInformationComplete(
          version, manufacturer_name, sub_version);
    }
  }

  void enqueue_command(std::unique_ptr<CommandPacketBuilder> command_packet) {
    hci_layer_->EnqueueCommand(
        std::move(command_packet),
Loading