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

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

Merge "[le audio] Set BASS connection policy with other LEA GATT profiles" into main

parents 68247bbc 0477c232
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -4106,6 +4106,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;
@@ -1167,6 +1168,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)
@@ -1175,6 +1177,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);

@@ -1190,7 +1193,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,
@@ -1230,7 +1236,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,