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

Commit 46ef4fea authored by Henri Chataing's avatar Henri Chataing Committed by Automerger Merge Worker
Browse files

Merge "RootCanal: Register an handler for invalid packets in...

Merge "RootCanal: Register an handler for invalid packets in DualModeController" into main am: bb5f78f8

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2972253



Change-Id: I9d07a4a57bf8124ba5e0cecdf88d7f88e6693058
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 125ddb81 bb5f78f8
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -237,6 +237,13 @@ void DualModeController::HandleCommand(
  }
}

void DualModeController::RegisterInvalidPacketHandler(
    std::function<void(uint32_t, InvalidPacketReason, std::string,
                       std::vector<uint8_t> const&)>& handler) {
  INFO(id_, "updating the invalid packet handler");
  invalid_packet_handler_ = handler;
}

void DualModeController::RegisterEventChannel(
    const std::function<void(std::shared_ptr<std::vector<uint8_t>>)>&
        send_event) {
+19 −0
Original line number Diff line number Diff line
@@ -40,6 +40,13 @@ namespace rootcanal {
using ::bluetooth::hci::Address;
using ::bluetooth::hci::CommandView;

// List of reject reasons for invalid packets.
enum InvalidPacketReason {
  kUnknown = 0,
  kParseError = 1,
  kUnsupported = 2,
};

// Emulates a dual mode BR/EDR + LE controller by maintaining the link layer
// state machine detailed in the Bluetooth Core Specification Version 4.2,
// Volume 6, Part B, Section 1.1 (page 30). Provides methods corresponding to
@@ -78,6 +85,13 @@ class DualModeController : public Device {
  void HandleSco(std::shared_ptr<std::vector<uint8_t>> sco_packet);
  void HandleIso(std::shared_ptr<std::vector<uint8_t>> iso_packet);

  /// Report invalid packets received for this controller instance
  /// to an external tracker. Packets are rejected if they failed to
  /// be parsed, or run into an unimplemented part of the controller.
  void RegisterInvalidPacketHandler(
      std::function<void(uint32_t, InvalidPacketReason, std::string,
                         std::vector<uint8_t> const&)>& handler);

  // Set the callbacks for sending packets to the HCI.
  void RegisterEventChannel(
      const std::function<void(std::shared_ptr<std::vector<uint8_t>>)>&
@@ -546,6 +560,11 @@ class DualModeController : public Device {
  std::function<void(std::shared_ptr<bluetooth::hci::ScoBuilder>)> send_sco_;
  std::function<void(std::shared_ptr<bluetooth::hci::IsoBuilder>)> send_iso_;

  // Report invalid packets received on this controller instance.
  std::function<void(uint32_t, InvalidPacketReason, std::string,
                     std::vector<uint8_t> const&)>
      invalid_packet_handler_;

  // Loopback mode (Vol 4, Part E § 7.6.1).
  // The local loopback mode is used to pass the android Vendor Test Suite
  // with RootCanal.