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

Commit 974d0272 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

leaudio: Improve inactivating group in error case

With this patch test code is improved to make sure that AF is stopped
from bluetooth side when device got inactivated due to error.

Also minor fix is added to clear the active group in the end of the
groupSetAndNotifyInactive.

Bug: 339801164
Test: atest bluetooth_le_audio_client_test
Flag: Exempt, trivial fix, regression tested with unit tests.
Change-Id: Idf1761615fba746013416d856e6d4c95abe048c2
parent 25ee8699
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -1222,16 +1222,16 @@ class LeAudioClientImpl : public LeAudioClient {
    if (active_group_id_ == bluetooth::groups::kGroupUnknown) {
      return;
    }
    auto group_id_to_close = active_group_id_;
    active_group_id_ = bluetooth::groups::kGroupUnknown;
    sink_monitor_notified_status_ = std::nullopt;
    log::info("Group id: {}", active_group_id_);

    log::info("Group id: {}", group_id_to_close);
    if (alarm_is_scheduled(suspend_timeout_)) alarm_cancel(suspend_timeout_);

    StopAudio();
    ClientAudioInterfaceRelease();
    callbacks_->OnGroupStatus(group_id_to_close, GroupStatus::INACTIVE);

    callbacks_->OnGroupStatus(active_group_id_, GroupStatus::INACTIVE);
    active_group_id_ = bluetooth::groups::kGroupUnknown;
  }

  void GroupSetActive(const int group_id) override {
+7 −1
Original line number Diff line number Diff line
@@ -5145,13 +5145,17 @@ TEST_F(UnicastTest, InactiveDeviceOnInternalStateMachineError) {

  SyncOnMainLoop();
  Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_);
  Mock::VerifyAndClearExpectations(&mock_le_audio_source_hal_client_);
  Mock::VerifyAndClearExpectations(mock_le_audio_source_hal_client_);
  Mock::VerifyAndClearExpectations(mock_le_audio_sink_hal_client_);
  Mock::VerifyAndClearExpectations(&mock_state_machine_);
  SyncOnMainLoop();

  // Verify Data transfer on one audio source cis
  TestAudioDataTransfer(group_id, cis_count_out, cis_count_in, 1920);

  EXPECT_CALL(*mock_le_audio_source_hal_client_, Stop()).Times(1);
  EXPECT_CALL(*mock_le_audio_sink_hal_client_, Stop()).Times(1);

  EXPECT_CALL(mock_audio_hal_client_callbacks_,
              OnGroupStatus(group_id, GroupStatus::INACTIVE))
      .Times(1);
@@ -5162,6 +5166,8 @@ TEST_F(UnicastTest, InactiveDeviceOnInternalStateMachineError) {

  SyncOnMainLoop();
  Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_);
  Mock::VerifyAndClearExpectations(mock_le_audio_source_hal_client_);
  Mock::VerifyAndClearExpectations(mock_le_audio_sink_hal_client_);
}

TEST_F(UnicastTest, GroupingAddTwiceNoRemove) {