Loading packages/SettingsLib/src/com/android/settingslib/media/BluetoothMediaDevice.java +9 −0 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice; import android.content.Context; import android.content.Context; import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable; import android.media.AudioManager; import android.media.MediaRoute2Info; import android.media.MediaRoute2Info; import android.media.MediaRouter2Manager; import android.media.MediaRouter2Manager; Loading @@ -34,11 +35,13 @@ public class BluetoothMediaDevice extends MediaDevice { private static final String TAG = "BluetoothMediaDevice"; private static final String TAG = "BluetoothMediaDevice"; private CachedBluetoothDevice mCachedDevice; private CachedBluetoothDevice mCachedDevice; private final AudioManager mAudioManager; BluetoothMediaDevice(Context context, CachedBluetoothDevice device, BluetoothMediaDevice(Context context, CachedBluetoothDevice device, MediaRouter2Manager routerManager, MediaRoute2Info info, String packageName) { MediaRouter2Manager routerManager, MediaRoute2Info info, String packageName) { super(context, routerManager, info, packageName); super(context, routerManager, info, packageName); mCachedDevice = device; mCachedDevice = device; mAudioManager = context.getSystemService(AudioManager.class); initDeviceRecord(); initDeviceRecord(); } } Loading Loading @@ -97,6 +100,12 @@ public class BluetoothMediaDevice extends MediaDevice { mCachedDevice.getDevice(), BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET); mCachedDevice.getDevice(), BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET); } } @Override public boolean isMutingExpectedDevice() { return mAudioManager.getMutingExpectedDevice() != null && mCachedDevice.getAddress().equals( mAudioManager.getMutingExpectedDevice().getAddress()); } @Override @Override public boolean isConnected() { public boolean isConnected() { return mCachedDevice.getBondState() == BluetoothDevice.BOND_BONDED return mCachedDevice.getBondState() == BluetoothDevice.BOND_BONDED Loading packages/SettingsLib/src/com/android/settingslib/media/MediaDevice.java +15 −0 Original line number Original line Diff line number Diff line Loading @@ -320,6 +320,13 @@ public abstract class MediaDevice implements Comparable<MediaDevice> { } } if (mType == another.mType) { if (mType == another.mType) { // Check device is muting expected device if (isMutingExpectedDevice()) { return -1; } else if (another.isMutingExpectedDevice()) { return 1; } // Check fast pair device // Check fast pair device if (isFastPairDevice()) { if (isFastPairDevice()) { return -1; return -1; Loading Loading @@ -392,6 +399,14 @@ public abstract class MediaDevice implements Comparable<MediaDevice> { return false; return false; } } /** * Check if it is muting expected device * @return {@code true} if it is muting expected device, otherwise return {@code false} */ protected boolean isMutingExpectedDevice() { return false; } @Override @Override public boolean equals(Object obj) { public boolean equals(Object obj) { if (!(obj instanceof MediaDevice)) { if (!(obj instanceof MediaDevice)) { Loading Loading
packages/SettingsLib/src/com/android/settingslib/media/BluetoothMediaDevice.java +9 −0 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ import android.bluetooth.BluetoothClass; import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothDevice; import android.content.Context; import android.content.Context; import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable; import android.media.AudioManager; import android.media.MediaRoute2Info; import android.media.MediaRoute2Info; import android.media.MediaRouter2Manager; import android.media.MediaRouter2Manager; Loading @@ -34,11 +35,13 @@ public class BluetoothMediaDevice extends MediaDevice { private static final String TAG = "BluetoothMediaDevice"; private static final String TAG = "BluetoothMediaDevice"; private CachedBluetoothDevice mCachedDevice; private CachedBluetoothDevice mCachedDevice; private final AudioManager mAudioManager; BluetoothMediaDevice(Context context, CachedBluetoothDevice device, BluetoothMediaDevice(Context context, CachedBluetoothDevice device, MediaRouter2Manager routerManager, MediaRoute2Info info, String packageName) { MediaRouter2Manager routerManager, MediaRoute2Info info, String packageName) { super(context, routerManager, info, packageName); super(context, routerManager, info, packageName); mCachedDevice = device; mCachedDevice = device; mAudioManager = context.getSystemService(AudioManager.class); initDeviceRecord(); initDeviceRecord(); } } Loading Loading @@ -97,6 +100,12 @@ public class BluetoothMediaDevice extends MediaDevice { mCachedDevice.getDevice(), BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET); mCachedDevice.getDevice(), BluetoothDevice.METADATA_IS_UNTETHERED_HEADSET); } } @Override public boolean isMutingExpectedDevice() { return mAudioManager.getMutingExpectedDevice() != null && mCachedDevice.getAddress().equals( mAudioManager.getMutingExpectedDevice().getAddress()); } @Override @Override public boolean isConnected() { public boolean isConnected() { return mCachedDevice.getBondState() == BluetoothDevice.BOND_BONDED return mCachedDevice.getBondState() == BluetoothDevice.BOND_BONDED Loading
packages/SettingsLib/src/com/android/settingslib/media/MediaDevice.java +15 −0 Original line number Original line Diff line number Diff line Loading @@ -320,6 +320,13 @@ public abstract class MediaDevice implements Comparable<MediaDevice> { } } if (mType == another.mType) { if (mType == another.mType) { // Check device is muting expected device if (isMutingExpectedDevice()) { return -1; } else if (another.isMutingExpectedDevice()) { return 1; } // Check fast pair device // Check fast pair device if (isFastPairDevice()) { if (isFastPairDevice()) { return -1; return -1; Loading Loading @@ -392,6 +399,14 @@ public abstract class MediaDevice implements Comparable<MediaDevice> { return false; return false; } } /** * Check if it is muting expected device * @return {@code true} if it is muting expected device, otherwise return {@code false} */ protected boolean isMutingExpectedDevice() { return false; } @Override @Override public boolean equals(Object obj) { public boolean equals(Object obj) { if (!(obj instanceof MediaDevice)) { if (!(obj instanceof MediaDevice)) { Loading