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

Commit 84ed56d3 authored by Myles Watson's avatar Myles Watson
Browse files

HCI: Share more code with hci_layer_fake

Bug: 301661850
Test: atest bluetooth_test_gd_unit
Flag: EXEMPT, test-only update
Change-Id: I49ef471c3bd9e6985e0991f449159b7b74bed618
parent eebfb5ed
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -685,6 +685,13 @@ void HciLayer::Start() {
  impl_->sco_queue_.GetDownEnd()->RegisterDequeue(handler, BindOn(impl_, &impl::on_outbound_sco_ready));
  impl_->iso_queue_.GetDownEnd()->RegisterDequeue(
      handler, BindOn(impl_, &impl::on_outbound_iso_ready));
  StartWithNoHalDependencies(handler);
  hal->registerIncomingPacketCallback(hal_callbacks_);
  EnqueueCommand(ResetBuilder::Create(), handler->BindOnce(&fail_if_reset_complete_not_success));
}

// Initialize event handlers that don't depend on the HAL
void HciLayer::StartWithNoHalDependencies(Handler* handler) {
  RegisterEventHandler(EventCode::DISCONNECTION_COMPLETE, handler->BindOn(this, &HciLayer::on_disconnection_complete));
  RegisterEventHandler(
      EventCode::READ_REMOTE_VERSION_INFORMATION_COMPLETE,
@@ -692,9 +699,6 @@ void HciLayer::Start() {
  auto drop_packet = handler->BindOn(impl_, &impl::drop);
  RegisterEventHandler(EventCode::PAGE_SCAN_REPETITION_MODE_CHANGE, drop_packet);
  RegisterEventHandler(EventCode::MAX_SLOTS_CHANGE, drop_packet);

  hal->registerIncomingPacketCallback(hal_callbacks_);
  EnqueueCommand(ResetBuilder::Create(), handler->BindOnce(&fail_if_reset_complete_not_success));
}

void HciLayer::Stop() {
+3 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@
#include "hci/le_security_interface.h"
#include "hci/security_interface.h"
#include "module.h"
#include "os/handler.h"
#include "os/utils.h"

namespace bluetooth {
@@ -119,6 +120,8 @@ class HciLayer : public Module, public CommandInterface<CommandBuilder> {

  void Start() override;

  void StartWithNoHalDependencies(os::Handler* handler);

  void Stop() override;

  virtual void Disconnect(uint16_t handle, ErrorCode reason);
+2 −0
Original line number Diff line number Diff line
@@ -244,6 +244,8 @@ void HciLayerFake::ListDependencies(ModuleList* /* list */) const {}
void HciLayerFake::Start() {
  std::lock_guard<std::mutex> lock(mutex_);
  InitEmptyCommand();
  os::Handler* handler = GetHandler();
  StartWithNoHalDependencies(handler);
}
void HciLayerFake::Stop() {}