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

Commit a7a36d12 authored by Jacqueline Bronger's avatar Jacqueline Bronger
Browse files

Add disconnected BT media devices on TV

These devices will be shown in the TvMediaOutputDialog.

Bug: 292053977
Test: atest LocalMediaManagerTest
Change-Id: I673eea99e0ad9a5bd290a8a71c72003f524cfe30
parent 49e61e47
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.media.AudioDeviceAttributes;
import android.media.AudioManager;
@@ -520,10 +521,14 @@ public class LocalMediaManager implements BluetoothCallback {
                    if (type == MediaDevice.MediaDeviceType.TYPE_USB_C_AUDIO_DEVICE
                            || type == MediaDevice.MediaDeviceType.TYPE_3POINT5_MM_AUDIO_DEVICE
                            || type == MediaDevice.MediaDeviceType.TYPE_PHONE_DEVICE) {
                        if (isTv()) {
                            mMediaDevices.addAll(buildDisconnectedBluetoothDevice());
                        } else {
                            MediaDevice mutingExpectedDevice = getMutingExpectedDevice();
                            if (mutingExpectedDevice != null) {
                                mMediaDevices.add(mutingExpectedDevice);
                            }
                        }
                        break;
                    }
                }
@@ -542,6 +547,12 @@ public class LocalMediaManager implements BluetoothCallback {
            }
        }

        private boolean isTv() {
            PackageManager pm = mContext.getPackageManager();
            return pm.hasSystemFeature(PackageManager.FEATURE_TELEVISION)
                    || pm.hasSystemFeature(PackageManager.FEATURE_LEANBACK);
        }

        private MediaDevice getMutingExpectedDevice() {
            if (mBluetoothAdapter == null
                    || mAudioManager.getMutingExpectedDevice() == null) {