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

Commit e638050e authored by Chienyuan's avatar Chienyuan
Browse files

RootCanal: Remove HciPacketBuilder and CommandPacketBuilder

Bug: 140386699
Test: run_cert.sh
Change-Id: I2bab335436d7dd9a9f205857f2fa9c9928a2443e
parent 542e7794
Loading
Loading
Loading
Loading
+204 −110

File changed.

Preview size limit exceeded, changes collapsed.

+116 −103
Original line number Diff line number Diff line
@@ -106,315 +106,326 @@ class DualModeController : public Device {
  // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.1

  // 7.1.1
  void HciInquiry(packets::PacketView<true> args);
  void HciInquiry(bluetooth::packet::PacketView<true> args);

  // 7.1.2
  void HciInquiryCancel(packets::PacketView<true> args);
  void HciInquiryCancel(bluetooth::packet::PacketView<true> args);

  // 7.1.5
  void HciCreateConnection(packets::PacketView<true> args);
  void HciCreateConnection(bluetooth::packet::PacketView<true> args);

  // 7.1.6
  void HciDisconnect(packets::PacketView<true> args);
  void HciDisconnect(bluetooth::packet::PacketView<true> args);

  // 7.1.8
  void HciAcceptConnectionRequest(packets::PacketView<true> args);
  void HciAcceptConnectionRequest(bluetooth::packet::PacketView<true> args);

  // 7.1.9
  void HciRejectConnectionRequest(packets::PacketView<true> args);
  void HciRejectConnectionRequest(bluetooth::packet::PacketView<true> args);

  // 7.1.10
  void HciLinkKeyRequestReply(packets::PacketView<true> args);
  void HciLinkKeyRequestReply(bluetooth::packet::PacketView<true> args);

  // 7.1.11
  void HciLinkKeyRequestNegativeReply(packets::PacketView<true> args);
  void HciLinkKeyRequestNegativeReply(bluetooth::packet::PacketView<true> args);

  // 7.1.14
  void HciChangeConnectionPacketType(packets::PacketView<true> args);
  void HciChangeConnectionPacketType(bluetooth::packet::PacketView<true> args);

  // 7.1.15
  void HciAuthenticationRequested(packets::PacketView<true> args);
  void HciAuthenticationRequested(bluetooth::packet::PacketView<true> args);

  // 7.1.16
  void HciSetConnectionEncryption(packets::PacketView<true> args);
  void HciSetConnectionEncryption(bluetooth::packet::PacketView<true> args);

  // 7.1.17
  void HciChangeConnectionLinkKey(packets::PacketView<true> args);
  void HciChangeConnectionLinkKey(bluetooth::packet::PacketView<true> args);

  // 7.1.18
  void HciMasterLinkKey(packets::PacketView<true> args);
  void HciMasterLinkKey(bluetooth::packet::PacketView<true> args);

  // 7.1.19
  void HciRemoteNameRequest(packets::PacketView<true> args);
  void HciRemoteNameRequest(bluetooth::packet::PacketView<true> args);

  // 7.2.8
  void HciSwitchRole(packets::PacketView<true> args);
  void HciSwitchRole(bluetooth::packet::PacketView<true> args);

  // 7.1.21
  void HciReadRemoteSupportedFeatures(packets::PacketView<true> args);
  void HciReadRemoteSupportedFeatures(bluetooth::packet::PacketView<true> args);

  // 7.1.22
  void HciReadRemoteExtendedFeatures(packets::PacketView<true> args);
  void HciReadRemoteExtendedFeatures(bluetooth::packet::PacketView<true> args);

  // 7.1.23
  void HciReadRemoteVersionInformation(packets::PacketView<true> args);
  void HciReadRemoteVersionInformation(
      bluetooth::packet::PacketView<true> args);

  // 7.1.24
  void HciReadClockOffset(packets::PacketView<true> args);
  void HciReadClockOffset(bluetooth::packet::PacketView<true> args);

  // 7.1.29
  void HciIoCapabilityRequestReply(packets::PacketView<true> args);
  void HciIoCapabilityRequestReply(bluetooth::packet::PacketView<true> args);

  // 7.1.30
  void HciUserConfirmationRequestReply(packets::PacketView<true> args);
  void HciUserConfirmationRequestReply(
      bluetooth::packet::PacketView<true> args);

  // 7.1.31
  void HciUserConfirmationRequestNegativeReply(packets::PacketView<true> args);
  void HciUserConfirmationRequestNegativeReply(
      bluetooth::packet::PacketView<true> args);

  // 7.1.32
  void HciUserPasskeyRequestReply(packets::PacketView<true> args);
  void HciUserPasskeyRequestReply(bluetooth::packet::PacketView<true> args);

  // 7.1.33
  void HciUserPasskeyRequestNegativeReply(packets::PacketView<true> args);
  void HciUserPasskeyRequestNegativeReply(
      bluetooth::packet::PacketView<true> args);

  // 7.1.34
  void HciRemoteOobDataRequestReply(packets::PacketView<true> args);
  void HciRemoteOobDataRequestReply(bluetooth::packet::PacketView<true> args);

  // 7.1.35
  void HciRemoteOobDataRequestNegativeReply(packets::PacketView<true> args);
  void HciRemoteOobDataRequestNegativeReply(
      bluetooth::packet::PacketView<true> args);

  // 7.1.36
  void HciIoCapabilityRequestNegativeReply(packets::PacketView<true> args);
  void HciIoCapabilityRequestNegativeReply(
      bluetooth::packet::PacketView<true> args);

  // Link Policy Commands
  // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.2

  // 7.2.1
  void HciHoldMode(packets::PacketView<true> args);
  void HciHoldMode(bluetooth::packet::PacketView<true> args);

  // 7.2.2
  void HciSniffMode(packets::PacketView<true> args);
  void HciSniffMode(bluetooth::packet::PacketView<true> args);

  // 7.2.3
  void HciExitSniffMode(packets::PacketView<true> args);
  void HciExitSniffMode(bluetooth::packet::PacketView<true> args);

  // 7.2.6
  void HciQosSetup(packets::PacketView<true> args);
  void HciQosSetup(bluetooth::packet::PacketView<true> args);

  // 7.2.10
  void HciWriteLinkPolicySettings(packets::PacketView<true> args);
  void HciWriteLinkPolicySettings(bluetooth::packet::PacketView<true> args);

  // 7.2.12
  void HciWriteDefaultLinkPolicySettings(packets::PacketView<true> args);
  void HciWriteDefaultLinkPolicySettings(
      bluetooth::packet::PacketView<true> args);

  // 7.2.13
  void HciFlowSpecification(packets::PacketView<true> args);
  void HciFlowSpecification(bluetooth::packet::PacketView<true> args);

  // 7.2.14
  void HciSniffSubrating(packets::PacketView<true> args);
  void HciSniffSubrating(bluetooth::packet::PacketView<true> args);

  // Link Controller Commands
  // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.3

  // 7.3.1
  void HciSetEventMask(packets::PacketView<true> args);
  void HciSetEventMask(bluetooth::packet::PacketView<true> args);

  // 7.3.2
  void HciReset(packets::PacketView<true> args);
  void HciReset(bluetooth::packet::PacketView<true> args);

  // 7.3.3
  void HciSetEventFilter(packets::PacketView<true> args);
  void HciSetEventFilter(bluetooth::packet::PacketView<true> args);

  // 7.3.10
  void HciDeleteStoredLinkKey(packets::PacketView<true> args);
  void HciDeleteStoredLinkKey(bluetooth::packet::PacketView<true> args);

  // 7.3.11
  void HciWriteLocalName(packets::PacketView<true> args);
  void HciWriteLocalName(bluetooth::packet::PacketView<true> args);

  // 7.3.12
  void HciReadLocalName(packets::PacketView<true> args);
  void HciReadLocalName(bluetooth::packet::PacketView<true> args);

  // 7.3.16
  void HciWritePageTimeout(packets::PacketView<true> args);
  void HciWritePageTimeout(bluetooth::packet::PacketView<true> args);

  // 7.3.18
  void HciWriteScanEnable(packets::PacketView<true> args);
  void HciWriteScanEnable(bluetooth::packet::PacketView<true> args);

  // 7.3.22
  void HciWriteInquiryScanActivity(packets::PacketView<true> args);
  void HciWriteInquiryScanActivity(bluetooth::packet::PacketView<true> args);

  // 7.3.23
  void HciReadAuthenticationEnable(packets::PacketView<true> args);
  void HciReadAuthenticationEnable(bluetooth::packet::PacketView<true> args);

  // 7.3.24
  void HciWriteAuthenticationEnable(packets::PacketView<true> args);
  void HciWriteAuthenticationEnable(bluetooth::packet::PacketView<true> args);

  // 7.3.26
  void HciWriteClassOfDevice(packets::PacketView<true> args);
  void HciWriteClassOfDevice(bluetooth::packet::PacketView<true> args);

  // 7.3.28
  void HciWriteVoiceSetting(packets::PacketView<true> args);
  void HciWriteVoiceSetting(bluetooth::packet::PacketView<true> args);

  // 7.3.39
  void HciHostBufferSize(packets::PacketView<true> args);
  void HciHostBufferSize(bluetooth::packet::PacketView<true> args);

  // 7.3.42
  void HciWriteLinkSupervisionTimeout(packets::PacketView<true> args);
  void HciWriteLinkSupervisionTimeout(bluetooth::packet::PacketView<true> args);

  // 7.3.45
  void HciWriteCurrentIacLap(packets::PacketView<true> args);
  void HciWriteCurrentIacLap(bluetooth::packet::PacketView<true> args);

  // 7.3.48
  void HciWriteInquiryScanType(packets::PacketView<true> args);
  void HciWriteInquiryScanType(bluetooth::packet::PacketView<true> args);

  // 7.3.50
  void HciWriteInquiryMode(packets::PacketView<true> args);
  void HciWriteInquiryMode(bluetooth::packet::PacketView<true> args);

  // 7.3.52
  void HciWritePageScanType(packets::PacketView<true> args);
  void HciWritePageScanType(bluetooth::packet::PacketView<true> args);

  // 7.3.56
  void HciWriteExtendedInquiryResponse(packets::PacketView<true> args);
  void HciWriteExtendedInquiryResponse(
      bluetooth::packet::PacketView<true> args);

  // 7.3.57
  void HciRefreshEncryptionKey(packets::PacketView<true> args);
  void HciRefreshEncryptionKey(bluetooth::packet::PacketView<true> args);

  // 7.3.59
  void HciWriteSimplePairingMode(packets::PacketView<true> args);
  void HciWriteSimplePairingMode(bluetooth::packet::PacketView<true> args);

  // 7.3.79
  void HciWriteLeHostSupport(packets::PacketView<true> args);
  void HciWriteLeHostSupport(bluetooth::packet::PacketView<true> args);

  // 7.3.92
  void HciWriteSecureConnectionsHostSupport(packets::PacketView<true> args);
  void HciWriteSecureConnectionsHostSupport(
      bluetooth::packet::PacketView<true> args);

  // Informational Parameters Commands
  // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.4

  // 7.4.5
  void HciReadBufferSize(packets::PacketView<true> args);
  void HciReadBufferSize(bluetooth::packet::PacketView<true> args);

  // 7.4.1
  void HciReadLocalVersionInformation(packets::PacketView<true> args);
  void HciReadLocalVersionInformation(bluetooth::packet::PacketView<true> args);

  // 7.4.6
  void HciReadBdAddr(packets::PacketView<true> args);
  void HciReadBdAddr(bluetooth::packet::PacketView<true> args);

  // 7.4.2
  void HciReadLocalSupportedCommands(packets::PacketView<true> args);
  void HciReadLocalSupportedCommands(bluetooth::packet::PacketView<true> args);

  // 7.4.3
  void HciReadLocalSupportedFeatures(packets::PacketView<true> args);
  void HciReadLocalSupportedFeatures(bluetooth::packet::PacketView<true> args);

  // 7.4.4
  void HciReadLocalExtendedFeatures(packets::PacketView<true> args);
  void HciReadLocalExtendedFeatures(bluetooth::packet::PacketView<true> args);

  // 7.4.8
  void HciReadLocalSupportedCodecs(packets::PacketView<true> args);
  void HciReadLocalSupportedCodecs(bluetooth::packet::PacketView<true> args);

  // Status Parameters Commands
  // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.5

  // 7.5.7
  void HciReadEncryptionKeySize(packets::PacketView<true> args);
  void HciReadEncryptionKeySize(bluetooth::packet::PacketView<true> args);

  // Test Commands
  // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.7

  // 7.7.1
  void HciReadLoopbackMode(packets::PacketView<true> args);
  void HciReadLoopbackMode(bluetooth::packet::PacketView<true> args);

  // 7.7.2
  void HciWriteLoopbackMode(packets::PacketView<true> args);
  void HciWriteLoopbackMode(bluetooth::packet::PacketView<true> args);

  // LE Controller Commands
  // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.8

  // 7.8.1
  void HciLeSetEventMask(packets::PacketView<true> args);
  void HciLeSetEventMask(bluetooth::packet::PacketView<true> args);

  // 7.8.2
  void HciLeReadBufferSize(packets::PacketView<true> args);
  void HciLeReadBufferSize(bluetooth::packet::PacketView<true> args);

  // 7.8.3
  void HciLeReadLocalSupportedFeatures(packets::PacketView<true> args);
  void HciLeReadLocalSupportedFeatures(
      bluetooth::packet::PacketView<true> args);

  // 7.8.4
  void HciLeSetRandomAddress(packets::PacketView<true> args);
  void HciLeSetRandomAddress(bluetooth::packet::PacketView<true> args);

  // 7.8.5
  void HciLeSetAdvertisingParameters(packets::PacketView<true> args);
  void HciLeSetAdvertisingParameters(bluetooth::packet::PacketView<true> args);

  // 7.8.7
  void HciLeSetAdvertisingData(packets::PacketView<true> args);
  void HciLeSetAdvertisingData(bluetooth::packet::PacketView<true> args);

  // 7.8.8
  void HciLeSetScanResponseData(packets::PacketView<true> args);
  void HciLeSetScanResponseData(bluetooth::packet::PacketView<true> args);

  // 7.8.9
  void HciLeSetAdvertisingEnable(packets::PacketView<true> args);
  void HciLeSetAdvertisingEnable(bluetooth::packet::PacketView<true> args);

  // 7.8.10
  void HciLeSetScanParameters(packets::PacketView<true> args);
  void HciLeSetScanParameters(bluetooth::packet::PacketView<true> args);

  // 7.8.11
  void HciLeSetScanEnable(packets::PacketView<true> args);
  void HciLeSetScanEnable(bluetooth::packet::PacketView<true> args);

  // 7.8.12
  void HciLeCreateConnection(packets::PacketView<true> args);
  void HciLeCreateConnection(bluetooth::packet::PacketView<true> args);

  // 7.8.18
  void HciLeConnectionUpdate(packets::PacketView<true> args);
  void HciLeConnectionUpdate(bluetooth::packet::PacketView<true> args);

  // 7.8.13
  void HciLeConnectionCancel(packets::PacketView<true> args);
  void HciLeConnectionCancel(bluetooth::packet::PacketView<true> args);

  // 7.8.14
  void HciLeReadWhiteListSize(packets::PacketView<true> args);
  void HciLeReadWhiteListSize(bluetooth::packet::PacketView<true> args);

  // 7.8.15
  void HciLeClearWhiteList(packets::PacketView<true> args);
  void HciLeClearWhiteList(bluetooth::packet::PacketView<true> args);

  // 7.8.16
  void HciLeAddDeviceToWhiteList(packets::PacketView<true> args);
  void HciLeAddDeviceToWhiteList(bluetooth::packet::PacketView<true> args);

  // 7.8.17
  void HciLeRemoveDeviceFromWhiteList(packets::PacketView<true> args);
  void HciLeRemoveDeviceFromWhiteList(bluetooth::packet::PacketView<true> args);

  // 7.8.21
  void HciLeReadRemoteFeatures(packets::PacketView<true> args);
  void HciLeReadRemoteFeatures(bluetooth::packet::PacketView<true> args);

  // 7.8.23
  void HciLeRand(packets::PacketView<true> args);
  void HciLeRand(bluetooth::packet::PacketView<true> args);

  // 7.8.24
  void HciLeStartEncryption(packets::PacketView<true> args);
  void HciLeStartEncryption(bluetooth::packet::PacketView<true> args);

  // 7.8.27
  void HciLeReadSupportedStates(packets::PacketView<true> args);
  void HciLeReadSupportedStates(bluetooth::packet::PacketView<true> args);

  // 7.8.38
  void HciLeAddDeviceToResolvingList(packets::PacketView<true> args);
  void HciLeAddDeviceToResolvingList(bluetooth::packet::PacketView<true> args);

  // 7.8.39
  void HciLeRemoveDeviceFromResolvingList(packets::PacketView<true> args);
  void HciLeRemoveDeviceFromResolvingList(
      bluetooth::packet::PacketView<true> args);

  // 7.8.40
  void HciLeClearResolvingList(packets::PacketView<true> args);
  void HciLeClearResolvingList(bluetooth::packet::PacketView<true> args);

  // 7.8.77
  void HciLeSetPrivacyMode(packets::PacketView<true> args);
  void HciLeSetPrivacyMode(bluetooth::packet::PacketView<true> args);

  // Vendor-specific Commands

  void HciLeVendorSleepMode(packets::PacketView<true> args);
  void HciLeVendorCap(packets::PacketView<true> args);
  void HciLeVendorMultiAdv(packets::PacketView<true> args);
  void HciLeVendor155(packets::PacketView<true> args);
  void HciLeVendor157(packets::PacketView<true> args);
  void HciLeEnergyInfo(packets::PacketView<true> args);
  void HciLeAdvertisingFilter(packets::PacketView<true> args);
  void HciLeExtendedScanParams(packets::PacketView<true> args);
  void HciLeVendorSleepMode(bluetooth::packet::PacketView<true> args);
  void HciLeVendorCap(bluetooth::packet::PacketView<true> args);
  void HciLeVendorMultiAdv(bluetooth::packet::PacketView<true> args);
  void HciLeVendor155(bluetooth::packet::PacketView<true> args);
  void HciLeVendor157(bluetooth::packet::PacketView<true> args);
  void HciLeEnergyInfo(bluetooth::packet::PacketView<true> args);
  void HciLeAdvertisingFilter(bluetooth::packet::PacketView<true> args);
  void HciLeExtendedScanParams(bluetooth::packet::PacketView<true> args);

  void SetTimerPeriod(std::chrono::milliseconds new_period);
  void StartTimer();
@@ -445,7 +456,9 @@ class DualModeController : public Device {
  // Maintains the commands to be registered and used in the HciHandler object.
  // Keys are command opcodes and values are the callbacks to handle each
  // command.
  std::unordered_map<uint16_t, std::function<void(packets::PacketView<true>)>> active_hci_commands_;
  std::unordered_map<uint16_t,
                     std::function<void(bluetooth::packet::PacketView<true>)>>
      active_hci_commands_;

  hci::LoopbackMode loopback_mode_;

+3 −5
Original line number Diff line number Diff line
@@ -19,9 +19,6 @@
#include "hci.h"
#include "include/le_advertisement.h"
#include "os/log.h"
#include "packets/hci/command_packet_view.h"
#include "packets/raw_builder.h"

#include "packet/raw_builder.h"

using std::vector;
@@ -61,7 +58,7 @@ void LinkLayerController::SendLinkLayerPacket(
}

bluetooth::hci::ErrorCode LinkLayerController::SendCommandToRemoteByAddress(
    bluetooth::hci::OpCode opcode, PacketView<true> args,
    bluetooth::hci::OpCode opcode, bluetooth::packet::PacketView<true> args,
    const Address& remote) {
  Address local_address = properties_.GetAddress();

@@ -104,7 +101,8 @@ bluetooth::hci::ErrorCode LinkLayerController::SendCommandToRemoteByAddress(
}

bluetooth::hci::ErrorCode LinkLayerController::SendCommandToRemoteByHandle(
    bluetooth::hci::OpCode opcode, PacketView<true> args, uint16_t handle) {
    bluetooth::hci::OpCode opcode, bluetooth::packet::PacketView<true> args,
    uint16_t handle) {
  // TODO: Handle LE connections
  if (!connections_.HasHandle(handle)) {
    return bluetooth::hci::ErrorCode::UNKNOWN_CONNECTION;
+2 −2
Original line number Diff line number Diff line
@@ -38,10 +38,10 @@ class LinkLayerController {

  LinkLayerController(const DeviceProperties& properties) : properties_(properties) {}
  bluetooth::hci::ErrorCode SendCommandToRemoteByAddress(
      bluetooth::hci::OpCode opcode, packets::PacketView<true> args,
      bluetooth::hci::OpCode opcode, bluetooth::packet::PacketView<true> args,
      const Address& remote);
  bluetooth::hci::ErrorCode SendCommandToRemoteByHandle(
      bluetooth::hci::OpCode opcode, packets::PacketView<true> args,
      bluetooth::hci::OpCode opcode, bluetooth::packet::PacketView<true> args,
      uint16_t handle);
  hci::Status SendScoToRemote(bluetooth::hci::ScoPacketView sco_packet);
  hci::Status SendAclToRemote(bluetooth::hci::AclPacketView acl_packet);
+0 −3
Original line number Diff line number Diff line
@@ -14,9 +14,6 @@ cc_library_static {
        "packet_view.cc",
        "raw_builder.cc",
        "view.cc",
        "hci/command_packet_builder.cc",
        "hci/command_packet_view.cc",
        "hci/hci_packet_builder.cc",
    ],
    cflags: [
        "-fvisibility=hidden",
Loading