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

Commit 901a2fa0 authored by Henri Chataing's avatar Henri Chataing
Browse files

RootCanal: Implement HCI LE Request Peer SCA command

Required by the LE Audio in Android which performs the
command which checking the supported bit;
the stack crashes when it receives a Command Complete event
instead of Command Status

Bug: 286588829
Test: m root-canal
Change-Id: Iaecc31a9d1ab822796d6a2fb74a4be9af737ee1b
parent 33018ef6
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -386,8 +386,8 @@ static std::array<uint8_t, 64> SupportedCommands() {
      // OpCodeIndex::LE_TERMINATE_BIG,
      // OpCodeIndex::LE_BIG_CREATE_SYNC,
      // OpCodeIndex::LE_BIG_TERMINATE_SYNC,
      // OpCodeIndex::LE_REQUEST_PEER_SCA,
      OpCodeIndex::LE_SETUP_ISO_DATA_PATH, OpCodeIndex::LE_REMOVE_ISO_DATA_PATH,
      OpCodeIndex::LE_REQUEST_PEER_SCA, OpCodeIndex::LE_SETUP_ISO_DATA_PATH,
      OpCodeIndex::LE_REMOVE_ISO_DATA_PATH,
      // OpCodeIndex::LE_ISO_TRANSMIT_TEST,
      // OpCodeIndex::LE_ISO_RECEIVE_TEST,
      // OpCodeIndex::LE_ISO_READ_TEST_COUNTERS,
@@ -1802,6 +1802,7 @@ static std::vector<OpCodeIndex> ll_connected_isochronous_stream_commands_ = {
    OpCodeIndex::LE_REJECT_CIS_REQUEST,
    OpCodeIndex::LE_SETUP_ISO_DATA_PATH,
    OpCodeIndex::LE_REMOVE_ISO_DATA_PATH,
    OpCodeIndex::LE_REQUEST_PEER_SCA,
};

static void SetLLFeatureBit(uint64_t& le_features, LLFeaturesBits bit,
+33 −1
Original line number Diff line number Diff line
@@ -1816,6 +1816,38 @@ void DualModeController::LeSetEventMask(CommandView command) {
      kNumCommandPackets, ErrorCode::SUCCESS));
}

void DualModeController::LeRequestPeerSca(CommandView command) {
  auto command_view = bluetooth::hci::LeRequestPeerScaView::Create(command);
  ASSERT(command_view.IsValid());
  uint16_t connection_handle = command_view.GetConnectionHandle();

  DEBUG(id_, "<< LE Request Peer SCA");
  DEBUG(id_, "   connection_handle=0x{:x}", connection_handle);

  // If the Host sends this command and the peer device does not support the
  // Sleep Clock Accuracy Updates feature, the Controller shall return the error
  // code Unsupported Feature or Parameter Value (0x11) in the HCI_LE_-
  // Request_Peer_SCA_Complete event.
  // TODO

  // If the Host issues this command when the Controller is aware (e.g., through
  // a previous feature exchange) that the peer device's Link Layer does not
  // support the Sleep Clock Accuracy Updates feature, the Controller shall
  // return the error code Unsupported Remote Feature (0x1A).
  // TODO

  if (link_layer_controller_.HasAclConnection(connection_handle)) {
    send_event_(bluetooth::hci::LeRequestPeerScaStatusBuilder::Create(
        ErrorCode::SUCCESS, kNumCommandPackets));
    send_event_(bluetooth::hci::LeRequestPeerScaCompleteBuilder::Create(
        ErrorCode::SUCCESS, connection_handle,
        bluetooth::hci::ClockAccuracy::PPM_500));
  } else {
    send_event_(bluetooth::hci::LeRequestPeerScaStatusBuilder::Create(
        ErrorCode::UNKNOWN_CONNECTION, kNumCommandPackets));
  }
}

void DualModeController::LeSetHostFeature(CommandView command) {
  auto command_view = bluetooth::hci::LeSetHostFeatureView::Create(command);
  ASSERT(command_view.IsValid());
@@ -4234,7 +4266,7 @@ const std::unordered_map<OpCode, DualModeController::CommandHandler>
        //{OpCode::LE_BIG_CREATE_SYNC, &DualModeController::LeBigCreateSync},
        //{OpCode::LE_BIG_TERMINATE_SYNC,
        //&DualModeController::LeBigTerminateSync},
        //{OpCode::LE_REQUEST_PEER_SCA, &DualModeController::LeRequestPeerSca},
        {OpCode::LE_REQUEST_PEER_SCA, &DualModeController::LeRequestPeerSca},
        {OpCode::LE_SETUP_ISO_DATA_PATH, &DualModeController::ForwardToLl},
        {OpCode::LE_REMOVE_ISO_DATA_PATH, &DualModeController::ForwardToLl},
        //{OpCode::LE_ISO_TRANSMIT_TEST,
+3 −0
Original line number Diff line number Diff line
@@ -496,6 +496,9 @@ class DualModeController : public Device {
  // 7.8.77
  void LeSetPrivacyMode(CommandView command);

  // 7.8.108
  void LeRequestPeerSca(CommandView command);

  // 7.8.115
  void LeSetHostFeature(CommandView command);