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

Commit fc29cdde authored by Yiyi Shen's avatar Yiyi Shen
Browse files

[Audiosharing] Check connection state before adding source

Test: atest
Bug: 305620450
Flag: com.android.settingslib.flags.enable_le_audio_sharing
Change-Id: I3be3becbf8af72681448891f76893dc42d45f50b
parent f66a357b
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();