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

Commit 91822f45 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Implement a shim hack to get the ACL handle"

parents 60fdd639 4f30ac50
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -187,6 +187,14 @@ LeAddressManager* AclManager::GetLeAddressManager() {
  return pimpl_->le_impl_->le_address_manager_;
}

uint16_t AclManager::HACK_GetHandle(Address address) {
  return pimpl_->classic_impl_->HACK_get_handle(address);
}

uint16_t AclManager::HACK_GetLeHandle(Address address) {
  return pimpl_->le_impl_->HACK_get_handle(address);
}

void AclManager::ListDependencies(ModuleList* list) {
  list->add<HciLayer>();
  list->add<Controller>();
+7 −0
Original line number Diff line number Diff line
@@ -35,10 +35,14 @@ namespace bluetooth {
namespace security {
class SecurityModule;
}
namespace shim {
class Btm;
}

namespace hci {

class AclManager : public Module {
 friend class bluetooth::shim::Btm;
 public:
  AclManager();
  // NOTE: It is necessary to forward declare a default destructor that overrides the base class one, because
@@ -95,6 +99,9 @@ class AclManager : public Module {
  std::string ToString() const override;

 private:
  virtual uint16_t HACK_GetHandle(const Address address);
  virtual uint16_t HACK_GetLeHandle(const Address address);

  struct impl;
  std::unique_ptr<impl> pimpl_;

+9 −0
Original line number Diff line number Diff line
@@ -520,6 +520,15 @@ struct classic_impl : public DisconnectorForLe, public security::ISecurityManage
    security_manager_->RegisterCallbackListener(this, handler_);
  }

  uint16_t HACK_get_handle(Address address) {
    for (auto it = acl_connections_.begin(); it != acl_connections_.end(); it++) {
      if (it->second.address_with_type_.GetAddress() == address) {
        return it->first;
      }
    }
    return 0xFFFF;
  }

  HciLayer* hci_layer_ = nullptr;
  Controller* controller_ = nullptr;
  RoundRobinScheduler* round_robin_scheduler_ = nullptr;
+13 −3
Original line number Diff line number Diff line
@@ -34,11 +34,12 @@ namespace acl_manager {
using common::BindOnce;

struct le_acl_connection {
  le_acl_connection(AddressWithType address_with_type, AclConnection::QueueDownEnd* queue_down_end,
                    os::Handler* handler)
      : assembler_(address_with_type, queue_down_end, handler) {}
  le_acl_connection(
      AddressWithType address_with_type, AclConnection::QueueDownEnd* queue_down_end, os::Handler* handler)
      : assembler_(address_with_type, queue_down_end, handler), address_with_type_(address_with_type) {}
  ~le_acl_connection() = default;
  struct acl_manager::assembler assembler_;
  AddressWithType address_with_type_;
  LeConnectionManagementCallbacks* le_connection_management_callbacks_ = nullptr;
};

@@ -393,6 +394,15 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
    le_address_manager_->AckResume(this);
  }

  uint16_t HACK_get_handle(Address address) {
    for (auto it = le_acl_connections_.begin(); it != le_acl_connections_.end(); it++) {
      if (it->second.address_with_type_.GetAddress() == address) {
        return it->first;
      }
    }
    return 0xFFFF;
  }

  static constexpr uint16_t kMinimumCeLength = 0x0002;
  static constexpr uint16_t kMaximumCeLength = 0x0C00;
  HciLayer* hci_layer_ = nullptr;
+10 −0
Original line number Diff line number Diff line
@@ -818,3 +818,13 @@ bool bluetooth::shim::Btm::RemoveBond(const RawAddress& bd_addr) {
  security_manager->RemoveBond(ToAddressWithType(bd_addr, BLE_ADDR_PUBLIC));
  return true;
}

uint16_t bluetooth::shim::Btm::GetAclHandle(const RawAddress& remote_bda,
                                            tBT_TRANSPORT transport) {
  auto acl_manager = bluetooth::shim::GetAclManager();
  if (transport == BT_TRANSPORT_BR_EDR) {
    return acl_manager->HACK_GetHandle(ToGdAddress(remote_bda));
  } else {
    return acl_manager->HACK_GetLeHandle(ToGdAddress(remote_bda));
  }
}
Loading