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

Commit 7920f3ad authored by Jacqueline Bronger's avatar Jacqueline Bronger Committed by Android (Google) Code Review
Browse files

Merge "Add disconnected BT media devices on TV" into main

parents d258bcd8 a7a36d12
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) {