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

Commit ef5f5dab authored by David Duarte's avatar David Duarte Committed by Gerrit Code Review
Browse files

Merge "Revert "RootCanal: Delay the first ACL packet sent on a connection""

parents 95df56ea e535096b
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -26,7 +26,6 @@ AclConnection::AclConnection(AddressWithType address,
      resolved_address_(resolved_address),
      type_(phy_type),
      role_(role),
      established_timestamp_(std::chrono::steady_clock::now()),
      last_packet_timestamp_(std::chrono::steady_clock::now()),
      timeout_(std::chrono::seconds(1)) {}

+0 −5
Original line number Diff line number Diff line
@@ -59,10 +59,6 @@ class AclConnection {
  bool IsNearExpiring() const;
  bool HasExpired() const;

  std::chrono::steady_clock::duration GetUptime() const {
    return std::chrono::steady_clock::now() - established_timestamp_;
  }

  // LE-ACL state.
  void InitiatePhyUpdate() { initiated_phy_update_ = true; }
  void PhyUpdateComplete() { initiated_phy_update_ = false; }
@@ -86,7 +82,6 @@ class AclConnection {
  bool encrypted_{false};
  uint16_t link_policy_settings_{0};
  bluetooth::hci::Role role_{bluetooth::hci::Role::CENTRAL};
  std::chrono::steady_clock::time_point established_timestamp_;
  std::chrono::steady_clock::time_point last_packet_timestamp_;
  std::chrono::steady_clock::duration timeout_;

+9 −20
Original line number Diff line number Diff line
@@ -2043,20 +2043,20 @@ LinkLayerController::~LinkLayerController() {}

void LinkLayerController::SendLeLinkLayerPacket(
    std::unique_ptr<model::packets::LinkLayerPacketBuilder> packet,
    int8_t tx_power, std::chrono::milliseconds delay) {
    int8_t tx_power) {
  std::shared_ptr<model::packets::LinkLayerPacketBuilder> shared_packet =
      std::move(packet);
  ScheduleTask(delay, [this, shared_packet, tx_power]() {
  ScheduleTask(kNoDelayMs, [this, shared_packet, tx_power]() {
    send_to_remote_(shared_packet, Phy::Type::LOW_ENERGY, tx_power);
  });
}

void LinkLayerController::SendLinkLayerPacket(
    std::unique_ptr<model::packets::LinkLayerPacketBuilder> packet,
    int8_t tx_power, std::chrono::milliseconds delay) {
    int8_t tx_power) {
  std::shared_ptr<model::packets::LinkLayerPacketBuilder> shared_packet =
      std::move(packet);
  ScheduleTask(delay, [this, shared_packet, tx_power]() {
  ScheduleTask(kNoDelayMs, [this, shared_packet, tx_power]() {
    send_to_remote_(shared_packet, Phy::Type::BR_EDR, tx_power);
  });
}
@@ -2143,21 +2143,10 @@ ErrorCode LinkLayerController::SendAclToRemote(
    return ErrorCode::UNKNOWN_CONNECTION;
  }

  AclConnection& connection = connections_.GetAclConnection(handle);
  AddressWithType my_address = connection.GetOwnAddress();
  AddressWithType destination = connection.GetAddress();
  AddressWithType my_address = connections_.GetOwnAddress(handle);
  AddressWithType destination = connections_.GetAddress(handle);
  Phy::Type phy = connections_.GetPhyType(handle);

  // The PTS test L2CAP/CMC/BV-13-C flakes if the first ACL packet is
  // sent too early after the connection establishment; the PTS in
  // this case is handling the packet before the Connection Complete
  // event and this causes the test to fail.
  std::chrono::milliseconds connection_uptime =
      std::chrono::duration_cast<std::chrono::milliseconds>(
          connection.GetUptime());
  std::chrono::milliseconds delay =
      connection_uptime > 100ms ? 0ms : 100ms - connection_uptime;

  auto acl_packet_payload = acl_packet.GetPayload();
  auto acl = model::packets::AclBuilder::Create(
      my_address.GetAddress(), destination.GetAddress(),
@@ -2167,14 +2156,14 @@ ErrorCode LinkLayerController::SendAclToRemote(

  switch (phy) {
    case Phy::Type::BR_EDR:
      SendLinkLayerPacket(std::move(acl), 0, delay);
      SendLinkLayerPacket(std::move(acl));
      break;
    case Phy::Type::LOW_ENERGY:
      SendLeLinkLayerPacket(std::move(acl), 0, delay);
      SendLeLinkLayerPacket(std::move(acl));
      break;
  }

  ScheduleTask(delay, [this, handle]() {
  ScheduleTask(kNoDelayMs, [this, handle]() {
    send_event_(bluetooth::hci::NumberOfCompletedPacketsBuilder::Create(
        {bluetooth::hci::CompletedPackets(handle, 1)}));
  });
+2 −4
Original line number Diff line number Diff line
@@ -603,12 +603,10 @@ class LinkLayerController {
 protected:
  void SendLinkLayerPacket(
      std::unique_ptr<model::packets::LinkLayerPacketBuilder> packet,
      int8_t tx_power = 0,
      std::chrono::milliseconds delay = std::chrono::milliseconds(0));
      int8_t tx_power = 0);
  void SendLeLinkLayerPacket(
      std::unique_ptr<model::packets::LinkLayerPacketBuilder> packet,
      int8_t tx_power = 0,
      std::chrono::milliseconds delay = std::chrono::milliseconds(0));
      int8_t tx_power = 0);

  void IncomingAclPacket(model::packets::LinkLayerPacketView incoming,
                         int8_t rssi);