Merge "[LE Audio] To enable the broadcast button when media is playing on BT LE device" into tm-qpr-dev am: 85ce4f74db

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18868546

Change-Id: Iefd8e5dc007ee94f78ce36f500d2495f7d669f92
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Betty Chang
2022-06-20 02:09:59 +00:00
committed by Automerger Merge Worker
3 changed files with 26 additions and 2 deletions

View File

@@ -840,6 +840,10 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback,
|| features.contains(MediaRoute2Info.FEATURE_REMOTE_GROUP_PLAYBACK)); || features.contains(MediaRoute2Info.FEATURE_REMOTE_GROUP_PLAYBACK));
} }
boolean isBluetoothLeDevice(@NonNull MediaDevice device) {
return device.isBLEDevice();
}
boolean isBroadcastSupported() { boolean isBroadcastSupported() {
LocalBluetoothLeBroadcast broadcast = LocalBluetoothLeBroadcast broadcast =
mLocalBluetoothManager.getProfileManager().getLeAudioBroadcastProfile(); mLocalBluetoothManager.getProfileManager().getLeAudioBroadcastProfile();

View File

@@ -99,7 +99,12 @@ public class MediaOutputDialog extends MediaOutputBaseDialog {
@Override @Override
public boolean isBroadcastSupported() { public boolean isBroadcastSupported() {
return mMediaOutputController.isBroadcastSupported(); boolean isBluetoothLeDevice = false;
if (mMediaOutputController.getCurrentConnectedMediaDevice() != null) {
isBluetoothLeDevice = mMediaOutputController.isBluetoothLeDevice(
mMediaOutputController.getCurrentConnectedMediaDevice());
}
return mMediaOutputController.isBroadcastSupported() && isBluetoothLeDevice;
} }
@Override @Override

View File

@@ -138,15 +138,30 @@ public class MediaOutputDialogTest extends SysuiTestCase {
mFeatures.add(MediaRoute2Info.FEATURE_REMOTE_GROUP_PLAYBACK); mFeatures.add(MediaRoute2Info.FEATURE_REMOTE_GROUP_PLAYBACK);
assertThat(mMediaOutputDialog.getStopButtonVisibility()).isEqualTo(View.VISIBLE); assertThat(mMediaOutputDialog.getStopButtonVisibility()).isEqualTo(View.VISIBLE);
}
mFeatures.clear(); @Test
public void getStopButtonVisibility_remoteBLEDevice_returnVisible() {
when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn( when(mLocalBluetoothProfileManager.getLeAudioBroadcastProfile()).thenReturn(
mLocalBluetoothLeBroadcast); mLocalBluetoothLeBroadcast);
when(mLocalBluetoothLeBroadcast.isEnabled(any())).thenReturn(false); when(mLocalBluetoothLeBroadcast.isEnabled(any())).thenReturn(false);
when(mPlaybackState.getState()).thenReturn(PlaybackState.STATE_PLAYING); when(mPlaybackState.getState()).thenReturn(PlaybackState.STATE_PLAYING);
when(mMediaDevice.isBLEDevice()).thenReturn(true);
assertThat(mMediaOutputDialog.getStopButtonVisibility()).isEqualTo(View.VISIBLE); 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 @Test
public void getStopButtonVisibility_localDevice_returnGone() { public void getStopButtonVisibility_localDevice_returnGone() {
mFeatures.add(MediaRoute2Info.FEATURE_LOCAL_PLAYBACK); mFeatures.add(MediaRoute2Info.FEATURE_LOCAL_PLAYBACK);