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

Commit 3996a0cf authored by Grzegorz Kołodziejczyk's avatar Grzegorz Kołodziejczyk
Browse files

le_audio: Allow broadcast handover fallback device clear

With this change there is possibile clearance of fallback group id in
case if active LE Audio unicast device would change to null.

Tag: #Bug
Bug: 338341279
Test: atest LeAudioServiceTest
Flag: Exempt, simple fix
Change-Id: I07a645493b7f05ae8811650eb205683bb91408e4
parent e513f9e0
Loading
Loading
Loading
Loading
+16 −3
Original line number Diff line number Diff line
@@ -2124,17 +2124,30 @@ public class LeAudioService extends ProfileService {
                        + ", mExposedActiveDevice: "
                        + mExposedActiveDevice);

        LeAudioGroupDescriptor groupDescriptor = getGroupDescriptor(currentlyActiveGroupId);
        if (isBroadcastActive()
                && currentlyActiveGroupId == LE_AUDIO_GROUP_ID_INVALID
                && mUnicastGroupIdDeactivatedForBroadcastTransition != LE_AUDIO_GROUP_ID_INVALID
                && groupId != LE_AUDIO_GROUP_ID_INVALID) {
                && mUnicastGroupIdDeactivatedForBroadcastTransition != LE_AUDIO_GROUP_ID_INVALID) {
            // If broadcast is ongoing and need to update unicast fallback active group
            // we need to update the cached group id and skip changing the active device
            updateFallbackUnicastGroupIdForBroadcast(groupId);

            /* In case of removing fallback unicast group, monitoring input device should be
             * removed from active devices.
             */
            if (groupDescriptor != null && groupId == LE_AUDIO_GROUP_ID_INVALID) {
                updateActiveDevices(
                        groupId,
                        groupDescriptor.mDirection,
                        AUDIO_DIRECTION_NONE,
                        false,
                        groupDescriptor.mHasFallbackDeviceWhenGettingInactive,
                        false);
            }

            return true;
        }

        LeAudioGroupDescriptor groupDescriptor = getGroupDescriptor(currentlyActiveGroupId);
        if (groupDescriptor != null && groupId == currentlyActiveGroupId) {
            /* Make sure active group is already exposed to audio framework.
             * If not, lets wait for it and don't sent additional intent.
+6 −0
Original line number Diff line number Diff line
@@ -1623,6 +1623,12 @@ public class LeAudioServiceTest {
        // Verify only update the fallback group and not proceed to change active
        assertThat(mService.setActiveDevice(mSingleDevice)).isTrue();
        assertThat(mService.mUnicastGroupIdDeactivatedForBroadcastTransition).isEqualTo(groupId);

        // Verify only update the fallback group to INVALID and not proceed to change active
        assertThat(mService.setActiveDevice(null)).isTrue();
        assertThat(mService.mUnicastGroupIdDeactivatedForBroadcastTransition)
                .isEqualTo(BluetoothLeAudio.GROUP_ID_INVALID);

        verify(mNativeInterface, times(0)).groupSetActive(anyInt());
    }