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

Commit f3bd6d54 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

leaudio: Fix late CIS disconnect scenario.

During stopping the stream, when remote device supports caching, and
when CIS got disconnected after ASE goes into Configured state, the
state machine will wait for CIS disconnection and notify upper layer
about state.

Before this patch, in such scenario, CONFIGURED_BY_USER state could be
used which is incorrect, as this state can be used only when CISes are
not yet created. That would lead to missing SuspendedForReconfiguration
call from the client.cc

Bug: 281954121
Test: atest BluetoothInstrumentationTests
Test: atest bluetooth_le_audio_test
Tag: #feature
Change-Id: If5be7ccdc6c13564865b87261f0e09640dc1221a
parent 3c6d20f2
Loading
Loading
Loading
Loading
+5 −11
Original line number Original line Diff line number Diff line
@@ -985,11 +985,6 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine {
              "state, reconfig=%d.",
              "state, reconfig=%d.",
              group->group_id_, reconfig);
              group->group_id_, reconfig);


          if (reconfig) {
            group->ClearPendingConfiguration();
            state_machine_callbacks_->StatusReportCb(
                group->group_id_, GroupStreamStatus::CONFIGURED_BY_USER);
          } else {
          /* This is Autonomous change if both, target and current state
          /* This is Autonomous change if both, target and current state
           * is CODEC_CONFIGURED
           * is CODEC_CONFIGURED
           */
           */
@@ -998,7 +993,6 @@ class LeAudioGroupStateMachineImpl : public LeAudioGroupStateMachine {
                group->group_id_, GroupStreamStatus::CONFIGURED_AUTONOMOUS);
                group->group_id_, GroupStreamStatus::CONFIGURED_AUTONOMOUS);
          }
          }
        }
        }
        }
        RemoveCigForGroup(group);
        RemoveCigForGroup(group);
      } break;
      } break;
      default:
      default:
+11 −9
Original line number Original line Diff line number Diff line
@@ -3884,7 +3884,7 @@ TEST_F(StateMachineTest, BoundedHeadphonesConversationalToMediaChannelCount_1) {
  ASSERT_EQ(1, get_func_call_count("alarm_cancel"));
  ASSERT_EQ(1, get_func_call_count("alarm_cancel"));
}
}


TEST_F(StateMachineTest, lateCisDisconnectedEvent_ConfiguredByUser) {
TEST_F(StateMachineTest, lateCisDisconnectedEvent_DuringReconfiguration) {
  const auto context_type = kContextTypeMedia;
  const auto context_type = kContextTypeMedia;
  const auto leaudio_group_id = 6;
  const auto leaudio_group_id = 6;
  const auto num_devices = 1;
  const auto num_devices = 1;
@@ -3950,10 +3950,11 @@ TEST_F(StateMachineTest, lateCisDisconnectedEvent_ConfiguredByUser) {
      StatusReportCb(leaudio_group_id,
      StatusReportCb(leaudio_group_id,
                     bluetooth::le_audio::GroupStreamStatus::RELEASING));
                     bluetooth::le_audio::GroupStreamStatus::RELEASING));


  EXPECT_CALL(mock_callbacks_,
  EXPECT_CALL(
      mock_callbacks_,
      StatusReportCb(
      StatusReportCb(
          leaudio_group_id,
          leaudio_group_id,
                  bluetooth::le_audio::GroupStreamStatus::CONFIGURED_BY_USER))
          bluetooth::le_audio::GroupStreamStatus::CONFIGURED_AUTONOMOUS))
      .Times(0);
      .Times(0);
  LeAudioGroupStateMachine::Get()->StopStream(group);
  LeAudioGroupStateMachine::Get()->StopStream(group);


@@ -3961,10 +3962,11 @@ TEST_F(StateMachineTest, lateCisDisconnectedEvent_ConfiguredByUser) {


  ASSERT_EQ(0, get_func_call_count("alarm_cancel"));
  ASSERT_EQ(0, get_func_call_count("alarm_cancel"));


  EXPECT_CALL(mock_callbacks_,
  EXPECT_CALL(
      mock_callbacks_,
      StatusReportCb(
      StatusReportCb(
          leaudio_group_id,
          leaudio_group_id,
                  bluetooth::le_audio::GroupStreamStatus::CONFIGURED_BY_USER));
          bluetooth::le_audio::GroupStreamStatus::CONFIGURED_AUTONOMOUS));


  // Inject CIS and ACL disconnection of first device
  // Inject CIS and ACL disconnection of first device
  InjectCisDisconnected(group, leAudioDevice, HCI_ERR_CONN_CAUSE_LOCAL_HOST);
  InjectCisDisconnected(group, leAudioDevice, HCI_ERR_CONN_CAUSE_LOCAL_HOST);