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

Commit 39ad1b7f authored by Jakub Tyszkowski's avatar Jakub Tyszkowski
Browse files

LeAudio: Fix checking for valid configs

When a certain configuration availability changes,
configuration ponter is set to null.

Bug: 281686787
Test: atest bluetooth_le_audio_test
Change-Id: I4bebe861f199d6cda36b4e67021e6993555ca9c7
parent 6efb65ca
Loading
Loading
Loading
Loading
+5 −4
Original line number Original line Diff line number Diff line
@@ -1801,10 +1801,11 @@ LeAudioDeviceGroup::GetCodecConfigurationByDirection(


bool LeAudioDeviceGroup::IsAudioSetConfigurationAvailable(
bool LeAudioDeviceGroup::IsAudioSetConfigurationAvailable(
    types::LeAudioContextType group_context_type) const {
    types::LeAudioContextType group_context_type) const {
  auto iter = available_context_to_configuration_map.find(group_context_type);
  if (available_context_to_configuration_map.count(group_context_type) != 0) {
  if (iter == available_context_to_configuration_map.end()) return false;
    return available_context_to_configuration_map.at(group_context_type) !=

           nullptr;
  return available_context_to_configuration_map.count(group_context_type) != 0;
  }
  return false;
}
}


bool LeAudioDeviceGroup::IsMetadataChanged(
bool LeAudioDeviceGroup::IsMetadataChanged(
+4 −0
Original line number Original line Diff line number Diff line
@@ -1041,6 +1041,8 @@ TEST_F(LeAudioAseConfigurationTest, test_context_update) {
  ASSERT_TRUE(config.has_value());
  ASSERT_TRUE(config.has_value());
  ASSERT_EQ(config->num_channels,
  ASSERT_EQ(config->num_channels,
            ::le_audio::LeAudioCodecConfiguration::kChannelNumberMono);
            ::le_audio::LeAudioCodecConfiguration::kChannelNumberMono);
  ASSERT_TRUE(
      group_->IsAudioSetConfigurationAvailable(LeAudioContextType::ALERTS));


  /* Block the ALERTS context */
  /* Block the ALERTS context */
  right->SetAvailableContexts(
  right->SetAvailableContexts(
@@ -1055,6 +1057,8 @@ TEST_F(LeAudioAseConfigurationTest, test_context_update) {
                       LeAudioContextType::ALERTS,
                       LeAudioContextType::ALERTS,
                       ::le_audio::types::kLeAudioDirectionSink)
                       ::le_audio::types::kLeAudioDirectionSink)
                   .has_value());
                   .has_value());
  ASSERT_FALSE(
      group_->IsAudioSetConfigurationAvailable(LeAudioContextType::ALERTS));
}
}


TEST_F(LeAudioAseConfigurationTest, test_mono_speaker_ringtone) {
TEST_F(LeAudioAseConfigurationTest, test_mono_speaker_ringtone) {