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

Commit c953766a authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

gd: ISO manager boilerplate

Bug: 150670922
Tag: #gd-refactor
Test: PTS tests will be added in upcoming patches
Change-Id: I01ff1091e17c40aebfcf3a0b1f977479574d8f24
parent 19113b6b
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -141,6 +141,7 @@ cc_defaults {
        ":BluetoothDumpsysSources",
        ":BluetoothHalSources",
        ":BluetoothHciSources",
        ":BluetoothIsoSources",
        ":BluetoothL2capSources",
        ":BluetoothNeighborSources",
        ":BluetoothPacketSources",
@@ -294,6 +295,7 @@ cc_test {
        ":BluetoothDumpsysTestSources",
        ":BluetoothHalTestSources",
        ":BluetoothHciTestSources",
        ":BluetoothIsoTestSources",
        ":BluetoothL2capTestSources",
        ":BluetoothNeighborTestSources",
        ":BluetoothPacketTestSources",
+8 −0
Original line number Diff line number Diff line
@@ -61,6 +61,10 @@ hci::LeScanningInterface* FuzzHciLayer::GetLeScanningInterface(
  return &le_scanning_interface_;
}

hci::LeIsoInterface* FuzzHciLayer::GetLeIsoInterface(ContextualCallback<void(hci::LeMetaEventView)> event_handler) {
  return &le_iso_interface_;
}

void FuzzHciLayer::Start() {
  acl_dev_null_ = new os::fuzz::DevNullQueue<AclPacketBuilder>(acl_queue_.GetDownEnd(), GetHandler());
  acl_dev_null_->Start();
@@ -179,6 +183,10 @@ void FuzzHciLayer::injectLeScanningEvent(std::vector<uint8_t> data) {
  InvokeIfValid<LeMetaEventView>(le_scanning_event_handler_, data);
}

void FuzzHciLayer::injectLeIsoEvent(std::vector<uint8_t> data) {
  InvokeIfValid<LeMetaEventView>(le_iso_event_handler_, data);
}

const ModuleFactory FuzzHciLayer::Factory = ModuleFactory([]() { return new FuzzHciLayer(); });

}  // namespace fuzz
+5 −0
Original line number Diff line number Diff line
@@ -115,6 +115,8 @@ class FuzzHciLayer : public HciLayer {
  hci::LeScanningInterface* GetLeScanningInterface(
      common::ContextualCallback<void(hci::LeMetaEventView)> event_handler) override;

  hci::LeIsoInterface* GetLeIsoInterface(common::ContextualCallback<void(LeMetaEventView)> event_handler) override;

  void injectArbitrary(FuzzedDataProvider& fdp);

  std::string ToString() const override {
@@ -148,6 +150,7 @@ class FuzzHciLayer : public HciLayer {
  void injectLeAdvertisingEvent(std::vector<uint8_t> data);

  void injectLeScanningEvent(std::vector<uint8_t> data);
  void injectLeIsoEvent(std::vector<uint8_t> data);

  FuzzedDataProvider* auto_reply_fdp;

@@ -161,6 +164,7 @@ class FuzzHciLayer : public HciLayer {
  FuzzCommandInterface<LeSecurityCommandBuilder> le_security_interface_{};
  FuzzCommandInterface<LeAdvertisingCommandBuilder> le_advertising_interface_{};
  FuzzCommandInterface<LeScanningCommandBuilder> le_scanning_interface_{};
  FuzzCommandInterface<LeIsoCommandBuilder> le_iso_interface_{};

  common::ContextualOnceCallback<void(hci::CommandCompleteView)> on_command_complete_;
  common::ContextualOnceCallback<void(hci::CommandStatusView)> on_command_status_;
@@ -176,6 +180,7 @@ class FuzzHciLayer : public HciLayer {
  common::ContextualCallback<void(uint16_t, hci::ErrorCode)> le_acl_on_disconnect_;
  common::ContextualCallback<void(hci::LeMetaEventView)> le_advertising_event_handler_;
  common::ContextualCallback<void(hci::LeMetaEventView)> le_scanning_event_handler_;
  common::ContextualCallback<void(hci::LeMetaEventView)> le_iso_event_handler_;
};

}  // namespace fuzz
+7 −0
Original line number Diff line number Diff line
@@ -405,6 +405,13 @@ LeScanningInterface* HciLayer::GetLeScanningInterface(ContextualCallback<void(Le
  return &le_scanning_interface;
}

LeIsoInterface* HciLayer::GetLeIsoInterface(ContextualCallback<void(LeMetaEventView)> event_handler) {
  for (const auto subevent : LeIsoEvents) {
    RegisterLeEventHandler(subevent, event_handler);
  }
  return &le_iso_interface;
}

const ModuleFactory HciLayer::Factory = ModuleFactory([]() { return new HciLayer(); });

void HciLayer::ListDependencies(ModuleList* list) {
+4 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#include "hci/hci_packets.h"
#include "hci/le_acl_connection_interface.h"
#include "hci/le_advertising_interface.h"
#include "hci/le_iso_interface.h"
#include "hci/le_scanning_interface.h"
#include "hci/le_security_interface.h"
#include "hci/security_interface.h"
@@ -82,6 +83,8 @@ class HciLayer : public Module, public CommandInterface<CommandPacketBuilder> {

  virtual LeScanningInterface* GetLeScanningInterface(common::ContextualCallback<void(LeMetaEventView)> event_handler);

  virtual LeIsoInterface* GetLeIsoInterface(common::ContextualCallback<void(LeMetaEventView)> event_handler);

  std::string ToString() const override {
    return "Hci Layer";
  }
@@ -138,6 +141,7 @@ class HciLayer : public Module, public CommandInterface<CommandPacketBuilder> {
  CommandInterfaceImpl<LeSecurityCommandBuilder> le_security_interface{*this};
  CommandInterfaceImpl<LeAdvertisingCommandBuilder> le_advertising_interface{*this};
  CommandInterfaceImpl<LeScanningCommandBuilder> le_scanning_interface{*this};
  CommandInterfaceImpl<LeIsoCommandBuilder> le_iso_interface{*this};
};
}  // namespace hci
}  // namespace bluetooth
Loading