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

Commit 6298315f authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Expose Role through AclConnection, Link, and le::FixedChannel

Role is needed in SMP to properly bootstrap the pairing process

Bug: 142341141
Change-Id: If0815c7bc9d07180950e66dbaafd69220e933340
parent 350b8fa9
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -291,8 +291,9 @@ struct AclManager::impl {
    if (acl_connections_.size() == 1 && packet_to_send_ == nullptr) {
      start_round_robin();
    }
    auto role = connection_complete.GetRole();
    std::unique_ptr<AclConnection> connection_proxy(
        new AclConnection(&acl_manager_, handle, address, peer_address_type));
        new AclConnection(&acl_manager_, handle, address, peer_address_type, role));
    le_client_handler_->Post(common::BindOnce(&LeConnectionCallbacks::OnLeConnectSuccess,
                                              common::Unretained(le_client_callbacks_), address_with_type,
                                              std::move(connection_proxy)));
@@ -323,8 +324,9 @@ struct AclManager::impl {
    if (acl_connections_.size() == 1 && packet_to_send_ == nullptr) {
      start_round_robin();
    }
    auto role = connection_complete.GetRole();
    std::unique_ptr<AclConnection> connection_proxy(
        new AclConnection(&acl_manager_, handle, address, peer_address_type));
        new AclConnection(&acl_manager_, handle, address, peer_address_type, role));
    le_client_handler_->Post(common::BindOnce(&LeConnectionCallbacks::OnLeConnectSuccess,
                                              common::Unretained(le_client_callbacks_), reporting_address_with_type,
                                              std::move(connection_proxy)));
+10 −2
Original line number Diff line number Diff line
@@ -99,6 +99,13 @@ class AclConnection {
    return handle_;
  }

  /* This return role for LE devices only, for Classic, please see |RoleDiscovery| method.
   * TODO: split AclConnection for LE and Classic
   */
  Role GetRole() const {
    return role_;
  }

  using Queue = common::BidiQueue<PacketView<kLittleEndian>, BasePacketBuilder>;
  using QueueUpEnd = common::BidiQueueEnd<BasePacketBuilder, PacketView<kLittleEndian>>;
  using QueueDownEnd = common::BidiQueueEnd<PacketView<kLittleEndian>, BasePacketBuilder>;
@@ -145,12 +152,13 @@ class AclConnection {
  friend AclManager;
  AclConnection(AclManager* manager, uint16_t handle, Address address)
      : manager_(manager), handle_(handle), address_(address) {}
  AclConnection(AclManager* manager, uint16_t handle, Address address, AddressType address_type)
      : manager_(manager), handle_(handle), address_(address), address_type_(address_type) {}
  AclConnection(AclManager* manager, uint16_t handle, Address address, AddressType address_type, Role role)
      : manager_(manager), handle_(handle), address_(address), address_type_(address_type), role_(role) {}
  AclManager* manager_;
  uint16_t handle_;
  Address address_;
  AddressType address_type_;
  Role role_;
  DISALLOW_COPY_AND_ASSIGN(AclConnection);
};

+4 −0
Original line number Diff line number Diff line
@@ -26,6 +26,10 @@ hci::AddressWithType FixedChannel::GetDevice() const {
  return impl_->GetDevice();
}

hci::Role FixedChannel::GetRole() const {
  return impl_->GetRole();
}

void FixedChannel::RegisterOnCloseCallback(os::Handler* user_handler, FixedChannel::OnCloseCallback on_close_callback) {
  l2cap_handler_->Post(common::BindOnce(&internal::FixedChannelImpl::RegisterOnCloseCallback, impl_, user_handler,
                                        std::move(on_close_callback)));
+5 −0
Original line number Diff line number Diff line
@@ -48,6 +48,11 @@ class FixedChannel {

  hci::AddressWithType GetDevice() const;

  /**
   * Return the role we have in the associated link
   */
  hci::Role GetRole() const;

  /**
   * Register close callback. If close callback is registered, when a channel is closed, the channel's resource will
   * only be freed after on_close callback is invoked. Otherwise, if no on_close callback is registered, the channel's
+4 −0
Original line number Diff line number Diff line
@@ -28,6 +28,10 @@ namespace l2cap {
namespace le {
namespace internal {

hci::Role FixedChannelImpl::GetRole() const {
  return link_->GetRole();
}

FixedChannelImpl::FixedChannelImpl(Cid cid, Link* link, os::Handler* l2cap_handler)
    : cid_(cid), device_(link->GetDevice()), link_(link), l2cap_handler_(l2cap_handler) {
  ASSERT_LOG(cid_ >= kFirstFixedChannel && cid_ <= kLastFixedChannel, "Invalid cid: %d", cid_);
Loading