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

Commit ffc850a2 authored by David Duarte's avatar David Duarte
Browse files

RootCanal: Disconnect peers on close

Bug: 209799507
Test: m root-canal
Change-Id: I0f7ae5717b08c147c9c17f37b026e72f3aab78ad
parent 438f4877
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -514,4 +514,13 @@ ScoLinkParameters AclConnectionHandler::GetScoLinkParameters(bluetooth::hci::Add
  return {};
}

std::vector<uint16_t> AclConnectionHandler::GetAclHandles() const {
  std::vector<uint16_t> keys;

  for (const auto& pair : acl_connections_) {
    keys.push_back(pair.first);
  }
  return keys;
}

}  // namespace test_vendor_lib
+2 −0
Original line number Diff line number Diff line
@@ -118,6 +118,8 @@ class AclConnectionHandler {
  StreamParameters GetStreamParameters(uint16_t handle) const;
  GroupParameters GetGroupParameters(uint8_t id) const;

  std::vector<uint16_t> GetAclHandles() const;

 private:
  std::unordered_map<uint16_t, AclConnection> acl_connections_;
  std::unordered_map<uint16_t, ScoConnection> sco_connections_;
+5 −0
Original line number Diff line number Diff line
@@ -61,6 +61,11 @@ void DualModeController::TimerTick() {
  link_layer_controller_.TimerTick();
}

void DualModeController::Close() {
  link_layer_controller_.Close();
  Device::Close();
}

void DualModeController::SendCommandCompleteUnknownOpCodeEvent(uint16_t command_opcode) const {
  std::unique_ptr<bluetooth::packet::RawBuilder> raw_builder_ptr =
      std::make_unique<bluetooth::packet::RawBuilder>();
+2 −0
Original line number Diff line number Diff line
@@ -69,6 +69,8 @@ class DualModeController : public Device {

  virtual void TimerTick() override;

  virtual void Close() override;

  // Route commands and data from the stack.
  void HandleAcl(std::shared_ptr<std::vector<uint8_t>> acl_packet);
  void HandleCommand(std::shared_ptr<std::vector<uint8_t>> command_packet);
+7 −1
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ namespace test_vendor_lib {

constexpr uint16_t kNumCommandPackets = 0x01;

constexpr milliseconds kNoDelayMs(1);
constexpr milliseconds kNoDelayMs(0);
constexpr milliseconds kShortDelayMs(5);
constexpr milliseconds kLongDelayMs(200);

@@ -2049,6 +2049,12 @@ void LinkLayerController::TimerTick() {
  LeAdvertising();
}

void LinkLayerController::Close() {
  for (auto handle : connections_.GetAclHandles()) {
    Disconnect(handle, static_cast<uint8_t>(ErrorCode::CONNECTION_TIMEOUT));
  }
}

void LinkLayerController::LeAdvertising() {
  steady_clock::time_point now = steady_clock::now();
  for (auto& advertiser : advertisers_) {
Loading