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

Commit 05d604c9 authored by Calvin Huang's avatar Calvin Huang
Browse files

RootCanal:Add Hci cmds

Add HciReadEncryptionKeySize and HciWriteSecureConnectionHostSupport

Bug: 138260499
Test: run run_device_cert.sh
Change-Id: Icd49a9e0b3fbbbeedf180946a8ba4801ea18a2b8
parent b16c44c5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
{
  "AclDataPacketSize": "1024",
  "EncryptionKeySize": "10",
  "ScoDataPacketSize": "255",
  "NumAclDataPackets": "10",
  "NumScoDataPackets": "10",
+22 −0
Original line number Diff line number Diff line
@@ -121,6 +121,7 @@ DualModeController::DualModeController(const std::string& properties_filename, u
  SET_HANDLER(OpCode::READ_BUFFER_SIZE, HciReadBufferSize);
  SET_HANDLER(OpCode::HOST_BUFFER_SIZE, HciHostBufferSize);
  SET_HANDLER(OpCode::SNIFF_SUBRATING, HciSniffSubrating);
  SET_HANDLER(OpCode::READ_ENCRYPTION_KEY_SIZE, HciReadEncryptionKeySize);
  SET_HANDLER(OpCode::READ_LOCAL_VERSION_INFORMATION, HciReadLocalVersionInformation);
  SET_HANDLER(OpCode::READ_BD_ADDR, HciReadBdAddr);
  SET_HANDLER(OpCode::READ_LOCAL_SUPPORTED_COMMANDS, HciReadLocalSupportedCommands);
@@ -137,6 +138,8 @@ DualModeController::DualModeController(const std::string& properties_filename, u
  SET_HANDLER(OpCode::IO_CAPABILITY_REQUEST_NEGATIVE_REPLY, HciIoCapabilityRequestNegativeReply);
  SET_HANDLER(OpCode::WRITE_SIMPLE_PAIRING_MODE, HciWriteSimplePairingMode);
  SET_HANDLER(OpCode::WRITE_LE_HOST_SUPPORT, HciWriteLeHostSupport);
  SET_HANDLER(OpCode::WRITE_SECURE_CONNECTIONS_HOST_SUPPORT,
              HciWriteSecureConnectionHostSupport);
  SET_HANDLER(OpCode::SET_EVENT_MASK, HciSetEventMask);
  SET_HANDLER(OpCode::WRITE_INQUIRY_MODE, HciWriteInquiryMode);
  SET_HANDLER(OpCode::WRITE_PAGE_SCAN_TYPE, HciWritePageScanType);
@@ -312,6 +315,19 @@ void DualModeController::HciReadBufferSize(packets::PacketView<true> args) {
  send_event_(command_complete->ToVector());
}

void DualModeController::HciReadEncryptionKeySize(
    packets::PacketView<true> args) {
  ASSERT_LOG(args.size() == 2, "%s  size=%zu", __func__, args.size());

  uint16_t handle = args.begin().extract<uint16_t>();

  std::shared_ptr<packets::EventPacketBuilder> command_complete =
      packets::EventPacketBuilder::CreateCommandCompleteReadEncryptionKeySize(
          hci::Status::SUCCESS, handle, properties_.GetEncryptionKeySize());

  send_event_(command_complete->ToVector());
}

void DualModeController::HciHostBufferSize(packets::PacketView<true> args) {
  ASSERT_LOG(args.size() == 7, "%s  size=%zu", __func__, args.size());
  SendCommandCompleteSuccess(OpCode::HOST_BUFFER_SIZE);
@@ -540,6 +556,12 @@ void DualModeController::HciWriteLeHostSupport(packets::PacketView<true> args) {
  SendCommandCompleteSuccess(OpCode::WRITE_LE_HOST_SUPPORT);
}

void DualModeController::HciWriteSecureConnectionHostSupport(
    packets::PacketView<true> args) {
  ASSERT_LOG(args.size() == 1, "%s  size=%zu", __func__, args.size());
  SendCommandCompleteSuccess(OpCode::WRITE_SECURE_CONNECTIONS_HOST_SUPPORT);
}

void DualModeController::HciSetEventMask(packets::PacketView<true> args) {
  ASSERT_LOG(args.size() == 8, "%s  size=%zu", __func__, args.size());
  SendCommandCompleteSuccess(OpCode::SET_EVENT_MASK);
+6 −0
Original line number Diff line number Diff line
@@ -271,6 +271,9 @@ class DualModeController : public Device {
  // 7.3.79
  void HciWriteLeHostSupport(packets::PacketView<true> args);

  // 7.3.92
  void HciWriteSecureConnectionHostSupport(packets::PacketView<true> args);

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

@@ -298,6 +301,9 @@ class DualModeController : public Device {
  // Status Parameters Commands
  // Bluetooth Core Specification Version 4.2 Volume 2 Part E 7.5

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

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

+1 −0
Original line number Diff line number Diff line
@@ -97,6 +97,7 @@ void DeviceProperties::RegisterJSONConverter(base::JSONValueConverter<DeviceProp
  converter->RegisterCustomField<uint16_t>(field_name, &DeviceProperties::field, &ParseUint16t);
  REGISTER_UINT16_T("AclDataPacketSize", acl_data_packet_size_);
  REGISTER_UINT8_T("ScoDataPacketSize", sco_data_packet_size_);
  REGISTER_UINT8_T("EncryptionKeySize", encryption_key_size_);
  REGISTER_UINT16_T("NumAclDataPackets", num_acl_data_packets_);
  REGISTER_UINT16_T("NumScoDataPackets", num_sco_data_packets_);
  REGISTER_UINT8_T("Version", version_);
+3 −0
Original line number Diff line number Diff line
@@ -69,6 +69,8 @@ class DeviceProperties {
    return sco_data_packet_size_;
  }

  uint8_t GetEncryptionKeySize() const { return encryption_key_size_; }

  uint16_t GetTotalNumAclDataPackets() const {
    return num_acl_data_packets_;
  }
@@ -310,6 +312,7 @@ class DeviceProperties {
  Address address_;
  uint8_t page_scan_repetition_mode_;
  uint16_t clock_offset_;
  uint8_t encryption_key_size_;

  // Low Energy
  uint16_t le_data_packet_length_;
Loading