diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputController.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputController.java index 42e9af846322e..0b4b03619a13f 100644 --- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputController.java +++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputController.java @@ -840,6 +840,10 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback, || features.contains(MediaRoute2Info.FEATURE_REMOTE_GROUP_PLAYBACK)); } + boolean isBluetoothLeDevice(@NonNull MediaDevice device) { + return device.isBLEDevice(); + } + boolean isBroadcastSupported() { LocalBluetoothLeBroadcast broadcast = mLocalBluetoothManager.getProfileManager().getLeAudioBroadcastProfile(); diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputDialog.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputDialog.java index 026a3055b01b0..3fd920bb4c720 100644 --- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputDialog.java +++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputDialog.java @@ -99,7 +99,12 @@ public class MediaOutputDialog extends MediaOutputBaseDialog { @Override public boolean isBroadcastSupported() { - return mMediaOutputController.isBroadcastSupported(); + boolean isBluetoothLeDevice = false; + if (mMediaOutputController.getCurrentConnectedMediaDevice() != null) { + isBluetoothLeDevice = mMediaOutputController.isBluetoothLeDevice( + mMediaOutputController.getCurrentConnectedMediaDevice()); + } + return mMediaOutputController.isBroadcastSupported() && isBluetoothLeDevice; } @Override diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputDialogTest.java b/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputDialogTest.java index 6786ad0116ea7..b16c928adcd47 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputDialogTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/media/dialog/MediaOutputDialogTest.java @@ -138,15 +138,30 @@ public class MediaOutputDialogTest extends SysuiTestCase { mFeatures.add(MediaRoute2Info.FEATURE_REMOTE_GROUP_PLAYBACK); assertThat(mMediaOutputDialog.getStopButtonVisibility()).isEqualTo(View.VISIBLE); + } - mFeatures.clear(); + @Test + public void getStopButtonVisibility_remoteBLEDevice_returnVisible() { when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn( mLocalBluetoothLeBroadcast); when(mLocalBluetoothLeBroadcast.isEnabled(any())).thenReturn(false); when(mPlaybackState.getState()).thenReturn(PlaybackState.STATE_PLAYING); + when(mMediaDevice.isBLEDevice()).thenReturn(true); + assertThat(mMediaOutputDialog.getStopButtonVisibility()).isEqualTo(View.VISIBLE); } + @Test + public void getStopButtonVisibility_remoteNonBLEDevice_returnGone() { + when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn( + mLocalBluetoothLeBroadcast); + when(mLocalBluetoothLeBroadcast.isEnabled(any())).thenReturn(false); + when(mPlaybackState.getState()).thenReturn(PlaybackState.STATE_PLAYING); + when(mMediaDevice.isBLEDevice()).thenReturn(false); + + assertThat(mMediaOutputDialog.getStopButtonVisibility()).isEqualTo(View.GONE); + } + @Test public void getStopButtonVisibility_localDevice_returnGone() { mFeatures.add(MediaRoute2Info.FEATURE_LOCAL_PLAYBACK);