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

Commit e903f4e3 authored by Rongxuan Liu's avatar Rongxuan Liu Committed by Gerrit Code Review
Browse files

Merge "le_audio: Allow broadcast handover fallback device clear" into main

parents 927f558d 3996a0cf
Loading
Loading
Loading
Loading
+16 −3
Original line number Original line Diff line number Diff line
@@ -2255,17 +2255,30 @@ public class LeAudioService extends ProfileService {
                        + ", mExposedActiveDevice: "
                        + ", mExposedActiveDevice: "
                        + mExposedActiveDevice);
                        + mExposedActiveDevice);


        LeAudioGroupDescriptor groupDescriptor = getGroupDescriptor(currentlyActiveGroupId);
        if (isBroadcastActive()
        if (isBroadcastActive()
                && currentlyActiveGroupId == LE_AUDIO_GROUP_ID_INVALID
                && currentlyActiveGroupId == LE_AUDIO_GROUP_ID_INVALID
                && mUnicastGroupIdDeactivatedForBroadcastTransition != LE_AUDIO_GROUP_ID_INVALID
                && mUnicastGroupIdDeactivatedForBroadcastTransition != LE_AUDIO_GROUP_ID_INVALID) {
                && groupId != LE_AUDIO_GROUP_ID_INVALID) {
            // If broadcast is ongoing and need to update unicast fallback active group
            // 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
            // we need to update the cached group id and skip changing the active device
            updateFallbackUnicastGroupIdForBroadcast(groupId);
            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;
            return true;
        }
        }


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