diff options
| author | 2022-03-28 13:56:16 +0000 | |
|---|---|---|
| committer | 2022-03-30 08:18:16 +0000 | |
| commit | d08d997838e7a23c59494ea42225f31fa1a176ea (patch) | |
| tree | 9124775819a0917d4dcbdf250f477d15dbc89c44 | |
| parent | a84dc9b8709e65ade97f2973279e1b2a77181603 (diff) | |
[Output Switcher] Modify checking for device isConnected
When there's only one selectable device and device included, also take
it as connected one.
Test: Verified on device
Bug: 227028939
Change-Id: I89221b8285d88899482dc3dae1b0781daf1ce33b
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.java | 10 | ||||
| -rw-r--r-- | packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java | 15 |
2 files changed, 14 insertions, 11 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.java index f4fcf10e7bb4..0edadcc82a24 100644 --- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.java +++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputAdapter.java @@ -20,7 +20,6 @@ import android.content.res.ColorStateList; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.Drawable; -import android.text.TextUtils; import android.util.Log; import android.view.View; import android.view.ViewGroup; @@ -231,15 +230,6 @@ public class MediaOutputAdapter extends MediaOutputBaseAdapter { } } - private boolean isDeviceIncluded(List<MediaDevice> deviceList, MediaDevice targetDevice) { - for (MediaDevice device : deviceList) { - if (TextUtils.equals(device.getId(), targetDevice.getId())) { - return true; - } - } - return false; - } - private void onItemClick(View view, MediaDevice device) { if (mController.isTransferring()) { return; diff --git a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java index df0c14b25c26..5c536d469212 100644 --- a/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java +++ b/packages/SystemUI/src/com/android/systemui/media/dialog/MediaOutputBaseAdapter.java @@ -46,6 +46,8 @@ import com.android.settingslib.utils.ThreadUtils; import com.android.systemui.R; import com.android.systemui.animation.Interpolators; +import java.util.List; + /** * Base adapter for media output dialog. */ @@ -94,7 +96,18 @@ public abstract class MediaOutputBaseAdapter extends boolean isCurrentlyConnected(MediaDevice device) { return TextUtils.equals(device.getId(), - mController.getCurrentConnectedMediaDevice().getId()); + mController.getCurrentConnectedMediaDevice().getId()) + || (mController.getSelectedMediaDevice().size() == 1 + && isDeviceIncluded(mController.getSelectedMediaDevice(), device)); + } + + boolean isDeviceIncluded(List<MediaDevice> deviceList, MediaDevice targetDevice) { + for (MediaDevice device : deviceList) { + if (TextUtils.equals(device.getId(), targetDevice.getId())) { + return true; + } + } + return false; } boolean isDragging() { |