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

Commit 974327ab authored by Henri Chataing's avatar Henri Chataing
Browse files

RootCanal: Use the Supported Commands mask as source of truth

DualModeController now distinguishes between
- supported commands: commands enabled in the supported commands mask
- implemented commands: commands for which an implementation is provided

Command are handled following this logic:
- implemented and supported command: registered handler invoked
- supported but not implemented command: raise an assert
- unsupported commands: send command complete which ERR_UNKNOWN_COMMAND

Test: m root-canal
Bug: 266087760
Change-Id: Ie930d368bd5c20d67fbc3a5f49f68763e12bfb50
parent e6a2920b
Loading
Loading
Loading
Loading
+559 −21

File changed.

Preview size limit exceeded, changes collapsed.

+9 −3
Original line number Diff line number Diff line
@@ -649,18 +649,24 @@ class DualModeController
  std::function<void(std::shared_ptr<bluetooth::hci::ScoBuilder>)> send_sco_;
  std::function<void(std::shared_ptr<bluetooth::hci::IsoBuilder>)> send_iso_;

  // Map supported opcodes to the function implementing the handler
  // Map all implemented opcodes to the function implementing the handler
  // for the associated command. The map should be a subset of the
  // supported_command field in the properties_ object.
  // supported_command field in the properties_ object. Commands
  // that are supported but not implemented will raise a fatal assert.
  std::unordered_map<bluetooth::hci::OpCode,
                     std::function<void(bluetooth::hci::CommandView)>>
      active_hci_commands_;
      hci_command_handlers_;

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

  // Map command opcodes to the corresponding bit index in the
  // supported command mask.
  static const std::unordered_map<OpCode, OpCodeIndex>
      hci_command_op_code_to_index_;

#ifndef ROOTCANAL_LMP
  SecurityManager security_manager_;
#endif /* ROOTCANAL_LMP */