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

Commit 759bcad5 authored by Jakub Pawłowski's avatar Jakub Pawłowski Committed by Automerger Merge Worker
Browse files

Merge "let HapClient profile to update connection policy with other LE audio...

Merge "let HapClient profile to update connection policy with other LE audio GATT based profile" into main am: 698e6238 am: 9a65152a am: c9507a01 am: 9eb93eb4

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2774224



Change-Id: I42647e461ef727e80e548dc34af3b0f6686e2efb
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 6d3ae504 9eb93eb4
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ import com.android.bluetooth.btservice.ProfileService;
import com.android.bluetooth.btservice.ServiceFactory;
import com.android.bluetooth.btservice.storage.DatabaseManager;
import com.android.bluetooth.csip.CsipSetCoordinatorService;
import com.android.bluetooth.hap.HapClientService;
import com.android.bluetooth.hfp.HeadsetService;
import com.android.bluetooth.mcp.McpService;
import com.android.bluetooth.tbs.TbsGatt;
@@ -154,6 +155,9 @@ public class LeAudioService extends ProfileService {
    @VisibleForTesting
    VolumeControlService mVolumeControlService;

    @VisibleForTesting
    HapClientService mHapClientService;

    @VisibleForTesting
    CsipSetCoordinatorService mCsipSetCoordinatorService;

@@ -2714,6 +2718,13 @@ public class LeAudioService extends ProfileService {
            mVolumeControlService.setConnectionPolicy(device, connectionPolicy);
        }

        if (mHapClientService == null) {
            mHapClientService = mServiceFactory.getHapClientService();
        }
        if (mHapClientService != null) {
            mHapClientService.setConnectionPolicy(device, connectionPolicy);
        }

        if (mCsipSetCoordinatorService == null) {
            mCsipSetCoordinatorService = mServiceFactory.getCsipSetCoordinatorService();
        }
+9 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@ import com.android.bluetooth.btservice.AdapterService;
import com.android.bluetooth.btservice.ServiceFactory;
import com.android.bluetooth.btservice.storage.DatabaseManager;
import com.android.bluetooth.csip.CsipSetCoordinatorService;
import com.android.bluetooth.hap.HapClientService;
import com.android.bluetooth.hfp.HeadsetService;
import com.android.bluetooth.mcp.McpService;
import com.android.bluetooth.tbs.TbsService;
@@ -119,6 +120,7 @@ public class LeAudioServiceTest {
    @Mock private McpService mMcpService;
    @Mock private TbsService mTbsService;
    @Mock private VolumeControlService mVolumeControlService;
    @Mock private HapClientService mHapClientService;
    @Mock private CsipSetCoordinatorService mCsipSetCoordinatorService;
    @Spy private LeAudioObjectsFactory mObjectsFactory = LeAudioObjectsFactory.getInstance();
    @Spy private ServiceFactory mServiceFactory = new ServiceFactory();
@@ -188,8 +190,10 @@ public class LeAudioServiceTest {
        mService.mAudioManager = mAudioManager;
        mService.mMcpService = mMcpService;
        mService.mTbsService = mTbsService;
        mService.mHapClientService = mHapClientService;
        mService.mServiceFactory = mServiceFactory;
        when(mServiceFactory.getVolumeControlService()).thenReturn(mVolumeControlService);
        when(mServiceFactory.getHapClientService()).thenReturn(mHapClientService);
        when(mServiceFactory.getCsipSetCoordinatorService()).thenReturn(mCsipSetCoordinatorService);

        LeAudioStackEvent stackEvent =
@@ -928,6 +932,7 @@ public class LeAudioServiceTest {
                anyInt(), anyInt());
        when(mVolumeControlService.setConnectionPolicy(any(), anyInt())).thenReturn(true);
        when(mCsipSetCoordinatorService.setConnectionPolicy(any(), anyInt())).thenReturn(true);
        when(mHapClientService.setConnectionPolicy(any(), anyInt())).thenReturn(true);
        when(mDatabaseManager.getProfileConnectionPolicy(mSingleDevice, BluetoothProfile.LE_AUDIO))
                .thenReturn(BluetoothProfile.CONNECTION_POLICY_UNKNOWN);

@@ -939,6 +944,8 @@ public class LeAudioServiceTest {
                mSingleDevice, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
        verify(mCsipSetCoordinatorService, times(1)).setConnectionPolicy(
                mSingleDevice, BluetoothProfile.CONNECTION_POLICY_ALLOWED);
        verify(mHapClientService, times(1)).setConnectionPolicy(
                mSingleDevice, BluetoothProfile.CONNECTION_POLICY_ALLOWED);

        // Verify the connection state broadcast, and that we are in Connecting state
        verifyConnectionStateIntent(TIMEOUT_MS, mSingleDevice, BluetoothProfile.STATE_CONNECTING,
@@ -969,6 +976,8 @@ public class LeAudioServiceTest {
                mSingleDevice, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN);
        verify(mCsipSetCoordinatorService, times(1)).setConnectionPolicy(
                mSingleDevice, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN);
        verify(mHapClientService, times(1)).setConnectionPolicy(
                mSingleDevice, BluetoothProfile.CONNECTION_POLICY_FORBIDDEN);

        // Verify the connection state broadcast, and that we are in Connecting state
        verifyConnectionStateIntent(TIMEOUT_MS, mSingleDevice, BluetoothProfile.STATE_DISCONNECTING,