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

Commit fc0bd90e authored by changbetty's avatar changbetty
Browse files

[LE Audio] To enable the broadcast button when media is playing on BT LE

device

Bug: 235192905
Test: atest -c MediaOutputDialogTest
Change-Id: I05d0dff2df6acd515ba4f1dba337b4b890b07150
parent e0d6f903
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -795,6 +795,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();
+6 −1
Original line number Diff line number Diff line
@@ -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
+16 −1
Original line number Diff line number Diff line
@@ -136,15 +136,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);