Merge "Fix output switcher will show 2 media sessions in some use cases" into rvc-qpr-dev am: 9ccf19cb9f

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/13109545

Change-Id: I5f2c4d8549c28d1c91d81b7808183b0c97700dda
This commit is contained in:
TreeHugger Robot
2020-12-07 06:47:40 +00:00
committed by Automerger Merge Worker
2 changed files with 36 additions and 1 deletions

View File

@@ -25,6 +25,9 @@ import androidx.annotation.Nullable;
import com.android.settings.sound.MediaOutputPreferenceController;
import java.util.ArrayList;
import java.util.List;
/**
* Utilities that can be shared between {@link MediaOutputIndicatorWorker} and
* {@link MediaOutputPreferenceController}.
@@ -43,6 +46,7 @@ public class MediaOutputUtils {
MediaSessionManager mediaSessionManager) {
MediaController localController = null;
final List<String> remoteMediaSessionLists = new ArrayList<>();
for (MediaController controller : mediaSessionManager.getActiveSessions(null)) {
final MediaController.PlaybackInfo pi = controller.getPlaybackInfo();
if (pi == null) {
@@ -69,10 +73,14 @@ public class MediaOutputUtils {
controller.getPackageName())) {
localController = null;
}
if (!remoteMediaSessionLists.contains(controller.getPackageName())) {
remoteMediaSessionLists.add(controller.getPackageName());
}
continue;
}
if (pi.getPlaybackType() == MediaController.PlaybackInfo.PLAYBACK_TYPE_LOCAL) {
if (localController == null) {
if (localController == null
&& !remoteMediaSessionLists.contains(controller.getPackageName())) {
localController = controller;
}
}