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

Commit 19890ff4 authored by Myles Watson's avatar Myles Watson Committed by Automerger Merge Worker
Browse files

Merge "RootCanal: better handling for Completed Number Of Packet events" am:...

Merge "RootCanal: better handling for Completed Number Of Packet events" am: 016ee9cd am: 46ee044a

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/1910534

Change-Id: I15c794709f23e0f28a286728107f0f2294b420b7
parents e37acfb0 46ee044a
Loading
Loading
Loading
Loading
+30 −5
Original line number Original line Diff line number Diff line
@@ -294,6 +294,9 @@ DualModeController::DualModeController(const std::string& properties_filename, u
  SET_SUPPORTED(WRITE_CONNECTION_ACCEPT_TIMEOUT, WriteConnectionAcceptTimeout);
  SET_SUPPORTED(WRITE_CONNECTION_ACCEPT_TIMEOUT, WriteConnectionAcceptTimeout);
  SET_SUPPORTED(LE_SET_ADDRESS_RESOLUTION_ENABLE, LeSetAddressResolutionEnable);
  SET_SUPPORTED(LE_SET_ADDRESS_RESOLUTION_ENABLE, LeSetAddressResolutionEnable);
  SET_SUPPORTED(LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT, LeSetResovalablePrivateAddressTimeout);
  SET_SUPPORTED(LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT, LeSetResovalablePrivateAddressTimeout);
  SET_SUPPORTED(READ_SYNCHRONOUS_FLOW_CONTROL_ENABLE, ReadSynchronousFlowControlEnable);
  SET_SUPPORTED(WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE, WriteSynchronousFlowControlEnable);

#undef SET_HANDLER
#undef SET_HANDLER
#undef SET_SUPPORTED
#undef SET_SUPPORTED
  properties_.SetSupportedCommands(supported_commands);
  properties_.SetSupportedCommands(supported_commands);
@@ -337,10 +340,8 @@ void DualModeController::HandleAcl(std::shared_ptr<std::vector<uint8_t>> packet)
    cp.connection_handle_ = handle;
    cp.connection_handle_ = handle;
    cp.host_num_of_completed_packets_ = kNumCommandPackets;
    cp.host_num_of_completed_packets_ = kNumCommandPackets;
    completed_packets.push_back(cp);
    completed_packets.push_back(cp);
    if (properties_.IsUnmasked(EventCode::NUMBER_OF_COMPLETED_PACKETS)) {
    send_event_(bluetooth::hci::NumberOfCompletedPacketsBuilder::Create(
    send_event_(bluetooth::hci::NumberOfCompletedPacketsBuilder::Create(
        completed_packets));
        completed_packets));
    }
    return;
    return;
  }
  }


@@ -360,7 +361,7 @@ void DualModeController::HandleSco(std::shared_ptr<std::vector<uint8_t>> packet)
    cp.connection_handle_ = handle;
    cp.connection_handle_ = handle;
    cp.host_num_of_completed_packets_ = kNumCommandPackets;
    cp.host_num_of_completed_packets_ = kNumCommandPackets;
    completed_packets.push_back(cp);
    completed_packets.push_back(cp);
    if (properties_.IsUnmasked(EventCode::NUMBER_OF_COMPLETED_PACKETS)) {
    if (properties_.GetSynchronousFlowControl()) {
      send_event_(bluetooth::hci::NumberOfCompletedPacketsBuilder::Create(
      send_event_(bluetooth::hci::NumberOfCompletedPacketsBuilder::Create(
          completed_packets));
          completed_packets));
    }
    }
@@ -1449,6 +1450,30 @@ void DualModeController::WriteScanEnable(CommandView command) {
  send_event_(std::move(packet));
  send_event_(std::move(packet));
}
}


void DualModeController::ReadSynchronousFlowControlEnable(CommandView command) {
  auto command_view = gd_hci::ReadSynchronousFlowControlEnableView::Create(
      gd_hci::DiscoveryCommandView::Create(command));
  ASSERT(command_view.IsValid());
  auto enabled = bluetooth::hci::Enable::DISABLED;
  if (properties_.GetSynchronousFlowControl()) {
    enabled = bluetooth::hci::Enable::ENABLED;
  }
  auto packet = bluetooth::hci::ReadSynchronousFlowControlEnableCompleteBuilder::Create(
      kNumCommandPackets, ErrorCode::SUCCESS, enabled);
  send_event_(std::move(packet));
}

void DualModeController::WriteSynchronousFlowControlEnable(CommandView command) {
  auto command_view = gd_hci::WriteSynchronousFlowControlEnableView::Create(
      gd_hci::DiscoveryCommandView::Create(command));
  ASSERT(command_view.IsValid());
  auto enabled = command_view.GetEnable() == bluetooth::hci::Enable::ENABLED;
  properties_.SetSynchronousFlowControl(enabled);
  auto packet = bluetooth::hci::WriteSynchronousFlowControlEnableCompleteBuilder::Create(
      kNumCommandPackets, ErrorCode::SUCCESS);
  send_event_(std::move(packet));
}

void DualModeController::SetEventFilter(CommandView command) {
void DualModeController::SetEventFilter(CommandView command) {
  auto command_view = gd_hci::SetEventFilterView::Create(command);
  auto command_view = gd_hci::SetEventFilterView::Create(command);
  ASSERT(command_view.IsValid());
  ASSERT(command_view.IsValid());
+6 −0
Original line number Original line Diff line number Diff line
@@ -289,6 +289,12 @@ class DualModeController : public Device {
  // 7.3.28
  // 7.3.28
  void WriteVoiceSetting(CommandView args);
  void WriteVoiceSetting(CommandView args);


  // 7.3.36
  void ReadSynchronousFlowControlEnable(CommandView args);

  // 7.3.37
  void WriteSynchronousFlowControlEnable(CommandView args);

  // 7.3.39
  // 7.3.39
  void HostBufferSize(CommandView args);
  void HostBufferSize(CommandView args);


+1 −3
Original line number Original line Diff line number Diff line
@@ -164,9 +164,7 @@ ErrorCode LinkLayerController::SendAclToRemote(
    completed_packets.push_back(cp);
    completed_packets.push_back(cp);
    auto packet = bluetooth::hci::NumberOfCompletedPacketsBuilder::Create(
    auto packet = bluetooth::hci::NumberOfCompletedPacketsBuilder::Create(
        completed_packets);
        completed_packets);
    if (properties_.IsUnmasked(EventCode::NUMBER_OF_COMPLETED_PACKETS)) {
    send_event_(std::move(packet));
    send_event_(std::move(packet));
    }
  });
  });


  auto acl_payload = acl_packet.GetPayload();
  auto acl_payload = acl_packet.GetPayload();
+9 −0
Original line number Original line Diff line number Diff line
@@ -133,6 +133,14 @@ class DeviceProperties {
    return num_sco_data_packets_;
    return num_sco_data_packets_;
  }
  }


  bool GetSynchronousFlowControl() const {
    return sco_flow_control_;
  }

  void SetSynchronousFlowControl(bool sco_flow_control) {
    sco_flow_control_ = sco_flow_control;
  }

  const Address& GetAddress() const {
  const Address& GetAddress() const {
    return address_;
    return address_;
  }
  }
@@ -391,6 +399,7 @@ class DeviceProperties {
  uint8_t sco_data_packet_size_;
  uint8_t sco_data_packet_size_;
  uint16_t num_acl_data_packets_;
  uint16_t num_acl_data_packets_;
  uint16_t num_sco_data_packets_;
  uint16_t num_sco_data_packets_;
  bool sco_flow_control_{false};
  uint8_t version_;
  uint8_t version_;
  uint16_t revision_;
  uint16_t revision_;
  uint8_t lmp_pal_version_;
  uint8_t lmp_pal_version_;