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

Commit b81adc25 authored by Rongxuan Liu's avatar Rongxuan Liu
Browse files

Remove leaudio_broadcast_audio_handover_policies flag

Bug: 308171251
Test: m com.android.btservices
Change-Id: If13bd4b31c9d7c28fbf672f88982fd66a7f99384
parent 8c49b368
Loading
Loading
Loading
Loading
+11 −17
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import static android.bluetooth.IBluetoothLeAudio.LE_AUDIO_GROUP_ID_INVALID;
import static com.android.bluetooth.flags.Flags.leaudioAllowedContextMask;
import static com.android.bluetooth.flags.Flags.leaudioBigDependsOnAudioState;
import static com.android.bluetooth.flags.Flags.leaudioBroadcastAssistantPeripheralEntrustment;
import static com.android.bluetooth.flags.Flags.leaudioBroadcastAudioHandoverPolicies;
import static com.android.bluetooth.flags.Flags.leaudioBroadcastExtractPeriodicScannerFromStateMachine;
import static com.android.bluetooth.flags.Flags.leaudioBroadcastMonitorSourceSyncStatus;
import static com.android.bluetooth.flags.Flags.leaudioBroadcastResyncHelper;
@@ -3245,7 +3244,6 @@ public class BassClientService extends ProfileService {
    }

    private boolean isAllowedToAddSource() {
        if (leaudioBroadcastAudioHandoverPolicies()) {
        /* Check if should wait for status update */
        if (mUnicastSourceStreamStatus.isEmpty()) {
            /* Assistant was not active, inform about activation */
@@ -3264,10 +3262,6 @@ public class BassClientService extends ProfileService {
        return mUnicastSourceStreamStatus.get() == STATUS_LOCAL_STREAM_SUSPENDED;
    }

        /* Don't block if this is not a handover case */
        return true;
    }

    /** Return true if there is any non primary device receiving broadcast */
    private boolean isAudioSharingModeOn(Integer broadcastId) {
        if (mLocalBroadcastReceivers == null) {
+0 −5
Original line number Diff line number Diff line
@@ -1263,11 +1263,6 @@ public class ActiveDeviceManager implements AdapterService.BluetoothStateCallbac
     * @return {@code true} if is broadcasting audio, {@code false} otherwise
     */
    private boolean isBroadcastingAudio() {
        if (!Flags.leaudioBroadcastAudioHandoverPolicies()) {
            // disable this if feature flag is false
            return false;
        }

        final LeAudioService leAudioService = mFactory.getLeAudioService();
        return leAudioService != null && !leAudioService.getAllBroadcastMetadata().isEmpty();
    }
+11 −29
Original line number Diff line number Diff line
@@ -1175,9 +1175,7 @@ public class LeAudioService extends ProfileService {
                        "Unicast group is active, queueing Broadcast creation, while the Unicast"
                                + " group is deactivated.");
                mCreateBroadcastQueue.add(broadcastSettings);
                if (Flags.leaudioBroadcastAudioHandoverPolicies()) {
                mNativeInterface.setUnicastMonitorMode(LeAudioStackEvent.DIRECTION_SINK, true);
                }
                removeActiveDevice(true);

                return;
@@ -1422,10 +1420,8 @@ public class LeAudioService extends ProfileService {
        }

        Log.d(TAG, "destroyBroadcast");
        if (Flags.leaudioBroadcastAudioHandoverPolicies()) {
        mIsSinkStreamMonitorModeEnabled = false;
        mNativeInterface.setUnicastMonitorMode(LeAudioStackEvent.DIRECTION_SINK, false);
        }
        mLeAudioBroadcasterNativeInterface.destroyBroadcast(broadcastId);
    }

@@ -2235,8 +2231,7 @@ public class LeAudioService extends ProfileService {
            if (notifyAndUpdateInactiveOutDeviceOnly
                    && ((newSupportedAudioDirections & AUDIO_DIRECTION_INPUT_BIT) != 0)) {
                newInDevice = getLeadDeviceForTheGroup(groupId);
            } else if (Flags.leaudioBroadcastAudioHandoverPolicies()
                    && mIsSinkStreamMonitorModeEnabled) {
            } else if (mIsSinkStreamMonitorModeEnabled) {
                mIsSinkStreamMonitorModeEnabled = false;
                mNativeInterface.setUnicastMonitorMode(LeAudioStackEvent.DIRECTION_SINK, false);
            }
@@ -2790,8 +2785,7 @@ public class LeAudioService extends ProfileService {
             */
            boolean leaveConnectedInputDevice = false;
            Integer newDirections = AUDIO_DIRECTION_NONE;
            if (Flags.leaudioBroadcastAudioHandoverPolicies()
                    && isBroadcastReadyToBeReActivated()) {
            if (isBroadcastReadyToBeReActivated()) {
                leaveConnectedInputDevice = true;
                newDirections |= AUDIO_DIRECTION_INPUT_BIT;

@@ -2879,10 +2873,6 @@ public class LeAudioService extends ProfileService {
    }

    private boolean isGroupReceivingBroadcast(int groupId) {
        if (!Flags.leaudioBroadcastAudioHandoverPolicies()) {
            return false;
        }

        BassClientService bassClientService = getBassClientService();
        if (bassClientService == null) {
            return false;
@@ -3895,11 +3885,9 @@ public class LeAudioService extends ProfileService {
            }

            // Notify broadcast assistant
            if (Flags.leaudioBroadcastAudioHandoverPolicies()) {
            if (bassClientService != null) {
                bassClientService.notifyBroadcastStateChanged(descriptor.mState, broadcastId);
            }
            }
        } else if (stackEvent.type == LeAudioStackEvent.EVENT_TYPE_BROADCAST_METADATA_CHANGED) {
            int broadcastId = stackEvent.valueInt1;
            if (stackEvent.broadcastMetadata == null) {
@@ -3941,10 +3929,8 @@ public class LeAudioService extends ProfileService {
            if (mAwaitingBroadcastCreateResponse && !areAllGroupsInNotActiveState()) {
                /* Broadcast would be created once unicast group became inactive */
                Log.i(TAG, "Unicast group is active, deactivate due to pending broadcast");
                if (Flags.leaudioBroadcastAudioHandoverPolicies()) {
                mIsSinkStreamMonitorModeEnabled = true;
                mNativeInterface.setUnicastMonitorMode(LeAudioStackEvent.DIRECTION_SINK, true);
                }
                removeActiveDevice(true);
            }
        } else if (stackEvent.type == LeAudioStackEvent.EVENT_TYPE_NATIVE_INITIALIZED) {
@@ -4287,9 +4273,7 @@ public class LeAudioService extends ProfileService {

        if (!leaudioUseAudioModeListener()) {
            /* For setting inCall mode */
            if (Flags.leaudioBroadcastAudioHandoverPolicies()
                    && inCall
                    && !areBroadcastsAllStopped()) {
            if (inCall && !areBroadcastsAllStopped()) {
                mQueuedInCallValue = Optional.of(true);

                /* Request activation of unicast group */
@@ -4304,9 +4288,7 @@ public class LeAudioService extends ProfileService {

        if (!leaudioUseAudioModeListener()) {
            /* For clearing inCall mode */
            if (Flags.leaudioBroadcastAudioHandoverPolicies()
                    && !inCall
                    && mBroadcastIdDeactivatedForUnicastTransition.isPresent()) {
            if (!inCall && mBroadcastIdDeactivatedForUnicastTransition.isPresent()) {
                handleUnicastStreamStatusChange(
                        LeAudioStackEvent.DIRECTION_SINK,
                        LeAudioStackEvent.STATUS_LOCAL_STREAM_SUSPENDED);
+3 −5
Original line number Diff line number Diff line
@@ -1394,12 +1394,10 @@ public class BassClientServiceTest {
    }

    private void handleHandoverSupport() {
        if (Flags.leaudioBroadcastAudioHandoverPolicies()) {
        /* Unicast finished streaming */
        mBassClientService.handleUnicastSourceStreamStatusChange(
                2 /* STATUS_LOCAL_STREAM_SUSPENDED */);
    }
    }

    private void verifyAddSourceForGroup(BluetoothLeBroadcastMetadata meta) {
        // Add broadcast source
+0 −4
Original line number Diff line number Diff line
@@ -1353,7 +1353,6 @@ public class ActiveDeviceManagerTest {
     */
    @Test
    public void a2dpConnectedWhenBroadcasting_notSetA2dpActive() {
        mSetFlagsRule.enableFlags(Flags.FLAG_LEAUDIO_BROADCAST_AUDIO_HANDOVER_POLICIES);
        final List<BluetoothLeBroadcastMetadata> metadataList = mock(List.class);
        when(mLeAudioService.getAllBroadcastMetadata()).thenReturn(metadataList);
        a2dpConnected(mA2dpDevice, false);
@@ -1370,7 +1369,6 @@ public class ActiveDeviceManagerTest {
     */
    @Test
    public void headsetConnectedWhenBroadcasting_notSetHeadsetActive() {
        mSetFlagsRule.enableFlags(Flags.FLAG_LEAUDIO_BROADCAST_AUDIO_HANDOVER_POLICIES);
        final List<BluetoothLeBroadcastMetadata> metadataList = mock(List.class);
        when(mLeAudioService.getAllBroadcastMetadata()).thenReturn(metadataList);
        headsetConnected(mHeadsetDevice, false);
@@ -1387,7 +1385,6 @@ public class ActiveDeviceManagerTest {
     */
    @Test
    public void hearingAidConnectedWhenBroadcasting_notSetHearingAidActive() {
        mSetFlagsRule.enableFlags(Flags.FLAG_LEAUDIO_BROADCAST_AUDIO_HANDOVER_POLICIES);
        final List<BluetoothLeBroadcastMetadata> metadataList = mock(List.class);
        when(mLeAudioService.getAllBroadcastMetadata()).thenReturn(metadataList);
        hearingAidConnected(mHearingAidDevice);
@@ -1401,7 +1398,6 @@ public class ActiveDeviceManagerTest {
     */
    @Test
    public void leHearingAidConnectedWhenBroadcasting_notSetLeHearingAidActive() {
        mSetFlagsRule.enableFlags(Flags.FLAG_LEAUDIO_BROADCAST_AUDIO_HANDOVER_POLICIES);
        final List<BluetoothLeBroadcastMetadata> metadataList = mock(List.class);
        when(mLeAudioService.getAllBroadcastMetadata()).thenReturn(metadataList);
        leHearingAidConnected(mLeHearingAidDevice);
Loading