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

Commit 6f49da27 authored by Myles Watson's avatar Myles Watson Committed by Gerrit Code Review
Browse files

Merge changes from topic "bt-gd-vse"

* changes:
  Hci: Include 0xFF in event loops
  GD: Crash on Root Inflammation Event
  BQR: Print common BQR events
  Revert "GD HCI: Pipe VSEs up in shim layer"
  Revert "GD HCI: Support vendor specific event in GD"
parents cc770b24 291ba16b
Loading
Loading
Loading
Loading
+52 −43
Original line number Original line Diff line number Diff line
@@ -87,14 +87,17 @@ class CommandQueueEntry {
struct HciLayer::impl {
struct HciLayer::impl {
  impl(hal::HciHal* hal, HciLayer& module) : hal_(hal), module_(module) {
  impl(hal::HciHal* hal, HciLayer& module) : hal_(hal), module_(module) {
    hci_timeout_alarm_ = new Alarm(module.GetHandler());
    hci_timeout_alarm_ = new Alarm(module.GetHandler());
    hci_abort_alarm_ = new Alarm(module.GetHandler());
  }
  }


  ~impl() {
  ~impl() {
    incoming_acl_buffer_.Clear();
    incoming_acl_buffer_.Clear();
    incoming_iso_buffer_.Clear();
    incoming_iso_buffer_.Clear();
    if (hci_timeout_alarm_ != nullptr) {
      delete hci_timeout_alarm_;
      delete hci_timeout_alarm_;
    }
    if (hci_abort_alarm_ != nullptr) {
      delete hci_abort_alarm_;
      delete hci_abort_alarm_;
    }
    command_queue_.clear();
    command_queue_.clear();
  }
  }


@@ -165,12 +168,15 @@ struct HciLayer::impl {
    command_queue_.front().GetCallback<TResponse>()->Invoke(move(response_view));
    command_queue_.front().GetCallback<TResponse>()->Invoke(move(response_view));
    command_queue_.pop_front();
    command_queue_.pop_front();
    waiting_command_ = OpCode::NONE;
    waiting_command_ = OpCode::NONE;
    if (hci_timeout_alarm_ != nullptr) {
      hci_timeout_alarm_->Cancel();
      hci_timeout_alarm_->Cancel();
      send_next_command();
      send_next_command();
    }
    }
  }


  void on_hci_timeout(OpCode op_code) {
  void on_hci_timeout(OpCode op_code) {
    LOG_ERROR("Timed out waiting for 0x%02hx (%s)", op_code, OpCodeText(op_code).c_str());
    LOG_ERROR("Timed out waiting for 0x%02hx (%s)", op_code, OpCodeText(op_code).c_str());
    // TODO: LogMetricHciTimeoutEvent(static_cast<uint32_t>(op_code));


    LOG_ERROR("Flushing %zd waiting commands", command_queue_.size());
    LOG_ERROR("Flushing %zd waiting commands", command_queue_.size());
    // Clear any waiting commands (there is an abort coming anyway)
    // Clear any waiting commands (there is an abort coming anyway)
@@ -180,8 +186,17 @@ struct HciLayer::impl {
    enqueue_command(
    enqueue_command(
        ControllerDebugInfoBuilder::Create(), module_.GetHandler()->BindOnce(&fail_if_reset_complete_not_success));
        ControllerDebugInfoBuilder::Create(), module_.GetHandler()->BindOnce(&fail_if_reset_complete_not_success));
    // Don't time out for this one;
    // Don't time out for this one;
    if (hci_timeout_alarm_ != nullptr) {
      hci_timeout_alarm_->Cancel();
      hci_timeout_alarm_->Cancel();
      delete hci_timeout_alarm_;
      hci_timeout_alarm_ = nullptr;
    }
    if (hci_abort_alarm_ == nullptr) {
      hci_abort_alarm_ = new Alarm(module_.GetHandler());
      hci_abort_alarm_->Schedule(BindOnce(&abort_after_time_out, op_code), kHciTimeoutRestartMs);
      hci_abort_alarm_->Schedule(BindOnce(&abort_after_time_out, op_code), kHciTimeoutRestartMs);
    } else {
      LOG_WARN("Unable to schedul abort timer");
    }
  }
  }


  void send_next_command() {
  void send_next_command() {
@@ -204,7 +219,11 @@ struct HciLayer::impl {
    OpCode op_code = cmd_view.GetOpCode();
    OpCode op_code = cmd_view.GetOpCode();
    waiting_command_ = op_code;
    waiting_command_ = op_code;
    command_credits_ = 0;  // Only allow one outstanding command
    command_credits_ = 0;  // Only allow one outstanding command
    if (hci_timeout_alarm_ != nullptr) {
      hci_timeout_alarm_->Schedule(BindOnce(&impl::on_hci_timeout, common::Unretained(this), op_code), kHciTimeoutMs);
      hci_timeout_alarm_->Schedule(BindOnce(&impl::on_hci_timeout, common::Unretained(this), op_code), kHciTimeoutMs);
    } else {
      LOG_WARN("%s sent without an hci-timeout timer", OpCodeText(op_code).c_str());
    }
  }
  }


  void register_event(EventCode event, ContextualCallback<void(EventView)> handler) {
  void register_event(EventCode event, ContextualCallback<void(EventView)> handler) {
@@ -245,23 +264,38 @@ struct HciLayer::impl {
    subevent_handlers_.erase(subevent_handlers_.find(event));
    subevent_handlers_.erase(subevent_handlers_.find(event));
  }
  }


  void register_vendor_specific_event(
  static void abort_after_root_inflammation(uint8_t vse_error) {
      VseSubeventCode vse_subevent_code, ContextualCallback<void(VendorSpecificEventView)> event_handler) {
    ASSERT_LOG(false, "Root inflammation with reason 0x%02hhx", vse_error);
    ASSERT_LOG(
        vendor_specific_event_handlers_.count(vse_subevent_code) == 0,
        "Can not register a second handler for %02hhx (%s)",
        vse_subevent_code,
        VseSubeventCodeText(vse_subevent_code).c_str());
    vendor_specific_event_handlers_[vse_subevent_code] = event_handler;
  }
  }


  void unregister_vendor_specific_event(VseSubeventCode vse_subevent_code) {
  void handle_root_inflammation(uint8_t vse_error_reason) {
    vendor_specific_event_handlers_.erase(vendor_specific_event_handlers_.find(vse_subevent_code));
    // Add Logging for crash reason
    if (hci_timeout_alarm_ != nullptr) {
      hci_timeout_alarm_->Cancel();
      delete hci_timeout_alarm_;
      hci_timeout_alarm_ = nullptr;
    }
    LOG_ERROR("Received a Root Inflammation Event, scheduling an abort");
    if (hci_abort_alarm_ == nullptr) {
      hci_abort_alarm_ = new Alarm(module_.GetHandler());
      hci_abort_alarm_->Schedule(BindOnce(&abort_after_root_inflammation, vse_error_reason), kHciTimeoutRestartMs);
    } else {
      LOG_WARN("Abort timer already scheduled");
    }
  }
  }


  void on_hci_event(EventView event) {
  void on_hci_event(EventView event) {
    ASSERT(event.IsValid());
    ASSERT(event.IsValid());
    EventCode event_code = event.GetEventCode();
    EventCode event_code = event.GetEventCode();
    // Root Inflamation is a special case, since it aborts here
    if (event_code == EventCode::VENDOR_SPECIFIC) {
      auto inflammation = BqrRootInflammationEventView::Create(
          BqrLinkQualityEventView::Create(BqrEventView::Create(VendorSpecificEventView::Create(event))));
      if (inflammation.IsValid()) {
        handle_root_inflammation(inflammation.GetVendorSpecificErrorCode());
        return;
      }
    }
    ASSERT_LOG(
    ASSERT_LOG(
        event_handlers_.find(event_code) != event_handlers_.end(),
        event_handlers_.find(event_code) != event_handlers_.end(),
        "Unhandled event of type 0x%02hhx (%s)",
        "Unhandled event of type 0x%02hhx (%s)",
@@ -282,20 +316,6 @@ struct HciLayer::impl {
    subevent_handlers_[subevent_code].Invoke(meta_event_view);
    subevent_handlers_[subevent_code].Invoke(meta_event_view);
  }
  }


  void on_vendor_specific_event(EventView event) {
    VendorSpecificEventView vendor_specific_event_view = VendorSpecificEventView::Create(event);
    ASSERT(vendor_specific_event_view.IsValid());
    VseSubeventCode vse_subevent_code = vendor_specific_event_view.GetSubeventCode();
    if (vendor_specific_event_handlers_.find(vse_subevent_code) == vendor_specific_event_handlers_.end()) {
      LOG_ERROR(
          "Unhandled vendor specific event of type 0x%02hhx (%s)",
          vse_subevent_code,
          VseSubeventCodeText(vse_subevent_code).c_str());
      return;
    }
    vendor_specific_event_handlers_[vse_subevent_code].Invoke(vendor_specific_event_view);
  }

  hal::HciHal* hal_;
  hal::HciHal* hal_;
  HciLayer& module_;
  HciLayer& module_;


@@ -304,7 +324,6 @@ struct HciLayer::impl {


  std::map<EventCode, ContextualCallback<void(EventView)>> event_handlers_;
  std::map<EventCode, ContextualCallback<void(EventView)>> event_handlers_;
  std::map<SubeventCode, ContextualCallback<void(LeMetaEventView)>> subevent_handlers_;
  std::map<SubeventCode, ContextualCallback<void(LeMetaEventView)>> subevent_handlers_;
  std::map<VseSubeventCode, ContextualCallback<void(VendorSpecificEventView)>> vendor_specific_event_handlers_;
  OpCode waiting_command_{OpCode::NONE};
  OpCode waiting_command_{OpCode::NONE};
  uint8_t command_credits_{1};  // Send reset first
  uint8_t command_credits_{1};  // Send reset first
  Alarm* hci_timeout_alarm_{nullptr};
  Alarm* hci_timeout_alarm_{nullptr};
@@ -391,15 +410,6 @@ void HciLayer::UnregisterLeEventHandler(SubeventCode event) {
  CallOn(impl_, &impl::unregister_le_event, event);
  CallOn(impl_, &impl::unregister_le_event, event);
}
}


void HciLayer::RegisterVendorSpecificEventHandler(
    VseSubeventCode vse_subevent_code, common::ContextualCallback<void(VendorSpecificEventView)> event_handler) {
  CallOn(impl_, &impl::register_vendor_specific_event, vse_subevent_code, event_handler);
}

void HciLayer::UnregisterVendorSpecificEventHandler(VseSubeventCode vse_subevent_code) {
  CallOn(impl_, &impl::unregister_vendor_specific_event, vse_subevent_code);
}

void HciLayer::on_disconnection_complete(EventView event_view) {
void HciLayer::on_disconnection_complete(EventView event_view) {
  auto disconnection_view = DisconnectionCompleteView::Create(event_view);
  auto disconnection_view = DisconnectionCompleteView::Create(event_view);
  if (!disconnection_view.IsValid()) {
  if (!disconnection_view.IsValid()) {
@@ -526,7 +536,6 @@ void HciLayer::Start() {
  auto drop_packet = handler->BindOn(impl_, &impl::drop);
  auto drop_packet = handler->BindOn(impl_, &impl::drop);
  RegisterEventHandler(EventCode::PAGE_SCAN_REPETITION_MODE_CHANGE, drop_packet);
  RegisterEventHandler(EventCode::PAGE_SCAN_REPETITION_MODE_CHANGE, drop_packet);
  RegisterEventHandler(EventCode::MAX_SLOTS_CHANGE, drop_packet);
  RegisterEventHandler(EventCode::MAX_SLOTS_CHANGE, drop_packet);
  RegisterEventHandler(EventCode::VENDOR_SPECIFIC, handler->BindOn(impl_, &impl::on_vendor_specific_event));


  EnqueueCommand(ResetBuilder::Create(), handler->BindOnce(&fail_if_reset_complete_not_success));
  EnqueueCommand(ResetBuilder::Create(), handler->BindOnce(&fail_if_reset_complete_not_success));
  hal->registerIncomingPacketCallback(hal_callbacks_);
  hal->registerIncomingPacketCallback(hal_callbacks_);
+0 −5
Original line number Original line Diff line number Diff line
@@ -67,11 +67,6 @@ class HciLayer : public Module, public CommandInterface<CommandBuilder> {


  virtual void UnregisterLeEventHandler(SubeventCode subevent_code);
  virtual void UnregisterLeEventHandler(SubeventCode subevent_code);


  virtual void RegisterVendorSpecificEventHandler(
      VseSubeventCode vse_subevent_code, common::ContextualCallback<void(VendorSpecificEventView)> event_handler);

  virtual void UnregisterVendorSpecificEventHandler(VseSubeventCode vse_subevent_code);

  virtual SecurityInterface* GetSecurityInterface(common::ContextualCallback<void(EventView)> event_handler);
  virtual SecurityInterface* GetSecurityInterface(common::ContextualCallback<void(EventView)> event_handler);


  virtual LeSecurityInterface* GetLeSecurityInterface(common::ContextualCallback<void(LeMetaEventView)> event_handler);
  virtual LeSecurityInterface* GetLeSecurityInterface(common::ContextualCallback<void(LeMetaEventView)> event_handler);
+0 −96
Original line number Original line Diff line number Diff line
@@ -17,7 +17,6 @@
#include "hci/hci_layer.h"
#include "hci/hci_layer.h"


#include <gtest/gtest.h>
#include <gtest/gtest.h>

#include <list>
#include <list>
#include <memory>
#include <memory>


@@ -270,15 +269,6 @@ class DependsOnHci : public Module {
    return packetview;
    return packetview;
  }
  }


  void RegisterVendorSpecificEvent(VseSubeventCode event) {
    hci_->RegisterVendorSpecificEventHandler(
        event, GetHandler()->BindOn(this, &DependsOnHci::handle_event<VendorSpecificEventView>));
  }

  void UnregisterVendorSpecificEvent(VseSubeventCode event) {
    hci_->UnregisterVendorSpecificEventHandler(event);
  }

  void Start() {
  void Start() {
    hci_ = GetDependency<HciLayer>();
    hci_ = GetDependency<HciLayer>();
    hci_->RegisterEventHandler(
    hci_->RegisterEventHandler(
@@ -459,92 +449,6 @@ TEST_F(HciTest, leMetaEvent) {
  ASSERT_TRUE(LeConnectionCompleteView::Create(LeMetaEventView::Create(EventView::Create(event))).IsValid());
  ASSERT_TRUE(LeConnectionCompleteView::Create(LeMetaEventView::Create(EventView::Create(event))).IsValid());
}
}


TEST_F(HciTest, vendorSpecificEventRegistration) {
  auto event_future = upper->GetReceivedEventFuture();

  upper->RegisterVendorSpecificEvent(VseSubeventCode::BQR_EVENT);

  // Send a vendor specific event
  hal->callbacks->hciEventReceived(GetPacketBytes(BqrLinkQualityEventBuilder::Create(
      QualityReportId::A2DP_AUDIO_CHOPPY,
      BqrPacketType::TYPE_2DH1,
      /* handle */ 0x123,
      Role::CENTRAL,
      /* TX_Power_Level */ 0x05,
      /* RSSI */ 65,
      /* SNR */ 30,
      /* Unused_AFH_Channel_Count */ 0,
      /* AFH_Select_Unideal_Channel_Count */ 0,
      /* LSTO */ 12,
      /* Connection_Piconet_Clock */ 42,
      /* Retransmission_Count */ 1,
      /* No_RX_Count */ 1,
      /* NAK_Count */ 1,
      /* Last_TX_ACK_Timestamp */ 123456,
      /* Flow_Off_Count */ 78910,
      /* Last_Flow_On_Timestamp */ 123457,
      /* Buffer_Overflow_Bytes */ 42,
      /* Buffer_Underflow_Bytes */ 24,
      /* Vendor Specific Parameter */ std::make_unique<RawBuilder>())));

  // Wait for the event
  auto event_status = event_future.wait_for(kTimeout);
  ASSERT_EQ(event_status, std::future_status::ready);

  auto event = upper->GetReceivedEvent();
  ASSERT_TRUE(
      BqrLinkQualityEventView::Create(BqrEventView::Create(VendorSpecificEventView::Create(EventView::Create(event))))
          .IsValid());

  // Now test if we can unregister the vendor specific event handler
  event_future = upper->GetReceivedEventFuture();

  upper->UnregisterVendorSpecificEvent(VseSubeventCode::BQR_EVENT);

  hal->callbacks->hciEventReceived(GetPacketBytes(BqrLinkQualityEventBuilder::Create(
      QualityReportId::A2DP_AUDIO_CHOPPY,
      BqrPacketType::TYPE_2DH1,
      /* handle */ 0x123,
      Role::CENTRAL,
      /* TX_Power_Level */ 0x05,
      /* RSSI */ 65,
      /* SNR */ 30,
      /* Unused_AFH_Channel_Count */ 0,
      /* AFH_Select_Unideal_Channel_Count */ 0,
      /* LSTO */ 12,
      /* Connection_Piconet_Clock */ 42,
      /* Retransmission_Count */ 1,
      /* No_RX_Count */ 1,
      /* NAK_Count */ 1,
      /* Last_TX_ACK_Timestamp */ 123456,
      /* Flow_Off_Count */ 78910,
      /* Last_Flow_On_Timestamp */ 123457,
      /* Buffer_Overflow_Bytes */ 42,
      /* Buffer_Underflow_Bytes */ 24,
      /* Vendor Specific Parameter */ std::make_unique<RawBuilder>())));

  // Wait for unregistered event should timeout
  event_status = event_future.wait_for(kTimeout);
  ASSERT_NE(event_status, std::future_status::ready);
}

TEST_F(HciTest, vendorSpecificEventUnknown) {
  auto event_future = upper->GetReceivedEventFuture();

  upper->RegisterVendorSpecificEvent(VseSubeventCode::BQR_EVENT);

  // Send a vendor specific event
  // Make sure 0xFE is not used for any VSE, if not change this value to an unused one
  auto raw_builder = std::make_unique<RawBuilder>();
  raw_builder->AddOctets1(42);
  hal->callbacks->hciEventReceived(
      GetPacketBytes(VendorSpecificEventBuilder::Create(static_cast<VseSubeventCode>(0xFE), std::move(raw_builder))));

  // Wait for the event should timeout
  auto event_status = event_future.wait_for(kTimeout);
  ASSERT_NE(event_status, std::future_status::ready);
}

TEST_F(HciTest, hciTimeOut) {
TEST_F(HciTest, hciTimeOut) {
  auto event_future = upper->GetReceivedEventFuture();
  auto event_future = upper->GetReceivedEventFuture();
  auto reset_command_future = hal->GetSentCommandFuture();
  auto reset_command_future = hal->GetSentCommandFuture();
+13 −60
Original line number Original line Diff line number Diff line
@@ -54,8 +54,7 @@ static base::Callback<void(const base::Location&, BT_HDR*)> send_data_upwards;
static const packet_fragmenter_t* packet_fragmenter;
static const packet_fragmenter_t* packet_fragmenter;


namespace {
namespace {
bool is_valid_event_code(uint8_t event_code_raw) {
bool is_valid_event_code(bluetooth::hci::EventCode event_code) {
  auto event_code = static_cast<bluetooth::hci::EventCode>(event_code_raw);
  switch (event_code) {
  switch (event_code) {
    case bluetooth::hci::EventCode::INQUIRY_COMPLETE:
    case bluetooth::hci::EventCode::INQUIRY_COMPLETE:
    case bluetooth::hci::EventCode::INQUIRY_RESULT:
    case bluetooth::hci::EventCode::INQUIRY_RESULT:
@@ -116,9 +115,7 @@ bool is_valid_event_code(uint8_t event_code_raw) {
  return false;
  return false;
};
};


bool is_valid_subevent_code(uint8_t subevent_code_raw) {
bool is_valid_subevent_code(bluetooth::hci::SubeventCode subevent_code) {
  auto subevent_code =
      static_cast<bluetooth::hci::SubeventCode>(subevent_code_raw);
  switch (subevent_code) {
  switch (subevent_code) {
    case bluetooth::hci::SubeventCode::CONNECTION_COMPLETE:
    case bluetooth::hci::SubeventCode::CONNECTION_COMPLETE:
    case bluetooth::hci::SubeventCode::CONNECTION_UPDATE_COMPLETE:
    case bluetooth::hci::SubeventCode::CONNECTION_UPDATE_COMPLETE:
@@ -161,19 +158,6 @@ bool is_valid_subevent_code(uint8_t subevent_code_raw) {
  }
  }
}
}


bool is_valid_vendor_specific_event(uint8_t vse_code_raw) {
  auto vse_code = static_cast<bluetooth::hci::VseSubeventCode>(vse_code_raw);
  switch (vse_code) {
    case bluetooth::hci::VseSubeventCode::BQR_EVENT:
    case bluetooth::hci::VseSubeventCode::BLE_THRESHOLD:
    case bluetooth::hci::VseSubeventCode::BLE_TRACKING:
    case bluetooth::hci::VseSubeventCode::DEBUG_INFO:
      return true;
    default:
      return false;
  }
}

static bool event_already_registered_in_hci_layer(
static bool event_already_registered_in_hci_layer(
    bluetooth::hci::EventCode event_code) {
    bluetooth::hci::EventCode event_code) {
  switch (event_code) {
  switch (event_code) {
@@ -181,8 +165,6 @@ static bool event_already_registered_in_hci_layer(
    case bluetooth::hci::EventCode::COMMAND_STATUS:
    case bluetooth::hci::EventCode::COMMAND_STATUS:
    case bluetooth::hci::EventCode::PAGE_SCAN_REPETITION_MODE_CHANGE:
    case bluetooth::hci::EventCode::PAGE_SCAN_REPETITION_MODE_CHANGE:
    case bluetooth::hci::EventCode::MAX_SLOTS_CHANGE:
    case bluetooth::hci::EventCode::MAX_SLOTS_CHANGE:
    case bluetooth::hci::EventCode::VENDOR_SPECIFIC:
      return bluetooth::shim::is_gd_hci_enabled();
    case bluetooth::hci::EventCode::DISCONNECTION_COMPLETE:
    case bluetooth::hci::EventCode::DISCONNECTION_COMPLETE:
    case bluetooth::hci::EventCode::READ_REMOTE_VERSION_INFORMATION_COMPLETE:
    case bluetooth::hci::EventCode::READ_REMOTE_VERSION_INFORMATION_COMPLETE:
    case bluetooth::hci::EventCode::LE_META_EVENT:
    case bluetooth::hci::EventCode::LE_META_EVENT:
@@ -354,16 +336,6 @@ static void subevent_callback(
                                                     &le_meta_event_view));
                                                     &le_meta_event_view));
}
}


static void vendor_specific_event_callback(
    bluetooth::hci::VendorSpecificEventView vendor_specific_event_view) {
  if (!send_data_upwards) {
    return;
  }
  send_data_upwards.Run(
      FROM_HERE,
      WrapPacketAndCopy(MSG_HC_TO_STACK_HCI_EVT, &vendor_specific_event_view));
}

void OnTransmitPacketCommandComplete(command_complete_cb complete_callback,
void OnTransmitPacketCommandComplete(command_complete_cb complete_callback,
                                     void* context,
                                     void* context,
                                     bluetooth::hci::CommandCompleteView view) {
                                     bluetooth::hci::CommandCompleteView view) {
@@ -453,13 +425,6 @@ static void register_le_event(bluetooth::hci::SubeventCode subevent_code) {
      subevent_code, handler->Bind(subevent_callback));
      subevent_code, handler->Bind(subevent_callback));
}
}


static void register_vendor_specific_event(
    bluetooth::hci::VseSubeventCode vse_code) {
  auto handler = bluetooth::shim::GetGdShimHandler();
  bluetooth::shim::GetHciLayer()->RegisterVendorSpecificEventHandler(
      vse_code, handler->Bind(vendor_specific_event_callback));
}

static void acl_data_callback() {
static void acl_data_callback() {
  if (hci_queue_end == nullptr) {
  if (hci_queue_end == nullptr) {
    return;
    return;
@@ -504,11 +469,12 @@ static void on_shutting_down() {
        !bluetooth::shim::is_gd_l2cap_enabled()) {
        !bluetooth::shim::is_gd_l2cap_enabled()) {
      hci_queue_end->UnregisterDequeue();
      hci_queue_end->UnregisterDequeue();
    }
    }
    for (uint8_t event_code_raw = 0; event_code_raw < 0xFF; event_code_raw++) {
    for (uint16_t event_code_raw = 0; event_code_raw < 0x100;
      if (!is_valid_event_code(event_code_raw)) {
         event_code_raw++) {
      auto event_code = static_cast<bluetooth::hci::EventCode>(event_code_raw);
      if (!is_valid_event_code(event_code)) {
        continue;
        continue;
      }
      }
      auto event_code = static_cast<bluetooth::hci::EventCode>(event_code_raw);
      if (event_already_registered_in_hci_layer(event_code)) {
      if (event_already_registered_in_hci_layer(event_code)) {
        continue;
        continue;
      } else if (event_already_registered_in_le_advertising_manager(
      } else if (event_already_registered_in_le_advertising_manager(
@@ -747,11 +713,11 @@ void bluetooth::shim::hci_on_reset_complete() {
    ::rust::hci_on_reset_complete();
    ::rust::hci_on_reset_complete();
  }
  }


  for (uint8_t event_code_raw = 0; event_code_raw < 0xFF; event_code_raw++) {
  for (uint16_t event_code_raw = 0; event_code_raw < 0x100; event_code_raw++) {
    if (!is_valid_event_code(event_code_raw)) {
    auto event_code = static_cast<bluetooth::hci::EventCode>(event_code_raw);
    if (!is_valid_event_code(event_code)) {
      continue;
      continue;
    }
    }
    auto event_code = static_cast<bluetooth::hci::EventCode>(event_code_raw);
    if (event_already_registered_in_acl_layer(event_code)) {
    if (event_already_registered_in_acl_layer(event_code)) {
      continue;
      continue;
    } else if (event_already_registered_in_controller_layer(event_code)) {
    } else if (event_already_registered_in_controller_layer(event_code)) {
@@ -771,13 +737,13 @@ void bluetooth::shim::hci_on_reset_complete() {
    }
    }
  }
  }


  for (uint8_t subevent_code_raw = 0; subevent_code_raw < 0xFF;
  for (uint16_t subevent_code_raw = 0; subevent_code_raw < 0x100;
       subevent_code_raw++) {
       subevent_code_raw++) {
    if (!is_valid_subevent_code(subevent_code_raw)) {
      continue;
    }
    auto subevent_code =
    auto subevent_code =
        static_cast<bluetooth::hci::SubeventCode>(subevent_code_raw);
        static_cast<bluetooth::hci::SubeventCode>(subevent_code_raw);
    if (!is_valid_subevent_code(subevent_code)) {
      continue;
    }
    if (subevent_already_registered_in_le_hci_layer(subevent_code)) {
    if (subevent_already_registered_in_le_hci_layer(subevent_code)) {
      continue;
      continue;
    }
    }
@@ -789,19 +755,6 @@ void bluetooth::shim::hci_on_reset_complete() {
    }
    }
  }
  }


  for (uint8_t vse_code_raw = 0; vse_code_raw < 0xFF; vse_code_raw++) {
    if (!is_valid_vendor_specific_event(vse_code_raw)) {
      continue;
    }
    auto vse_code = static_cast<bluetooth::hci::VseSubeventCode>(vse_code_raw);
    if (bluetooth::common::init_flags::gd_rust_is_enabled()) {
      // TODO(b/183057550): Need Rust HCI implementation for VSE
      // ::rust::register_vendor_specific_event(vse_code_raw);
    } else {
      cpp::register_vendor_specific_event(vse_code);
    }
  }

  if (bluetooth::shim::is_gd_acl_enabled()) {
  if (bluetooth::shim::is_gd_acl_enabled()) {
    return;
    return;
  }
  }
+1 −0
Original line number Original line Diff line number Diff line
@@ -716,6 +716,7 @@ cc_test {
        "test/btm/stack_btm_test.cc",
        "test/btm/stack_btm_test.cc",
        "test/common/mock_bta_dm_act.cc",
        "test/common/mock_bta_dm_act.cc",
        "test/common/mock_bta_sys_conn.cc",
        "test/common/mock_bta_sys_conn.cc",
        "test/common/mock_btif_bqr.cc",
        "test/common/mock_btif_dm.cc",
        "test/common/mock_btif_dm.cc",
        "test/common/mock_btif_storage.cc",
        "test/common/mock_btif_storage.cc",
        "test/common/mock_btu_hcif.cc",
        "test/common/mock_btu_hcif.cc",
Loading