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

Commit 1725297b authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "RootCanal: Check connections when setting features"

parents bd8cfa5b 0b05e8a2
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -1676,13 +1676,18 @@ void DualModeController::LeSetEventMask(CommandView command) {
void DualModeController::LeSetHostFeature(CommandView command) {
  auto command_view = gd_hci::LeSetHostFeatureView::Create(command);
  ASSERT(command_view.IsValid());
  // TODO: if the controller has active connections, return COMMAND_DISALLOED
  ErrorCode error_code =
      properties_.SetLeHostFeature(

  ErrorCode error_code = ErrorCode::SUCCESS;
  if (link_layer_controller_.HasAclConnection()) {
    error_code = ErrorCode::COMMAND_DISALLOWED;
  } else {
    bool bit_was_set = properties_.SetLeHostFeature(
        static_cast<uint8_t>(command_view.GetBitNumber()),
          static_cast<uint8_t>(command_view.GetBitValue()))
          ? ErrorCode::SUCCESS
          : ErrorCode::UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE;
        static_cast<uint8_t>(command_view.GetBitValue()));
    if (!bit_was_set) {
      error_code = ErrorCode::UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE;
    }
  }
  send_event_(bluetooth::hci::LeSetHostFeatureCompleteBuilder::Create(
      kNumCommandPackets, error_code));
}
+4 −0
Original line number Diff line number Diff line
@@ -3396,6 +3396,10 @@ ErrorCode LinkLayerController::LeResolvingListAddDevice(
  return ErrorCode::SUCCESS;
}

bool LinkLayerController::HasAclConnection() {
  return (connections_.GetAclHandles().size() > 0);
}

void LinkLayerController::LeSetPrivacyMode(uint8_t address_type, Address addr,
                                           uint8_t mode) {
  // set mode for addr
+2 −0
Original line number Diff line number Diff line
@@ -380,6 +380,8 @@ class LinkLayerController {
      uint8_t retransmission_effort, uint16_t packet_types);
  ErrorCode RejectSynchronousConnection(Address bd_addr, uint16_t reason);

  bool HasAclConnection();

  void HandleIso(bluetooth::hci::IsoView iso);

 protected: