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

Commit 5a5a1e2e authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Execute channel fail callbacks when link not up"

parents 33c02b15 ded0c10e
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -90,8 +90,10 @@ void LinkManager::ConnectDynamicChannelServices(hci::Address device,
    acl_manager_->CreateConnection(device);
    if (pending_dynamic_channels_.find(device) != pending_dynamic_channels_.end()) {
      pending_dynamic_channels_[device].push_back(psm);
      pending_dynamic_channels_callbacks_[device].push_back(std::move(pending_dynamic_channel_connection));
    } else {
      pending_dynamic_channels_[device] = {psm};
      pending_dynamic_channels_callbacks_[device].push_back(std::move(pending_dynamic_channel_connection));
    }
    return;
  }
@@ -130,6 +132,7 @@ void LinkManager::OnConnectSuccess(std::unique_ptr<hci::AclConnection> acl_conne
      link->SendConnectionRequest(psm, link->ReserveDynamicChannel());
    }
    pending_dynamic_channels_.erase(device);
    pending_dynamic_channels_callbacks_.erase(device);
  }
  // Remove device from pending links list, if any
  auto pending_link = pending_links_.find(device);
@@ -147,6 +150,16 @@ void LinkManager::OnConnectFail(hci::Address device, hci::ErrorCode reason) {
  if (pending_link == pending_links_.end()) {
    // There is no pending link, exit
    LOG_DEBUG("Connection to %s failed without a pending link", device.ToString().c_str());
    if (pending_dynamic_channels_callbacks_.find(device) != pending_dynamic_channels_callbacks_.end()) {
      for (PendingDynamicChannelConnection& callbacks : pending_dynamic_channels_callbacks_[device]) {
        callbacks.handler_->Post(common::BindOnce(std::move(callbacks.on_fail_callback_),
                                                  DynamicChannelManager::ConnectionResult{
                                                      .hci_error = hci::ErrorCode::CONNECTION_TIMEOUT,
                                                  }));
      }
      pending_dynamic_channels_.erase(device);
      pending_dynamic_channels_callbacks_.erase(device);
    }
    return;
  }
  for (auto& pending_fixed_channel_connection : pending_link->second.pending_fixed_channel_connections_) {
+1 −0
Original line number Diff line number Diff line
@@ -90,6 +90,7 @@ class LinkManager : public hci::ConnectionCallbacks {
  std::unordered_map<hci::Address, PendingLink> pending_links_;
  std::unordered_map<hci::Address, Link> links_;
  std::unordered_map<hci::Address, std::list<Psm>> pending_dynamic_channels_;
  std::unordered_map<hci::Address, std::list<PendingDynamicChannelConnection>> pending_dynamic_channels_callbacks_;
  DISALLOW_COPY_AND_ASSIGN(LinkManager);
};