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

Commit b7e204ba authored by Henri Chataing's avatar Henri Chataing
Browse files

gd/hal: Rename the nocp_iso_clocker module to link_clocker

In preparation for adding the support for L2CAP credit
acknowledgments parsed from ACL data packets.

Add empty OnAclData packet handler, to be implemented.

Bug: 300285792
Bug: 312273987
Test: m com.android.btservices
Change-Id: Ib9b96c8c579ab67239d4a50f3fd1cf7e739a53bf
parent d3ba2297
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -19,11 +19,12 @@
#include <base/logging.h>
#include <base/strings/stringprintf.h>

#include <algorithm>
#include <cmath>
#include <utility>

#include "asrc_tables.h"
#include "hal/nocp_iso_clocker.h"
#include "hal/link_clocker.h"

namespace bluetooth::audio::asrc {

@@ -238,10 +239,10 @@ class SourceAudioHalAsrc::ClockRecovery : ::bluetooth::hal::NocpIsoHandler {
            .link = {{.state = LinkState::RESET}, {.state = LinkState::RESET}},
            .active_link_id = -1},
        reference_timing_{0, 0, 0} {
    ::bluetooth::hal::NocpIsoClocker::Register(this);
    ::bluetooth::hal::LinkClocker::Register(this);
  }

  ~ClockRecovery() override { ::bluetooth::hal::NocpIsoClocker::Unregister(); }
  ~ClockRecovery() override { ::bluetooth::hal::LinkClocker::Unregister(); }

  __attribute__((no_sanitize("integer"))) uint32_t Convert(
      uint32_t stream_time) {
+2 −2
Original line number Diff line number Diff line
@@ -20,8 +20,8 @@
#include <iostream>

namespace bluetooth::hal {
void NocpIsoClocker::Register(NocpIsoHandler*) {}
void NocpIsoClocker::Unregister() {}
void LinkClocker::Register(NocpIsoHandler*) {}
void LinkClocker::Unregister() {}
}  // namespace bluetooth::hal

namespace bluetooth::audio::asrc {
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ package {
filegroup {
    name: "BluetoothHalSources",
    srcs: [
        "nocp_iso_clocker.cc",
        "link_clocker.cc",
        "snoop_logger.cc",
        "snoop_logger_socket.cc",
        "snoop_logger_socket_thread.cc",
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

source_set("BluetoothHalSources") {
  sources = [
    "nocp_iso_clocker.cc",
    "link_clocker.cc",
    "snoop_logger.cc",
    "snoop_logger_socket.cc",
    "snoop_logger_socket_thread.cc",
+14 −14
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@
#include "common/stop_watch.h"
#include "common/strings.h"
#include "hal/hci_hal.h"
#include "hal/nocp_iso_clocker.h"
#include "hal/link_clocker.h"
#include "hal/snoop_logger.h"
#include "os/alarm.h"
#include "os/log.h"
@@ -83,8 +83,8 @@ std::string GetTimerText(const char* func_name, VecType vec) {

class InternalHciCallbacks : public IBluetoothHciCallbacks_1_1 {
 public:
  InternalHciCallbacks(SnoopLogger* btsnoop_logger, NocpIsoClocker* nocp_iso_clocker)
      : btsnoop_logger_(btsnoop_logger), nocp_iso_clocker_(nocp_iso_clocker) {
  InternalHciCallbacks(SnoopLogger* btsnoop_logger, LinkClocker* link_clocker)
      : btsnoop_logger_(btsnoop_logger), link_clocker_(link_clocker) {
    init_promise_ = new std::promise<void>();
  }

@@ -115,7 +115,7 @@ class InternalHciCallbacks : public IBluetoothHciCallbacks_1_1 {
  Return<void> hciEventReceived(const hidl_vec<uint8_t>& event) override {
    common::StopWatch stop_watch(GetTimerText(__func__, event));
    std::vector<uint8_t> received_hci_packet(event.begin(), event.end());
    nocp_iso_clocker_->OnHciEvent(received_hci_packet);
    link_clocker_->OnHciEvent(received_hci_packet);
    btsnoop_logger_->Capture(
        received_hci_packet, SnoopLogger::Direction::INCOMING, SnoopLogger::PacketType::EVT);
    {
@@ -174,7 +174,7 @@ class InternalHciCallbacks : public IBluetoothHciCallbacks_1_1 {
  std::promise<void>* init_promise_ = nullptr;
  HciHalCallbacks* callback_ = nullptr;
  SnoopLogger* btsnoop_logger_ = nullptr;
  NocpIsoClocker* nocp_iso_clocker_ = nullptr;
  LinkClocker* link_clocker_ = nullptr;
};

static constexpr char kBluetoothAidlHalServiceName[] =
@@ -182,8 +182,8 @@ static constexpr char kBluetoothAidlHalServiceName[] =

class AidlHciCallbacks : public ::aidl::android::hardware::bluetooth::BnBluetoothHciCallbacks {
 public:
  AidlHciCallbacks(SnoopLogger* btsnoop_logger, NocpIsoClocker* nocp_iso_clocker)
      : btsnoop_logger_(btsnoop_logger), nocp_iso_clocker_(nocp_iso_clocker) {
  AidlHciCallbacks(SnoopLogger* btsnoop_logger, LinkClocker* link_clocker)
      : btsnoop_logger_(btsnoop_logger), link_clocker_(link_clocker) {
    init_promise_ = new std::promise<void>();
  }

@@ -212,7 +212,7 @@ class AidlHciCallbacks : public ::aidl::android::hardware::bluetooth::BnBluetoot
  ::ndk::ScopedAStatus hciEventReceived(const std::vector<uint8_t>& event) override {
    common::StopWatch stop_watch(GetTimerText(__func__, event));
    std::vector<uint8_t> received_hci_packet(event.begin(), event.end());
    nocp_iso_clocker_->OnHciEvent(received_hci_packet);
    link_clocker_->OnHciEvent(received_hci_packet);
    btsnoop_logger_->Capture(
        received_hci_packet, SnoopLogger::Direction::INCOMING, SnoopLogger::PacketType::EVT);
    bool sent = false;
@@ -291,7 +291,7 @@ class AidlHciCallbacks : public ::aidl::android::hardware::bluetooth::BnBluetoot
  std::promise<void>* init_promise_ = nullptr;
  HciHalCallbacks* callback_ = nullptr;
  SnoopLogger* btsnoop_logger_ = nullptr;
  NocpIsoClocker* nocp_iso_clocker_ = nullptr;
  LinkClocker* link_clocker_ = nullptr;
};

}  // namespace
@@ -362,7 +362,7 @@ class HciHalHidl : public HciHal {

 protected:
  void ListDependencies(ModuleList* list) const {
    list->add<NocpIsoClocker>();
    list->add<LinkClocker>();
    list->add<SnoopLogger>();
  }

@@ -374,7 +374,7 @@ class HciHalHidl : public HciHal {
    ASSERT(bt_hci_1_1_ == nullptr);
    ASSERT(aidl_hci_ == nullptr);

    nocp_iso_clocker_ = GetDependency<NocpIsoClocker>();
    link_clocker_ = GetDependency<LinkClocker>();
    btsnoop_logger_ = GetDependency<SnoopLogger>();

    if (AServiceManager_isDeclared(kBluetoothAidlHalServiceName)) {
@@ -408,7 +408,7 @@ class HciHalHidl : public HciHal {
          death_link == STATUS_OK, "Unable to set the death recipient for the Bluetooth HAL");

      aidl_callbacks_ =
          ::ndk::SharedRefBase::make<AidlHciCallbacks>(btsnoop_logger_, nocp_iso_clocker_);
          ::ndk::SharedRefBase::make<AidlHciCallbacks>(btsnoop_logger_, link_clocker_);
      aidl_hci_->initialize(aidl_callbacks_);
    }
  }
@@ -448,7 +448,7 @@ class HciHalHidl : public HciHal {
    ASSERT(bt_hci_ != nullptr);
    auto death_link = bt_hci_->linkToDeath(hci_death_recipient_, 0);
    ASSERT_LOG(death_link.isOk(), "Unable to set the death recipient for the Bluetooth HAL");
    hidl_callbacks_ = new InternalHciCallbacks(btsnoop_logger_, nocp_iso_clocker_);
    hidl_callbacks_ = new InternalHciCallbacks(btsnoop_logger_, link_clocker_);

    if (bt_hci_1_1_ != nullptr) {
      bt_hci_1_1_->initialize_1_1(hidl_callbacks_);
@@ -507,7 +507,7 @@ class HciHalHidl : public HciHal {
  std::shared_ptr<AidlHciCallbacks> aidl_callbacks_;
  ::ndk::ScopedAIBinder_DeathRecipient aidl_death_recipient_;
  SnoopLogger* btsnoop_logger_;
  NocpIsoClocker* nocp_iso_clocker_;
  LinkClocker* link_clocker_;
};

const ModuleFactory HciHal::Factory = ModuleFactory([]() { return new HciHalHidl(); });
Loading