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

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

RootCanal: Remove unused or trivial declarations

Bug: 279169336
Test: m root-canal
Change-Id: If79b5f7328a00ec711df1ff7ca641ab51e859509
parent 72075dec
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -68,9 +68,7 @@ class TestEnvironment {
        default_commands_file_(default_commands_file),
        enable_hci_sniffer_(enable_hci_sniffer),
        enable_baseband_sniffer_(enable_baseband_sniffer),
        enable_pcap_filter_(enable_pcap_filter),
        controller_(std::make_shared<rootcanal::DualModeController>(
            controller_properties_file)) {
        enable_pcap_filter_(enable_pcap_filter) {
    test_model_.SetReuseDeviceIds(!disable_address_reuse);
  }

@@ -100,8 +98,6 @@ class TestEnvironment {
  std::shared_ptr<Device> ConnectToRemoteServer(const std::string& server,
                                                int port, Phy::Type phy_type);

  std::shared_ptr<rootcanal::DualModeController> controller_;

  rootcanal::TestChannelTransport test_channel_transport_;
  rootcanal::TestChannelTransport remote_hci_transport_;
  rootcanal::TestChannelTransport remote_link_layer_transport_;
+22 −96
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ using std::vector;

namespace rootcanal {
constexpr uint16_t kNumCommandPackets = 0x01;
constexpr uint16_t kLeMaximumAdvertisingDataLength = 512;
constexpr uint16_t kLeMaximumDataLength = 64;
constexpr uint16_t kLeMaximumDataTime = 0x148;

@@ -61,11 +60,8 @@ void DualModeController::SendCommandCompleteUnknownOpCodeEvent(
          static_cast<uint8_t>(ErrorCode::UNKNOWN_HCI_COMMAND)})));
}

DualModeController::DualModeController(const std::string& properties_filename,
                                       uint16_t /*num_keys*/)
DualModeController::DualModeController(const std::string& properties_filename)
    : properties_(properties_filename) {
  loopback_mode_ = LoopbackMode::NO_LOOPBACK;

  Address public_address{};
  ASSERT(Address::FromString("3C:5A:B4:04:05:06", public_address));
  SetAddress(public_address);
@@ -77,6 +73,10 @@ DualModeController::DualModeController(const std::string& properties_filename,
      });
}

void DualModeController::ForwardToLm(CommandView command) {
  link_layer_controller_.ForwardToLm(command);
}

void DualModeController::SniffSubrating(CommandView command) {
  auto command_view = bluetooth::hci::SniffSubratingView::Create(command);
  ASSERT(command_view.IsValid());
@@ -797,53 +797,6 @@ void DualModeController::RejectSynchronousConnection(CommandView command) {
      status, kNumCommandPackets));
}

void DualModeController::IoCapabilityRequestReply(CommandView command) {
  link_layer_controller_.ForwardToLm(command);
}

void DualModeController::UserConfirmationRequestReply(CommandView command) {
  link_layer_controller_.ForwardToLm(command);
}

void DualModeController::UserConfirmationRequestNegativeReply(
    CommandView command) {
  link_layer_controller_.ForwardToLm(command);
}

void DualModeController::PinCodeRequestReply(CommandView command) {
  link_layer_controller_.ForwardToLm(command);
}

void DualModeController::PinCodeRequestNegativeReply(CommandView command) {
  link_layer_controller_.ForwardToLm(command);
}

void DualModeController::UserPasskeyRequestReply(CommandView command) {
  link_layer_controller_.ForwardToLm(command);
}

void DualModeController::UserPasskeyRequestNegativeReply(CommandView command) {
  link_layer_controller_.ForwardToLm(command);
}

void DualModeController::RemoteOobDataRequestReply(CommandView command) {
  link_layer_controller_.ForwardToLm(command);
}

void DualModeController::RemoteOobDataRequestNegativeReply(
    CommandView command) {
  link_layer_controller_.ForwardToLm(command);
}

void DualModeController::IoCapabilityRequestNegativeReply(CommandView command) {
  link_layer_controller_.ForwardToLm(command);
}

void DualModeController::RemoteOobExtendedDataRequestReply(
    CommandView command) {
  link_layer_controller_.ForwardToLm(command);
}

void DualModeController::ReadInquiryResponseTransmitPowerLevel(
    CommandView command) {
  auto command_view =
@@ -857,10 +810,6 @@ void DualModeController::ReadInquiryResponseTransmitPowerLevel(
          Create(kNumCommandPackets, ErrorCode::SUCCESS, tx_power));
}

void DualModeController::SendKeypressNotification(CommandView command) {
  link_layer_controller_.ForwardToLm(command);
}

void DualModeController::EnhancedFlush(CommandView command) {
  auto command_view = bluetooth::hci::EnhancedFlushView::Create(command);
  ASSERT(command_view.IsValid());
@@ -1004,14 +953,6 @@ void DualModeController::WriteInquiryScanType(CommandView command) {
      kNumCommandPackets, ErrorCode::SUCCESS));
}

void DualModeController::AuthenticationRequested(CommandView command) {
  link_layer_controller_.ForwardToLm(command);
}

void DualModeController::SetConnectionEncryption(CommandView command) {
  link_layer_controller_.ForwardToLm(command);
}

void DualModeController::ChangeConnectionLinkKey(CommandView command) {
  auto command_view =
      bluetooth::hci::ChangeConnectionLinkKeyView::Create(command);
@@ -1466,14 +1407,6 @@ void DualModeController::RejectConnectionRequest(CommandView command) {
      status, kNumCommandPackets));
}

void DualModeController::LinkKeyRequestReply(CommandView command) {
  link_layer_controller_.ForwardToLm(command);
}

void DualModeController::LinkKeyRequestNegativeReply(CommandView command) {
  link_layer_controller_.ForwardToLm(command);
}

void DualModeController::DeleteStoredLinkKey(CommandView command) {
  auto command_view = bluetooth::hci::DeleteStoredLinkKeyView::Create(command);
  ASSERT(command_view.IsValid());
@@ -2634,7 +2567,7 @@ void DualModeController::LeReadMaximumAdvertisingDataLength(
  send_event_(
      bluetooth::hci::LeReadMaximumAdvertisingDataLengthCompleteBuilder::Create(
          kNumCommandPackets, ErrorCode::SUCCESS,
          kLeMaximumAdvertisingDataLength));
          properties_.le_max_advertising_data_length));
}

void DualModeController::LeReadNumberOfSupportedAdvertisingSets(
@@ -3300,20 +3233,16 @@ const std::unordered_map<OpCode, DualModeController::CommandHandler>
         &DualModeController::AcceptConnectionRequest},
        {OpCode::REJECT_CONNECTION_REQUEST,
         &DualModeController::RejectConnectionRequest},
        {OpCode::LINK_KEY_REQUEST_REPLY,
         &DualModeController::LinkKeyRequestReply},
        {OpCode::LINK_KEY_REQUEST_REPLY, &DualModeController::ForwardToLm},
        {OpCode::LINK_KEY_REQUEST_NEGATIVE_REPLY,
         &DualModeController::LinkKeyRequestNegativeReply},
        {OpCode::PIN_CODE_REQUEST_REPLY,
         &DualModeController::PinCodeRequestReply},
         &DualModeController::ForwardToLm},
        {OpCode::PIN_CODE_REQUEST_REPLY, &DualModeController::ForwardToLm},
        {OpCode::PIN_CODE_REQUEST_NEGATIVE_REPLY,
         &DualModeController::PinCodeRequestNegativeReply},
         &DualModeController::ForwardToLm},
        {OpCode::CHANGE_CONNECTION_PACKET_TYPE,
         &DualModeController::ChangeConnectionPacketType},
        {OpCode::AUTHENTICATION_REQUESTED,
         &DualModeController::AuthenticationRequested},
        {OpCode::SET_CONNECTION_ENCRYPTION,
         &DualModeController::SetConnectionEncryption},
        {OpCode::AUTHENTICATION_REQUESTED, &DualModeController::ForwardToLm},
        {OpCode::SET_CONNECTION_ENCRYPTION, &DualModeController::ForwardToLm},
        {OpCode::CHANGE_CONNECTION_LINK_KEY,
         &DualModeController::ChangeConnectionLinkKey},
        {OpCode::CENTRAL_LINK_KEY, &DualModeController::CentralLinkKey},
@@ -3334,22 +3263,20 @@ const std::unordered_map<OpCode, DualModeController::CommandHandler>
         &DualModeController::AcceptSynchronousConnection},
        {OpCode::REJECT_SYNCHRONOUS_CONNECTION,
         &DualModeController::RejectSynchronousConnection},
        {OpCode::IO_CAPABILITY_REQUEST_REPLY,
         &DualModeController::IoCapabilityRequestReply},
        {OpCode::IO_CAPABILITY_REQUEST_REPLY, &DualModeController::ForwardToLm},
        {OpCode::USER_CONFIRMATION_REQUEST_REPLY,
         &DualModeController::UserConfirmationRequestReply},
         &DualModeController::ForwardToLm},
        {OpCode::USER_CONFIRMATION_REQUEST_NEGATIVE_REPLY,
         &DualModeController::UserConfirmationRequestNegativeReply},
        {OpCode::USER_PASSKEY_REQUEST_REPLY,
         &DualModeController::UserPasskeyRequestReply},
         &DualModeController::ForwardToLm},
        {OpCode::USER_PASSKEY_REQUEST_REPLY, &DualModeController::ForwardToLm},
        {OpCode::USER_PASSKEY_REQUEST_NEGATIVE_REPLY,
         &DualModeController::UserPasskeyRequestNegativeReply},
         &DualModeController::ForwardToLm},
        {OpCode::REMOTE_OOB_DATA_REQUEST_REPLY,
         &DualModeController::RemoteOobDataRequestReply},
         &DualModeController::ForwardToLm},
        {OpCode::REMOTE_OOB_DATA_REQUEST_NEGATIVE_REPLY,
         &DualModeController::RemoteOobDataRequestNegativeReply},
         &DualModeController::ForwardToLm},
        {OpCode::IO_CAPABILITY_REQUEST_NEGATIVE_REPLY,
         &DualModeController::IoCapabilityRequestNegativeReply},
         &DualModeController::ForwardToLm},
        {OpCode::ENHANCED_SETUP_SYNCHRONOUS_CONNECTION,
         &DualModeController::EnhancedSetupSynchronousConnection},
        {OpCode::ENHANCED_ACCEPT_SYNCHRONOUS_CONNECTION,
@@ -3366,7 +3293,7 @@ const std::unordered_map<OpCode, DualModeController::CommandHandler>
        //{OpCode::RECEIVE_SYNCHRONIZATION_TRAIN,
        //&DualModeController::ReceiveSynchronizationTrain},
        {OpCode::REMOTE_OOB_EXTENDED_DATA_REQUEST_REPLY,
         &DualModeController::RemoteOobExtendedDataRequestReply},
         &DualModeController::ForwardToLm},

        // LINK_POLICY
        {OpCode::HOLD_MODE, &DualModeController::HoldMode},
@@ -3492,8 +3419,7 @@ const std::unordered_map<OpCode, DualModeController::CommandHandler>
        //{OpCode::WRITE_DEFAULT_ERRONEOUS_DATA_REPORTING,
        //&DualModeController::WriteDefaultErroneousDataReporting},
        {OpCode::ENHANCED_FLUSH, &DualModeController::EnhancedFlush},
        {OpCode::SEND_KEYPRESS_NOTIFICATION,
         &DualModeController::SendKeypressNotification},
        {OpCode::SEND_KEYPRESS_NOTIFICATION, &DualModeController::ForwardToLm},
        {OpCode::SET_EVENT_MASK_PAGE_2, &DualModeController::SetEventMaskPage2},
        //{OpCode::READ_FLOW_CONTROL_MODE,
        //&DualModeController::ReadFlowControlMode},
+13 −67
Original line number Diff line number Diff line
@@ -48,24 +48,22 @@ using ::bluetooth::hci::CommandView;
// corresponding Bluetooth command in the Core Specification with the prefix
// "Hci" to distinguish it as a controller command.
class DualModeController : public Device {
  static constexpr uint16_t kSecurityManagerNumKeys = 15;

 public:
  // Sets all of the methods to be used as callbacks in the HciHandler.
  DualModeController(const std::string& properties_filename = "",
                     uint16_t num_keys = kSecurityManagerNumKeys);

  DualModeController(const std::string& properties_filename = "");
  DualModeController(DualModeController&&) = delete;
  DualModeController(const DualModeController&) = delete;
  ~DualModeController() = default;

  DualModeController& operator=(const DualModeController&) = delete;

  // Device methods.
  virtual std::string GetTypeString() const override;
  std::string GetTypeString() const override;

  virtual void ReceiveLinkLayerPacket(
      model::packets::LinkLayerPacketView incoming, Phy::Type type,
      int8_t rssi) override;
  void ReceiveLinkLayerPacket(model::packets::LinkLayerPacketView incoming,
                              Phy::Type type, int8_t rssi) override;

  virtual void Tick() override;
  virtual void Close() override;
  void Tick() override;
  void Close() override;

  // Route commands and data from the stack.
  void HandleAcl(std::shared_ptr<std::vector<uint8_t>> acl_packet);
@@ -120,27 +118,9 @@ class DualModeController : public Device {
  // 7.1.9
  void RejectConnectionRequest(CommandView command);

  // 7.1.10
  void LinkKeyRequestReply(CommandView command);

  // 7.1.11
  void LinkKeyRequestNegativeReply(CommandView command);

  // 7.1.12
  void PinCodeRequestReply(CommandView command);

  // 7.1.13
  void PinCodeRequestNegativeReply(CommandView command);

  // 7.1.14
  void ChangeConnectionPacketType(CommandView command);

  // 7.1.15
  void AuthenticationRequested(CommandView command);

  // 7.1.16
  void SetConnectionEncryption(CommandView command);

  // 7.1.17
  void ChangeConnectionLinkKey(CommandView command);

@@ -174,39 +154,12 @@ class DualModeController : public Device {
  // 7.1.28
  void RejectSynchronousConnection(CommandView command);

  // 7.1.29
  void IoCapabilityRequestReply(CommandView command);

  // 7.1.30
  void UserConfirmationRequestReply(CommandView command);

  // 7.1.31
  void UserConfirmationRequestNegativeReply(CommandView command);

  // 7.1.32
  void UserPasskeyRequestReply(CommandView command);

  // 7.1.33
  void UserPasskeyRequestNegativeReply(CommandView command);

  // 7.1.34
  void RemoteOobDataRequestReply(CommandView command);

  // 7.1.35
  void RemoteOobDataRequestNegativeReply(CommandView command);

  // 7.1.36
  void IoCapabilityRequestNegativeReply(CommandView command);

  // 7.1.45
  void EnhancedSetupSynchronousConnection(CommandView command);

  // 7.1.46
  void EnhancedAcceptSynchronousConnection(CommandView command);

  // 7.1.53
  void RemoteOobExtendedDataRequestReply(CommandView command);

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

@@ -354,9 +307,6 @@ class DualModeController : public Device {
  // 7.3.61
  void ReadInquiryResponseTransmitPowerLevel(CommandView command);

  // 7.3.63
  void SendKeypressNotification(CommandView command);

  // 7.3.66
  void EnhancedFlush(CommandView command);

@@ -624,9 +574,8 @@ class DualModeController : public Device {
  void CsrReadPskey(CsrPskey pskey, std::vector<uint8_t>& value);
  void CsrWritePskey(CsrPskey pskey, std::vector<uint8_t> const& value);

  void SetTimerPeriod(std::chrono::milliseconds new_period);
  void StartTimer();
  void StopTimer();
  // Command pass-through.
  void ForwardToLm(CommandView command);

 protected:
  // Controller configuration.
@@ -651,7 +600,7 @@ class DualModeController : public Device {
  // 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_;
  bluetooth::hci::LoopbackMode loopback_mode_{LoopbackMode::NO_LOOPBACK};

  // Map command opcodes to the corresponding bit index in the
  // supported command mask.
@@ -665,9 +614,6 @@ class DualModeController : public Device {
  using CommandHandler =
      std::function<void(DualModeController*, bluetooth::hci::CommandView)>;
  static const std::unordered_map<OpCode, CommandHandler> hci_command_handlers_;

  DualModeController(const DualModeController& other) = delete;
  DualModeController& operator=(const DualModeController& other) = delete;
};

}  // namespace rootcanal