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

Commit fbd5acd2 authored by Rahul Arya's avatar Rahul Arya Committed by Henri Chataing
Browse files

[Rootcanal] Add PAGE_TIMEOUT for classic connections on Rootcanal

Default to 0x2000 as per spec but let host change this if needed. Needed
for PTS tests.

Test: pts-bot
Bug: 248626893
Bug: 245578454
Ignore-AOSP-First: cherry-pick from AOSP
Merged-In: I5433635d67ac3d8c1890094c26bca87d50b46d52
Change-Id: I5433635d67ac3d8c1890094c26bca87d50b46d52
(cherry picked from commit 09d9aee8)
parent 5c94609c
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1494,7 +1494,7 @@ void DualModeController::ReadPageTimeout(CommandView command) {
  auto command_view = gd_hci::ReadPageTimeoutView::Create(
      gd_hci::DiscoveryCommandView::Create(command));
  ASSERT(command_view.IsValid());
  uint16_t page_timeout = 0x2000;
  uint16_t page_timeout = link_layer_controller_.GetPageTimeout();
  send_event_(bluetooth::hci::ReadPageTimeoutCompleteBuilder::Create(
      kNumCommandPackets, ErrorCode::SUCCESS, page_timeout));
}
@@ -1503,6 +1503,7 @@ void DualModeController::WritePageTimeout(CommandView command) {
  auto command_view = gd_hci::WritePageTimeoutView::Create(
      gd_hci::DiscoveryCommandView::Create(command));
  ASSERT(command_view.IsValid());
  link_layer_controller_.SetPageTimeout(command_view.GetPageTimeout());
  send_event_(bluetooth::hci::WritePageTimeoutCompleteBuilder::Create(
      kNumCommandPackets, ErrorCode::SUCCESS));
}
+16 −0
Original line number Diff line number Diff line
@@ -2681,6 +2681,7 @@ void LinkLayerController::IncomingPageResponsePacket(
    LOG_WARN("No free handles");
    return;
  }
  CancelScheduledTask(page_timeout_task_id_);
#ifdef ROOTCANAL_LMP
  ASSERT(link_manager_add_link(
      lm_.get(), reinterpret_cast<const uint8_t(*)[6]>(peer.data())));
@@ -3366,6 +3367,14 @@ ErrorCode LinkLayerController::CreateConnection(const Address& addr, uint16_t,
    return ErrorCode::CONTROLLER_BUSY;
  }

  page_timeout_task_id_ = ScheduleTask(
      duration_cast<milliseconds>(page_timeout_ * microseconds(625)),
      [this, addr] {
        send_event_(bluetooth::hci::ConnectionCompleteBuilder::Create(
            ErrorCode::PAGE_TIMEOUT, 0xeff, addr, bluetooth::hci::LinkType::ACL,
            bluetooth::hci::Enable::DISABLED));
      });

  SendLinkLayerPacket(model::packets::PageBuilder::Create(
      GetAddress(), addr, class_of_device_, allow_role_switch));

@@ -3376,6 +3385,7 @@ ErrorCode LinkLayerController::CreateConnectionCancel(const Address& addr) {
  if (!connections_.CancelPendingConnection(addr)) {
    return ErrorCode::UNKNOWN_CONNECTION;
  }
  CancelScheduledTask(page_timeout_task_id_);
  return ErrorCode::SUCCESS;
}

@@ -4252,6 +4262,12 @@ void LinkLayerController::SetPageScanEnable(bool enable) {
  page_scan_enable_ = enable;
}

uint16_t LinkLayerController::GetPageTimeout() { return page_timeout_; }

void LinkLayerController::SetPageTimeout(uint16_t page_timeout) {
  page_timeout_ = page_timeout;
}

ErrorCode LinkLayerController::AddScoConnection(uint16_t connection_handle,
                                                uint16_t packet_type) {
  if (!connections_.HasHandle(connection_handle)) {
+4 −0
Original line number Diff line number Diff line
@@ -351,6 +351,8 @@ class LinkLayerController {

  void SetInquiryScanEnable(bool enable);
  void SetPageScanEnable(bool enable);
  uint16_t GetPageTimeout();
  void SetPageTimeout(uint16_t page_timeout);

  ErrorCode ChangeConnectionPacketType(uint16_t handle, uint16_t types);
  ErrorCode ChangeConnectionLinkKey(uint16_t handle);
@@ -841,6 +843,8 @@ class LinkLayerController {
  SecurityManager security_manager_{10};
#endif /* ROOTCANAL_LMP */

  AsyncTaskId page_timeout_task_id_ = kInvalidTaskId;

  std::chrono::steady_clock::time_point last_inquiry_;
  model::packets::InquiryType inquiry_mode_{
      model::packets::InquiryType::STANDARD};