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

Commit d2ade5c3 authored by Yiyi Shen's avatar Yiyi Shen Committed by Android (Google) Code Review
Browse files

Merge "[Audiosharing] Check connection state before adding source" into main

parents 8e03e1f7 fc29cdde
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -431,10 +431,13 @@ public class CsipDeviceManager {
                    for (BluetoothDevice device : sinksToSync) {
                        log("addMemberDevicesIntoMainDevice: sync audio sharing source to "
                                + device.getAnonymizedAddress());
                        if (assistant.getConnectionStatus(device)
                                == BluetoothProfile.STATE_CONNECTED) {
                            assistant.addSource(device, metadata, /* isGroupOp= */ false);
                        }
                    }
                }
            }
        } else {
            log("addMemberDevicesIntoMainDevice: skip sync source, flag disabled");
        }
+4 −0
Original line number Diff line number Diff line
@@ -377,6 +377,7 @@ public class CsipDeviceManagerTest {
                BluetoothLeBroadcastReceiveState.class);
        when(state.getBisSyncState()).thenReturn(ImmutableList.of(1L));
        when(mAssistant.getAllSources(mDevice2)).thenReturn(ImmutableList.of(state));
        when(mAssistant.getConnectionStatus(mDevice1)).thenReturn(BluetoothAdapter.STATE_CONNECTED);
        when(mContext.getSystemService(UserManager.class)).thenReturn(mUserManager);
        when(mUserManager.isManagedProfile()).thenReturn(true);

@@ -407,6 +408,7 @@ public class CsipDeviceManagerTest {
                BluetoothLeBroadcastReceiveState.class);
        when(state.getBisSyncState()).thenReturn(ImmutableList.of(1L));
        when(mAssistant.getAllSources(mDevice2)).thenReturn(ImmutableList.of(state));
        when(mAssistant.getConnectionStatus(mDevice1)).thenReturn(BluetoothAdapter.STATE_CONNECTED);

        assertThat(mCsipDeviceManager.addMemberDevicesIntoMainDevice(GROUP1, preferredDevice))
                .isTrue();
@@ -474,6 +476,8 @@ public class CsipDeviceManagerTest {
                BluetoothLeBroadcastReceiveState.class);
        when(state.getBisSyncState()).thenReturn(ImmutableList.of(1L));
        when(mAssistant.getAllSources(mDevice1)).thenReturn(ImmutableList.of(state));
        when(mAssistant.getConnectionStatus(mDevice2)).thenReturn(BluetoothAdapter.STATE_CONNECTED);
        when(mAssistant.getConnectionStatus(mDevice3)).thenReturn(BluetoothAdapter.STATE_CONNECTED);

        assertThat(mCsipDeviceManager.addMemberDevicesIntoMainDevice(GROUP1, preferredDevice))
                .isTrue();