Loading packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBroadcastDialog.java +17 −18 Original line number Diff line number Diff line Loading @@ -261,7 +261,10 @@ public class MediaOutputBroadcastDialog extends MediaOutputBaseDialog { mMediaOutputController.registerLeBroadcastAssistantServiceCallback(mExecutor, mBroadcastAssistantCallback); } connectBroadcastWithActiveDevice(); /* Add local source broadcast to connected capable devices that may be possible receivers * of stream. */ startBroadcastWithConnectedDevices(); } @Override Loading Loading @@ -394,20 +397,15 @@ public class MediaOutputBroadcastDialog extends MediaOutputBaseDialog { } } void connectBroadcastWithActiveDevice() { void startBroadcastWithConnectedDevices() { //get the Metadata, and convert to BT QR code format. BluetoothLeBroadcastMetadata broadcastMetadata = getBroadcastMetadata(); if (broadcastMetadata == null) { Log.e(TAG, "Error: There is no broadcastMetadata."); return; } MediaDevice mediaDevice = mMediaOutputController.getCurrentConnectedMediaDevice(); if (mediaDevice == null || !(mediaDevice instanceof BluetoothMediaDevice) || !mediaDevice.isBLEDevice()) { Log.e(TAG, "Error: There is no active BT LE device."); return; } BluetoothDevice sink = ((BluetoothMediaDevice) mediaDevice).getCachedDevice().getDevice(); for (BluetoothDevice sink : mMediaOutputController.getConnectedBroadcastSinkDevices()) { Log.d(TAG, "The broadcastMetadata broadcastId: " + broadcastMetadata.getBroadcastId() + ", the device: " + sink.getAnonymizedAddress()); Loading @@ -416,10 +414,11 @@ public class MediaOutputBroadcastDialog extends MediaOutputBaseDialog { return; } if (!mMediaOutputController.addSourceIntoSinkDeviceWithBluetoothLeAssistant(sink, broadcastMetadata, /*isGroupOp=*/ true)) { broadcastMetadata, /*isGroupOp=*/ false)) { Log.e(TAG, "Error: Source add failed"); } } } private void updateBroadcastCodeVisibility() { mBroadcastCode.setTransformationMethod( Loading packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputController.java +11 −0 Original line number Diff line number Diff line Loading @@ -1093,6 +1093,17 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback, broadcast.unregisterServiceCallBack(callback); } List<BluetoothDevice> getConnectedBroadcastSinkDevices() { LocalBluetoothLeBroadcastAssistant assistant = mLocalBluetoothManager.getProfileManager().getLeAudioBroadcastAssistantProfile(); if (assistant == null) { Log.d(TAG, "The broadcast assistant profile is null"); return null; } return assistant.getConnectedDevices(); } boolean isThereAnyBroadcastSourceIntoSinkDevice(BluetoothDevice sink) { LocalBluetoothLeBroadcastAssistant assistant = mLocalBluetoothManager.getProfileManager().getLeAudioBroadcastAssistantProfile(); Loading packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputBroadcastDialogTest.java +46 −13 Original line number Diff line number Diff line Loading @@ -98,7 +98,8 @@ public class MediaOutputBroadcastDialogTest extends SysuiTestCase { private final BroadcastSender mBroadcastSender = mock(BroadcastSender.class); private final LocalMediaManager mLocalMediaManager = mock(LocalMediaManager.class); private final MediaDevice mBluetoothMediaDevice = mock(BluetoothMediaDevice.class); private final BluetoothDevice mBluetoothDevice = mock(BluetoothDevice.class); private final BluetoothDevice mBluetoothFirstDevice = mock(BluetoothDevice.class); private final BluetoothDevice mBluetoothSecondDevice = mock(BluetoothDevice.class); private final CachedBluetoothDevice mCachedBluetoothDevice = mock(CachedBluetoothDevice.class); private final CommonNotifCollection mNotifCollection = mock(CommonNotifCollection.class); private final DialogLaunchAnimator mDialogLaunchAnimator = mock(DialogLaunchAnimator.class); Loading Loading @@ -142,20 +143,20 @@ public class MediaOutputBroadcastDialogTest extends SysuiTestCase { } @Test public void connectBroadcastWithActiveDevice_noBroadcastMetadata_failToAddSource() { public void startBroadcastWithConnectedDevices_noBroadcastMetadata_failToAddSource() { when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn( mLocalBluetoothLeBroadcast); when(mLocalBluetoothLeBroadcast.getLatestBluetoothLeBroadcastMetadata()).thenReturn(null); when(mLocalBluetoothProfileManager.getLeAudioBroadcastAssistantProfile()).thenReturn( mLocalBluetoothLeBroadcastAssistant); mMediaOutputBroadcastDialog.connectBroadcastWithActiveDevice(); mMediaOutputBroadcastDialog.startBroadcastWithConnectedDevices(); verify(mLocalBluetoothLeBroadcastAssistant, never()).addSource(any(), any(), anyBoolean()); } @Test public void connectBroadcastWithActiveDevice_noConnectedMediaDevice_failToAddSource() { public void startBroadcastWithConnectedDevices_noConnectedMediaDevice_failToAddSource() { when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn( mLocalBluetoothLeBroadcast); when(mLocalBluetoothLeBroadcast.getLatestBluetoothLeBroadcastMetadata()).thenReturn( Loading @@ -164,13 +165,13 @@ public class MediaOutputBroadcastDialogTest extends SysuiTestCase { mLocalBluetoothLeBroadcastAssistant); when(mLocalMediaManager.getCurrentConnectedDevice()).thenReturn(null); mMediaOutputBroadcastDialog.connectBroadcastWithActiveDevice(); mMediaOutputBroadcastDialog.startBroadcastWithConnectedDevices(); verify(mLocalBluetoothLeBroadcastAssistant, never()).addSource(any(), any(), anyBoolean()); } @Test public void connectBroadcastWithActiveDevice_hasBroadcastSource_failToAddSource() { public void startBroadcastWithConnectedDevices_hasBroadcastSource_failToAddSource() { when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn( mLocalBluetoothLeBroadcast); when(mLocalBluetoothLeBroadcast.getLatestBluetoothLeBroadcastMetadata()).thenReturn( Loading @@ -180,19 +181,19 @@ public class MediaOutputBroadcastDialogTest extends SysuiTestCase { when(mLocalMediaManager.getCurrentConnectedDevice()).thenReturn(mBluetoothMediaDevice); when(((BluetoothMediaDevice) mBluetoothMediaDevice).getCachedDevice()) .thenReturn(mCachedBluetoothDevice); when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice); when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothFirstDevice); List<BluetoothLeBroadcastReceiveState> sourceList = new ArrayList<>(); sourceList.add(mBluetoothLeBroadcastReceiveState); when(mLocalBluetoothLeBroadcastAssistant.getAllSources(mBluetoothDevice)).thenReturn( when(mLocalBluetoothLeBroadcastAssistant.getAllSources(mBluetoothFirstDevice)).thenReturn( sourceList); mMediaOutputBroadcastDialog.connectBroadcastWithActiveDevice(); mMediaOutputBroadcastDialog.startBroadcastWithConnectedDevices(); verify(mLocalBluetoothLeBroadcastAssistant, never()).addSource(any(), any(), anyBoolean()); } @Test public void connectBroadcastWithActiveDevice_noBroadcastSource_failToAddSource() { public void startBroadcastWithConnectedDevices_noBroadcastSource_failToAddSource() { when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn( mLocalBluetoothLeBroadcast); when(mLocalBluetoothProfileManager.getLeAudioBroadcastAssistantProfile()).thenReturn( Loading @@ -203,12 +204,16 @@ public class MediaOutputBroadcastDialogTest extends SysuiTestCase { when(mBluetoothMediaDevice.isBLEDevice()).thenReturn(true); when(((BluetoothMediaDevice) mBluetoothMediaDevice).getCachedDevice()).thenReturn( mCachedBluetoothDevice); when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice); when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothFirstDevice); List<BluetoothLeBroadcastReceiveState> sourceList = new ArrayList<>(); when(mLocalBluetoothLeBroadcastAssistant.getAllSources(mBluetoothDevice)).thenReturn( when(mLocalBluetoothLeBroadcastAssistant.getAllSources(mBluetoothFirstDevice)).thenReturn( sourceList); List<BluetoothDevice> connectedDevicesList = new ArrayList<>(); connectedDevicesList.add(mBluetoothFirstDevice); when(mLocalBluetoothLeBroadcastAssistant.getConnectedDevices()).thenReturn( connectedDevicesList); mMediaOutputBroadcastDialog.connectBroadcastWithActiveDevice(); mMediaOutputBroadcastDialog.startBroadcastWithConnectedDevices(); verify(mLocalBluetoothLeBroadcastAssistant, times(1)).addSource(any(), any(), anyBoolean()); } Loading Loading @@ -360,4 +365,32 @@ public class MediaOutputBroadcastDialogTest extends SysuiTestCase { assertThat(broadcastErrorMessage.getVisibility()).isEqualTo(View.VISIBLE); } @Test public void addSourceToAllConnectedDevices() { when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn( mLocalBluetoothLeBroadcast); when(mLocalBluetoothProfileManager.getLeAudioBroadcastAssistantProfile()).thenReturn( mLocalBluetoothLeBroadcastAssistant); when(mLocalBluetoothLeBroadcast.getLatestBluetoothLeBroadcastMetadata()).thenReturn( mBluetoothLeBroadcastMetadata); when(mLocalMediaManager.getCurrentConnectedDevice()).thenReturn(mBluetoothMediaDevice); when(mBluetoothMediaDevice.isBLEDevice()).thenReturn(true); when(((BluetoothMediaDevice) mBluetoothMediaDevice).getCachedDevice()) .thenReturn(mCachedBluetoothDevice); when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothFirstDevice); List<BluetoothLeBroadcastReceiveState> sourceList = new ArrayList<>(); when(mLocalBluetoothLeBroadcastAssistant.getAllSources(mBluetoothFirstDevice)).thenReturn( sourceList); List<BluetoothDevice> connectedDevicesList = new ArrayList<>(); connectedDevicesList.add(mBluetoothFirstDevice); connectedDevicesList.add(mBluetoothSecondDevice); when(mLocalBluetoothLeBroadcastAssistant.getConnectedDevices()).thenReturn( connectedDevicesList); mMediaOutputBroadcastDialog.startBroadcastWithConnectedDevices(); verify(mLocalBluetoothLeBroadcastAssistant, times(2)).addSource(any(), any(), anyBoolean()); } } Loading
packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBroadcastDialog.java +17 −18 Original line number Diff line number Diff line Loading @@ -261,7 +261,10 @@ public class MediaOutputBroadcastDialog extends MediaOutputBaseDialog { mMediaOutputController.registerLeBroadcastAssistantServiceCallback(mExecutor, mBroadcastAssistantCallback); } connectBroadcastWithActiveDevice(); /* Add local source broadcast to connected capable devices that may be possible receivers * of stream. */ startBroadcastWithConnectedDevices(); } @Override Loading Loading @@ -394,20 +397,15 @@ public class MediaOutputBroadcastDialog extends MediaOutputBaseDialog { } } void connectBroadcastWithActiveDevice() { void startBroadcastWithConnectedDevices() { //get the Metadata, and convert to BT QR code format. BluetoothLeBroadcastMetadata broadcastMetadata = getBroadcastMetadata(); if (broadcastMetadata == null) { Log.e(TAG, "Error: There is no broadcastMetadata."); return; } MediaDevice mediaDevice = mMediaOutputController.getCurrentConnectedMediaDevice(); if (mediaDevice == null || !(mediaDevice instanceof BluetoothMediaDevice) || !mediaDevice.isBLEDevice()) { Log.e(TAG, "Error: There is no active BT LE device."); return; } BluetoothDevice sink = ((BluetoothMediaDevice) mediaDevice).getCachedDevice().getDevice(); for (BluetoothDevice sink : mMediaOutputController.getConnectedBroadcastSinkDevices()) { Log.d(TAG, "The broadcastMetadata broadcastId: " + broadcastMetadata.getBroadcastId() + ", the device: " + sink.getAnonymizedAddress()); Loading @@ -416,10 +414,11 @@ public class MediaOutputBroadcastDialog extends MediaOutputBaseDialog { return; } if (!mMediaOutputController.addSourceIntoSinkDeviceWithBluetoothLeAssistant(sink, broadcastMetadata, /*isGroupOp=*/ true)) { broadcastMetadata, /*isGroupOp=*/ false)) { Log.e(TAG, "Error: Source add failed"); } } } private void updateBroadcastCodeVisibility() { mBroadcastCode.setTransformationMethod( Loading
packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputController.java +11 −0 Original line number Diff line number Diff line Loading @@ -1093,6 +1093,17 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback, broadcast.unregisterServiceCallBack(callback); } List<BluetoothDevice> getConnectedBroadcastSinkDevices() { LocalBluetoothLeBroadcastAssistant assistant = mLocalBluetoothManager.getProfileManager().getLeAudioBroadcastAssistantProfile(); if (assistant == null) { Log.d(TAG, "The broadcast assistant profile is null"); return null; } return assistant.getConnectedDevices(); } boolean isThereAnyBroadcastSourceIntoSinkDevice(BluetoothDevice sink) { LocalBluetoothLeBroadcastAssistant assistant = mLocalBluetoothManager.getProfileManager().getLeAudioBroadcastAssistantProfile(); Loading
packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputBroadcastDialogTest.java +46 −13 Original line number Diff line number Diff line Loading @@ -98,7 +98,8 @@ public class MediaOutputBroadcastDialogTest extends SysuiTestCase { private final BroadcastSender mBroadcastSender = mock(BroadcastSender.class); private final LocalMediaManager mLocalMediaManager = mock(LocalMediaManager.class); private final MediaDevice mBluetoothMediaDevice = mock(BluetoothMediaDevice.class); private final BluetoothDevice mBluetoothDevice = mock(BluetoothDevice.class); private final BluetoothDevice mBluetoothFirstDevice = mock(BluetoothDevice.class); private final BluetoothDevice mBluetoothSecondDevice = mock(BluetoothDevice.class); private final CachedBluetoothDevice mCachedBluetoothDevice = mock(CachedBluetoothDevice.class); private final CommonNotifCollection mNotifCollection = mock(CommonNotifCollection.class); private final DialogLaunchAnimator mDialogLaunchAnimator = mock(DialogLaunchAnimator.class); Loading Loading @@ -142,20 +143,20 @@ public class MediaOutputBroadcastDialogTest extends SysuiTestCase { } @Test public void connectBroadcastWithActiveDevice_noBroadcastMetadata_failToAddSource() { public void startBroadcastWithConnectedDevices_noBroadcastMetadata_failToAddSource() { when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn( mLocalBluetoothLeBroadcast); when(mLocalBluetoothLeBroadcast.getLatestBluetoothLeBroadcastMetadata()).thenReturn(null); when(mLocalBluetoothProfileManager.getLeAudioBroadcastAssistantProfile()).thenReturn( mLocalBluetoothLeBroadcastAssistant); mMediaOutputBroadcastDialog.connectBroadcastWithActiveDevice(); mMediaOutputBroadcastDialog.startBroadcastWithConnectedDevices(); verify(mLocalBluetoothLeBroadcastAssistant, never()).addSource(any(), any(), anyBoolean()); } @Test public void connectBroadcastWithActiveDevice_noConnectedMediaDevice_failToAddSource() { public void startBroadcastWithConnectedDevices_noConnectedMediaDevice_failToAddSource() { when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn( mLocalBluetoothLeBroadcast); when(mLocalBluetoothLeBroadcast.getLatestBluetoothLeBroadcastMetadata()).thenReturn( Loading @@ -164,13 +165,13 @@ public class MediaOutputBroadcastDialogTest extends SysuiTestCase { mLocalBluetoothLeBroadcastAssistant); when(mLocalMediaManager.getCurrentConnectedDevice()).thenReturn(null); mMediaOutputBroadcastDialog.connectBroadcastWithActiveDevice(); mMediaOutputBroadcastDialog.startBroadcastWithConnectedDevices(); verify(mLocalBluetoothLeBroadcastAssistant, never()).addSource(any(), any(), anyBoolean()); } @Test public void connectBroadcastWithActiveDevice_hasBroadcastSource_failToAddSource() { public void startBroadcastWithConnectedDevices_hasBroadcastSource_failToAddSource() { when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn( mLocalBluetoothLeBroadcast); when(mLocalBluetoothLeBroadcast.getLatestBluetoothLeBroadcastMetadata()).thenReturn( Loading @@ -180,19 +181,19 @@ public class MediaOutputBroadcastDialogTest extends SysuiTestCase { when(mLocalMediaManager.getCurrentConnectedDevice()).thenReturn(mBluetoothMediaDevice); when(((BluetoothMediaDevice) mBluetoothMediaDevice).getCachedDevice()) .thenReturn(mCachedBluetoothDevice); when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice); when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothFirstDevice); List<BluetoothLeBroadcastReceiveState> sourceList = new ArrayList<>(); sourceList.add(mBluetoothLeBroadcastReceiveState); when(mLocalBluetoothLeBroadcastAssistant.getAllSources(mBluetoothDevice)).thenReturn( when(mLocalBluetoothLeBroadcastAssistant.getAllSources(mBluetoothFirstDevice)).thenReturn( sourceList); mMediaOutputBroadcastDialog.connectBroadcastWithActiveDevice(); mMediaOutputBroadcastDialog.startBroadcastWithConnectedDevices(); verify(mLocalBluetoothLeBroadcastAssistant, never()).addSource(any(), any(), anyBoolean()); } @Test public void connectBroadcastWithActiveDevice_noBroadcastSource_failToAddSource() { public void startBroadcastWithConnectedDevices_noBroadcastSource_failToAddSource() { when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn( mLocalBluetoothLeBroadcast); when(mLocalBluetoothProfileManager.getLeAudioBroadcastAssistantProfile()).thenReturn( Loading @@ -203,12 +204,16 @@ public class MediaOutputBroadcastDialogTest extends SysuiTestCase { when(mBluetoothMediaDevice.isBLEDevice()).thenReturn(true); when(((BluetoothMediaDevice) mBluetoothMediaDevice).getCachedDevice()).thenReturn( mCachedBluetoothDevice); when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothDevice); when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothFirstDevice); List<BluetoothLeBroadcastReceiveState> sourceList = new ArrayList<>(); when(mLocalBluetoothLeBroadcastAssistant.getAllSources(mBluetoothDevice)).thenReturn( when(mLocalBluetoothLeBroadcastAssistant.getAllSources(mBluetoothFirstDevice)).thenReturn( sourceList); List<BluetoothDevice> connectedDevicesList = new ArrayList<>(); connectedDevicesList.add(mBluetoothFirstDevice); when(mLocalBluetoothLeBroadcastAssistant.getConnectedDevices()).thenReturn( connectedDevicesList); mMediaOutputBroadcastDialog.connectBroadcastWithActiveDevice(); mMediaOutputBroadcastDialog.startBroadcastWithConnectedDevices(); verify(mLocalBluetoothLeBroadcastAssistant, times(1)).addSource(any(), any(), anyBoolean()); } Loading Loading @@ -360,4 +365,32 @@ public class MediaOutputBroadcastDialogTest extends SysuiTestCase { assertThat(broadcastErrorMessage.getVisibility()).isEqualTo(View.VISIBLE); } @Test public void addSourceToAllConnectedDevices() { when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn( mLocalBluetoothLeBroadcast); when(mLocalBluetoothProfileManager.getLeAudioBroadcastAssistantProfile()).thenReturn( mLocalBluetoothLeBroadcastAssistant); when(mLocalBluetoothLeBroadcast.getLatestBluetoothLeBroadcastMetadata()).thenReturn( mBluetoothLeBroadcastMetadata); when(mLocalMediaManager.getCurrentConnectedDevice()).thenReturn(mBluetoothMediaDevice); when(mBluetoothMediaDevice.isBLEDevice()).thenReturn(true); when(((BluetoothMediaDevice) mBluetoothMediaDevice).getCachedDevice()) .thenReturn(mCachedBluetoothDevice); when(mCachedBluetoothDevice.getDevice()).thenReturn(mBluetoothFirstDevice); List<BluetoothLeBroadcastReceiveState> sourceList = new ArrayList<>(); when(mLocalBluetoothLeBroadcastAssistant.getAllSources(mBluetoothFirstDevice)).thenReturn( sourceList); List<BluetoothDevice> connectedDevicesList = new ArrayList<>(); connectedDevicesList.add(mBluetoothFirstDevice); connectedDevicesList.add(mBluetoothSecondDevice); when(mLocalBluetoothLeBroadcastAssistant.getConnectedDevices()).thenReturn( connectedDevicesList); mMediaOutputBroadcastDialog.startBroadcastWithConnectedDevices(); verify(mLocalBluetoothLeBroadcastAssistant, times(2)).addSource(any(), any(), anyBoolean()); } }