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

Commit de42f44b authored by Yuyang Huang's avatar Yuyang Huang
Browse files

Add Read Local Supported Codecs command

Bug: 280972672
Test: atest --host bluetooth_test_gd_unit
Change-Id: I8d09730de4209d48f165eeb908a8e4a8b706a101
parent 4cb692cb
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -96,6 +96,12 @@ struct Controller::impl {
          handler->BindOnceOn(this, &Controller::impl::le_read_buffer_size_handler));
    }

    if (is_supported(OpCode::READ_LOCAL_SUPPORTED_CODECS_V1)) {
      hci_->EnqueueCommand(
          ReadLocalSupportedCodecsV1Builder::Create(),
          handler->BindOnceOn(this, &Controller::impl::read_local_supported_codecs_v1_handler));
    }

    hci_->EnqueueCommand(
        LeReadFilterAcceptListSizeBuilder::Create(),
        handler->BindOnceOn(this, &Controller::impl::le_read_connect_list_size_handler));
@@ -355,6 +361,16 @@ struct Controller::impl {
    }
  }

  void read_local_supported_codecs_v1_handler(CommandCompleteView view) {
    auto complete_view = ReadLocalSupportedCodecsV1CompleteView::Create(view);
    ASSERT(complete_view.IsValid());
    ErrorCode status = complete_view.GetStatus();
    ASSERT_LOG(
        status == ErrorCode::SUCCESS, "Status 0x%02hhx, %s", status, ErrorCodeText(status).c_str());
    local_supported_codec_ids_ = complete_view.GetSupportedCodecs();
    local_supported_vendor_codec_ids_ = complete_view.GetVendorSpecificCodecs();
  }

  void set_min_encryption_key_size_handler(CommandCompleteView view) {
    auto complete_view = SetMinEncryptionKeySizeCompleteView::Create(view);
    ASSERT(complete_view.IsValid());
@@ -1065,6 +1081,8 @@ struct Controller::impl {
  Address mac_address_{};
  std::string local_name_{};
  LeBufferSize le_buffer_size_{};
  std::vector<uint8_t> local_supported_codec_ids_{};
  std::vector<uint32_t> local_supported_vendor_codec_ids_{};
  LeBufferSize iso_buffer_size_{};
  uint64_t le_local_supported_features_{};
  uint64_t le_supported_states_{};
@@ -1106,6 +1124,10 @@ LocalVersionInformation Controller::GetLocalVersionInformation() const {
  return impl_->local_version_information_;
}

std::vector<uint8_t> Controller::GetLocalSupportedBrEdrCodecIds() const {
  return impl_->local_supported_codec_ids_;
}

#define BIT(x) (0x1ULL << (x))

#define LOCAL_FEATURE_ACCESSOR(name, page, bit) \
+3 −0
Original line number Diff line number Diff line
@@ -184,6 +184,9 @@ class Controller : public Module {

  virtual uint8_t GetLePeriodicAdvertiserListSize() const;

  // 7.4.8 Read Local Supported Codecs command v1 only returns codecs on the BR/EDR transport
  virtual std::vector<uint8_t> GetLocalSupportedBrEdrCodecIds() const;

  struct VendorCapabilities {
    uint8_t is_supported_;
    uint8_t max_advt_instances_;
+7 −0
Original line number Diff line number Diff line
@@ -112,6 +112,12 @@ class TestHciLayer : public HciLayer {
        event_builder =
            ReadLocalSupportedCommandsCompleteBuilder::Create(num_packets, ErrorCode::SUCCESS, supported_commands);
      } break;
      case (OpCode::READ_LOCAL_SUPPORTED_CODECS_V1): {
        std::vector<uint8_t> supported_codecs{0, 1, 2, 3, 4, 5, 6};
        std::vector<uint32_t> supported_vendor_codecs;
        event_builder = ReadLocalSupportedCodecsV1CompleteBuilder::Create(
            num_packets, ErrorCode::SUCCESS, supported_codecs, supported_vendor_codecs);
      } break;
      case (OpCode::READ_LOCAL_EXTENDED_FEATURES): {
        ReadLocalExtendedFeaturesView read_command = ReadLocalExtendedFeaturesView::Create(command);
        ASSERT_TRUE(read_command.IsValid());
@@ -354,6 +360,7 @@ TEST_F(ControllerTest, read_controller_info) {
  ASSERT_EQ(controller_->GetLeMaximumDataLength().supported_max_rx_time_, 0x78);
  ASSERT_EQ(controller_->GetLeMaximumAdvertisingDataLength(), 0x0672);
  ASSERT_EQ(controller_->GetLeNumberOfSupportedAdverisingSets(), 0xF0);
  ASSERT_TRUE(controller_->GetLocalSupportedBrEdrCodecIds().size() > 0);
}

TEST_F(ControllerTest, read_write_local_name) {