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

Commit 1866d2c9 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "RootCanal: Update the logic in case of page collision" into main

parents f94f2b7c 1411a4d2
Loading
Loading
Loading
Loading
+19 −13
Original line number Diff line number Diff line
@@ -5044,6 +5044,20 @@ void LinkLayerController::IncomingPagePacket(
  auto page = model::packets::PageView::Create(incoming);
  ASSERT(page.IsValid());

  // [HCI] 7.3.3 Set Event Filter command
  // If the Auto_Accept_Flag is off and the Host has masked the
  // HCI_Connection_Request event, the Controller shall reject the
  // connection attempt.
  if (!IsEventUnmasked(EventCode::CONNECTION_REQUEST)) {
    INFO(id_,
         "rejecting connection request from {} because the HCI_Connection_Request"
         " event is masked by the Host", bd_addr);
    SendLinkLayerPacket(
        model::packets::PageRejectBuilder::Create(
            GetAddress(), bd_addr, static_cast<uint8_t>(ErrorCode::CONNECTION_TIMEOUT)));
    return;
  }

  // Cannot establish two BR-EDR connections with the same peer.
  if (connections_.GetAclConnectionHandle(bd_addr).has_value()) {
    return;
@@ -5059,12 +5073,10 @@ void LinkLayerController::IncomingPagePacket(
    return;
  }

  if (IsEventUnmasked(EventCode::CONNECTION_REQUEST)) {
  send_event_(bluetooth::hci::ConnectionRequestBuilder::Create(
      bd_addr, page.GetClassOfDevice(),
      bluetooth::hci::ConnectionRequestLinkType::ACL));
}
}

void LinkLayerController::IncomingPageRejectPacket(
    model::packets::LinkLayerPacketView incoming) {
@@ -5314,15 +5326,9 @@ void LinkLayerController::MakePeripheralConnection(const Address& bd_addr,
  if (page_.has_value() && page_->bd_addr == bd_addr) {
    // TODO: the core specification is very unclear as to what behavior
    // is expected when two connections are established simultaneously.
    // This implementation considers that an HCI Connection Complete
    // This implementation considers that a unique HCI Connection Complete
    // event is expected for both the HCI Create Connection and HCI Accept
    // Connection Request commands. Both events are sent with the status
    // for success.
    if (IsEventUnmasked(EventCode::CONNECTION_COMPLETE)) {
      send_event_(bluetooth::hci::ConnectionCompleteBuilder::Create(
          ErrorCode::SUCCESS, connection_handle, bd_addr,
          bluetooth::hci::LinkType::ACL, bluetooth::hci::Enable::DISABLED));
    }
    // Connection Request commands.
    page_ = {};
  }

+0 −7
Original line number Diff line number Diff line
@@ -56,10 +56,3 @@ class Test(ControllerTest):
                                   bd_addr=peer_address,
                                   link_type=hci.LinkType.ACL,
                                   encryption_enabled=hci.Enable.DISABLED))

        await self.expect_evt(
            hci.ConnectionComplete(status=ErrorCode.SUCCESS,
                                   connection_handle=acl_connection_handle,
                                   bd_addr=peer_address,
                                   link_type=hci.LinkType.ACL,
                                   encryption_enabled=hci.Enable.DISABLED))