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

Commit 78df72fe authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

leaudio: Make sure attached device has proper metadata (ccid)

Without this patch, late connected device would miss metadata
in the enable command

Bug: 231084798
Bug: 238961038
Bug: 239651157
Sponsor: @siyuanh
Test: atest BluetoothInstrumentationTests
Tag: #feature

Merged-In: I5ca3acb85f4c8db239fb204cbdac920b99eb875c
Change-Id: I5ca3acb85f4c8db239fb204cbdac920b99eb875c
(cherry picked from commit 2b229592)
parent d572cc91
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -560,6 +560,7 @@ cc_test {
        "le_audio/client_audio_test.cc",
        "le_audio/client_parser.cc",
        "le_audio/client_parser_test.cc",
        "le_audio/content_control_id_keeper.cc",
        "le_audio/devices.cc",
        "le_audio/devices_test.cc",
        "le_audio/le_audio_set_configuration_provider_json.cc",
+5 −1
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include "btm_iso_api.h"
#include "client_parser.h"
#include "codec_manager.h"
#include "content_control_id_keeper.h"
#include "devices.h"
#include "gd/common/strings.h"
#include "hcimsgs.h"
@@ -141,7 +142,10 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine {
      return false;
    }

    if (!group->Configure(group->GetContextType())) {
    auto context_type = group->GetCurrentContextType();
    auto ccid = le_audio::ContentControlIdKeeper::GetInstance()->GetCcid(
        static_cast<uint16_t>(context_type));
    if (!group->Configure(context_type, ccid)) {
      LOG_ERROR(" failed to set ASE configuration");
      return false;
    }
+10 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@

#include <functional>

#include "bta/le_audio/content_control_id_keeper.h"
#include "bta_gatt_api_mock.h"
#include "bta_gatt_queue_mock.h"
#include "btm_api_mock.h"
@@ -48,6 +49,11 @@ std::map<std::string, int> mock_function_count_map;

extern struct fake_osi_alarm_set_on_mloop fake_osi_alarm_set_on_mloop_;

constexpr uint8_t media_ccid = 0xC0;
constexpr auto media_context = static_cast<
    std::underlying_type<le_audio::types::LeAudioContextType>::type>(
    le_audio::types::LeAudioContextType::MEDIA);

namespace le_audio {
namespace internal {

@@ -166,6 +172,8 @@ class StateMachineTest : public Test {
    ::le_audio::AudioSetConfigurationProvider::Initialize();
    LeAudioGroupStateMachine::Initialize(&mock_callbacks_);

    ContentControlIdKeeper::GetInstance()->Start();

    // Support 2M Phy
    ON_CALL(mock_controller_, SupportsBle2mPhy()).WillByDefault(Return(true));
    ON_CALL(btm_interface, IsPhy2mSupported(_, _)).WillByDefault(Return(true));
@@ -2473,6 +2481,8 @@ TEST_F(StateMachineTest, testAttachDeviceToTheStream) {
  const auto leaudio_group_id = 6;
  const auto num_devices = 2;

  ContentControlIdKeeper::GetInstance()->SetCcid(media_context, media_ccid);

  // Prepare multiple fake connected devices in a group
  auto* group =
      PrepareSingleTestDeviceGroup(leaudio_group_id, context_type, num_devices);