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

Commit 7e36f462 authored by Łukasz Rymanowski (xWF)'s avatar Łukasz Rymanowski (xWF) Committed by Gerrit Code Review
Browse files

Merge "leaudio: Fix setting disconnecting state for ASEs" into main

parents 903b6570 0b4e3186
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -2946,6 +2946,11 @@ private:
      return CIS_STILL_NEEDED;
    }

    ase->cis_state = CisState::DISCONNECTING;
    if (bidirection_ase) {
      bidirection_ase->cis_state = CisState::DISCONNECTING;
    }

    group->RemoveCisFromStreamIfNeeded(leAudioDevice, ase->cis_conn_hdl);
    IsoManager::GetInstance()->DisconnectCis(ase->cis_conn_hdl, HCI_ERR_PEER_USER);
    log_history_->AddLogHistory(kLogStateMachineTag, group->group_id_, leAudioDevice->address_,
+48 −0
Original line number Diff line number Diff line
@@ -4920,6 +4920,54 @@ TEST_F(StateMachineTest, testStateTransitionTimeoutAndDisconnectWhenEnabling) {
  }
}

TEST_F(StateMachineTest, testInjectReleasingStateWhenEnabling) {
  const auto context_type = kContextTypeConversational;
  const int leaudio_group_id = 4;
  channel_count_ = kLeAudioCodecChannelCountSingleChannel;

  // Prepare fake connected device group
  auto* group = PrepareSingleTestDeviceGroup(leaudio_group_id, context_type);
  PrepareConfigureCodecHandler(group, 2);
  PrepareConfigureQosHandler(group, 2);
  PrepareEnableHandler(group, 0, true, false);

  InjectInitialConfiguredNotification(group);

  EXPECT_CALL(*mock_iso_manager_, CreateCig(_, _)).Times(1);
  EXPECT_CALL(*mock_iso_manager_, EstablishCis(_)).Times(1);
  EXPECT_CALL(*mock_iso_manager_, SetupIsoDataPath(_, _)).Times(0);
  EXPECT_CALL(*mock_iso_manager_, RemoveIsoDataPath(_, _)).Times(0);
  EXPECT_CALL(*mock_iso_manager_, DisconnectCis(_, _)).Times(0);
  EXPECT_CALL(*mock_iso_manager_, RemoveCig(_, _)).Times(0);

  // Stub Establish Cis and Remove CIG
  ON_CALL(*mock_iso_manager_, EstablishCis).WillByDefault(Return());
  ON_CALL(*mock_iso_manager_, RemoveCig).WillByDefault(Return());

  group->PrintDebugState();

  // Start the configuration and stream Media content
  ASSERT_TRUE(LeAudioGroupStateMachine::Get()->StartStream(
          group, context_type,
          {.sink = types::AudioContexts(context_type),
           .source = types::AudioContexts(context_type)}));

  testing::Mock::VerifyAndClearExpectations(mock_iso_manager_);

  group->PrintDebugState();

  log::info("Inject Release of all ASEs");

  EXPECT_CALL(*mock_iso_manager_, DisconnectCis(_, _)).Times(1);

  // Stub DisconnectCis to trigger the issue.
  ON_CALL(*mock_iso_manager_, DisconnectCis).WillByDefault(Return());

  InjectReleaseAndIdleStateForAGroup(group, true, false);

  testing::Mock::VerifyAndClearExpectations(mock_iso_manager_);
}

MATCHER_P(dataPathIsEq, expected, "") { return arg.data_path_id == expected; }

TEST_F(StateMachineTest, testConfigureDataPathForHost) {