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

Commit 3ae70074 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "RootCanal: Support Suggested Default Length" am: f451333a

Original change: https://android-review.googlesource.com/c/platform/system/bt/+/1832035

Change-Id: I15176f7ded90a15792839c01e6d929553074f761
parents 042bed28 f451333a
Loading
Loading
Loading
Loading
+28 −2
Original line number Diff line number Diff line
@@ -265,6 +265,8 @@ DualModeController::DualModeController(const std::string& properties_filename, u
  SET_SUPPORTED(LE_SET_PRIVACY_MODE, LeSetPrivacyMode);
  SET_SUPPORTED(LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH,
                LeReadSuggestedDefaultDataLength);
  SET_SUPPORTED(LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH,
                LeWriteSuggestedDefaultDataLength);
  // ISO Commands
  SET_SUPPORTED(LE_READ_ISO_TX_SYNC, LeReadIsoTxSync);
  SET_SUPPORTED(LE_SET_CIG_PARAMETERS, LeSetCigParameters);
@@ -1947,8 +1949,32 @@ void DualModeController::LeReadSuggestedDefaultDataLength(CommandView command) {
      gd_hci::LeConnectionManagementCommandView::Create(
          gd_hci::AclCommandView::Create(command)));
  ASSERT(command_view.IsValid());
  send_event_(bluetooth::hci::LeReadSuggestedDefaultDataLengthCompleteBuilder::Create(
      kNumCommandPackets, ErrorCode::SUCCESS, kLeMaximumDataLength, kLeMaximumDataTime));
  send_event_(
      bluetooth::hci::LeReadSuggestedDefaultDataLengthCompleteBuilder::Create(
          kNumCommandPackets, ErrorCode::SUCCESS,
          le_suggested_default_data_bytes_, le_suggested_default_data_time_));
}

void DualModeController::LeWriteSuggestedDefaultDataLength(
    CommandView command) {
  auto command_view = gd_hci::LeWriteSuggestedDefaultDataLengthView::Create(
      gd_hci::LeConnectionManagementCommandView::Create(
          gd_hci::AclCommandView::Create(command)));
  ASSERT(command_view.IsValid());
  uint16_t bytes = command_view.GetTxOctets();
  uint16_t time = command_view.GetTxTime();
  if (bytes > 0xFB || bytes < 0x1B || time < 0x148 || time > 0x4290) {
    send_event_(
        bluetooth::hci::LeWriteSuggestedDefaultDataLengthCompleteBuilder::
            Create(kNumCommandPackets,
                   ErrorCode::INVALID_HCI_COMMAND_PARAMETERS));
    return;
  }
  le_suggested_default_data_bytes_ = bytes;
  le_suggested_default_data_time_ = time;
  send_event_(
      bluetooth::hci::LeWriteSuggestedDefaultDataLengthCompleteBuilder::Create(
          kNumCommandPackets, ErrorCode::SUCCESS));
}

void DualModeController::LeAddDeviceToResolvingList(CommandView command) {
+7 −0
Original line number Diff line number Diff line
@@ -468,6 +468,9 @@ class DualModeController : public Device {
  // 7.8.34
  void LeReadSuggestedDefaultDataLength(CommandView args);

  // 7.8.35
  void LeWriteSuggestedDefaultDataLength(CommandView args);

  // 7.8.38
  void LeAddDeviceToResolvingList(CommandView args);

@@ -575,6 +578,10 @@ class DualModeController : public Device {

  void SendCommandCompleteUnknownOpCodeEvent(uint16_t command_opcode) const;

  // Unused state to maintain consistency for the Host
  uint16_t le_suggested_default_data_bytes_{0x20};
  uint16_t le_suggested_default_data_time_{0x148};

  // Callbacks to send packets back to the HCI.
  std::function<void(std::shared_ptr<bluetooth::hci::AclBuilder>)> send_acl_;
  std::function<void(std::shared_ptr<bluetooth::hci::EventBuilder>)>