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

Commit 0477c232 authored by Rongxuan Liu's avatar Rongxuan Liu
Browse files

[le audio] Set BASS connection policy with other LEA GATT profiles

If setting LE audio policies is triggered by CSIP profile connected,
we didn't set BASS with other LEA GATT profiles. This will cause the
issue that one bud enabled BASS while the other bud didn't.
Adding this to ensure the connection policies are aligned among member
devices. And this will also support in LE audio only device case.

Bug: 350877103
Flag: EXEMPT, trivial change, covered by unit test
Test: atest LeAudioServiceTest
Test: manual tested private broadcast
Change-Id: I4c5e11e2d6a348ec232b0cce05885e5921576a93
parent 048a3931
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -4090,6 +4090,13 @@ public class LeAudioService extends ProfileService {
        if (mCsipSetCoordinatorService != null) {
            mCsipSetCoordinatorService.setConnectionPolicy(device, connectionPolicy);
        }

        if (mBassClientService == null) {
            mBassClientService = mServiceFactory.getBassClientService();
        }
        if (mBassClientService != null && mBassClientService.isEnabled()) {
            mBassClientService.setConnectionPolicy(device, connectionPolicy);
        }
    }

    /**
+12 −2
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import android.media.BluetoothProfileConnectionInfo;
import android.os.Handler;
import android.os.Looper;
import android.os.ParcelUuid;
import android.sysprop.BluetoothProperties;
import android.platform.test.flag.junit.SetFlagsRule;

import androidx.test.filters.MediumTest;
@@ -1188,6 +1189,7 @@ public class LeAudioServiceTest {
    /** Test setting connection policy */
    @Test
    public void testSetConnectionPolicy() {
        mSetFlagsRule.enableFlags(Flags.FLAG_LEAUDIO_BROADCAST_FEATURE_SUPPORT);
        doReturn(true).when(mNativeInterface).connectLeAudio(any(BluetoothDevice.class));
        doReturn(true).when(mNativeInterface).disconnectLeAudio(any(BluetoothDevice.class));
        doReturn(true)
@@ -1196,6 +1198,7 @@ public class LeAudioServiceTest {
        when(mVolumeControlService.setConnectionPolicy(any(), anyInt())).thenReturn(true);
        when(mCsipSetCoordinatorService.setConnectionPolicy(any(), anyInt())).thenReturn(true);
        when(mHapClientService.setConnectionPolicy(any(), anyInt())).thenReturn(true);
        when(mBassClientService.setConnectionPolicy(any(), anyInt())).thenReturn(true);
        when(mDatabaseManager.getProfileConnectionPolicy(mSingleDevice, BluetoothProfile.LE_AUDIO))
                .thenReturn(BluetoothProfile.CONNECTION_POLICY_UNKNOWN);

@@ -1211,7 +1214,10 @@ public class LeAudioServiceTest {
                .setConnectionPolicy(mSingleDevice, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
        verify(mHapClientService, times(1))
                .setConnectionPolicy(mSingleDevice, BluetoothProfile.CONNECTION_POLICY_ALLOWED);

        if (BluetoothProperties.isProfileBapBroadcastAssistEnabled().orElse(false)) {
            verify(mBassClientService, times(1))
                    .setConnectionPolicy(mSingleDevice, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
        }
        // Verify the connection state broadcast, and that we are in Connecting state
        verifyConnectionStateIntent(
                TIMEOUT_MS,
@@ -1251,7 +1257,11 @@ public class LeAudioServiceTest {
                .setConnectionPolicy(mSingleDevice, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN);
        verify(mHapClientService, times(1))
                .setConnectionPolicy(mSingleDevice, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN);

        if (BluetoothProperties.isProfileBapBroadcastAssistEnabled().orElse(false)) {
            verify(mBassClientService, times(1))
                    .setConnectionPolicy(
                            mSingleDevice, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN);
        }
        // Verify the connection state broadcast, and that we are in Connecting state
        verifyConnectionStateIntent(
                TIMEOUT_MS,