[automerge] DO NOT MERGE: provide different change in downstream since merge conflict [Output Switcher] Enable volume control for single cast device 2p: d1f381a7db
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16660809 Bug: 202500642 Change-Id: I28a6fc24644460f01aa7cd9e25a94a5814a14ee3
This commit is contained in:
@@ -165,6 +165,31 @@ public class InfoMediaManager extends MediaManager {
|
|||||||
return sessionInfos.get(sessionInfos.size() - 1);
|
return sessionInfos.get(sessionInfos.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean isRoutingSessionAvailableForVolumeControl() {
|
||||||
|
if (mVolumeAdjustmentForRemoteGroupSessions) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
List<RoutingSessionInfo> sessions =
|
||||||
|
mRouterManager.getRoutingSessions(mPackageName);
|
||||||
|
boolean foundNonSystemSession = false;
|
||||||
|
boolean isGroup = false;
|
||||||
|
for (RoutingSessionInfo session : sessions) {
|
||||||
|
if (!session.isSystemSession()) {
|
||||||
|
foundNonSystemSession = true;
|
||||||
|
int selectedRouteCount = session.getSelectedRoutes().size();
|
||||||
|
if (selectedRouteCount > 1) {
|
||||||
|
isGroup = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!foundNonSystemSession) {
|
||||||
|
Log.d(TAG, "No routing session for " + mPackageName);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return !isGroup;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a {@code device} from current media.
|
* Remove a {@code device} from current media.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -196,6 +196,14 @@ public class LocalMediaManager implements BluetoothCallback {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns if the media session is available for volume control.
|
||||||
|
* @return True if this media session is available for colume control, false otherwise.
|
||||||
|
*/
|
||||||
|
public boolean isMediaSessionAvailableForVolumeControl() {
|
||||||
|
return mInfoMediaManager.isRoutingSessionAvailableForVolumeControl();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start scan connected MediaDevice
|
* Start scan connected MediaDevice
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback {
|
|||||||
private final SystemUIDialogManager mDialogManager;
|
private final SystemUIDialogManager mDialogManager;
|
||||||
private final List<MediaDevice> mGroupMediaDevices = new CopyOnWriteArrayList<>();
|
private final List<MediaDevice> mGroupMediaDevices = new CopyOnWriteArrayList<>();
|
||||||
private final boolean mAboveStatusbar;
|
private final boolean mAboveStatusbar;
|
||||||
private final boolean mVolumeAdjustmentForRemoteGroupSessions;
|
|
||||||
private final NotificationEntryManager mNotificationEntryManager;
|
private final NotificationEntryManager mNotificationEntryManager;
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
final List<MediaDevice> mMediaDevices = new CopyOnWriteArrayList<>();
|
final List<MediaDevice> mMediaDevices = new CopyOnWriteArrayList<>();
|
||||||
@@ -117,8 +116,6 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback {
|
|||||||
mMetricLogger = new MediaOutputMetricLogger(mContext, mPackageName);
|
mMetricLogger = new MediaOutputMetricLogger(mContext, mPackageName);
|
||||||
mUiEventLogger = uiEventLogger;
|
mUiEventLogger = uiEventLogger;
|
||||||
mDialogLaunchAnimator = dialogLaunchAnimator;
|
mDialogLaunchAnimator = dialogLaunchAnimator;
|
||||||
mVolumeAdjustmentForRemoteGroupSessions = mContext.getResources().getBoolean(
|
|
||||||
com.android.internal.R.bool.config_volumeAdjustmentForRemoteGroupSessions);
|
|
||||||
mDialogManager = dialogManager;
|
mDialogManager = dialogManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -496,10 +493,15 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback {
|
|||||||
|| features.contains(MediaRoute2Info.FEATURE_REMOTE_GROUP_PLAYBACK));
|
|| features.contains(MediaRoute2Info.FEATURE_REMOTE_GROUP_PLAYBACK));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isPlayBackInfoLocal() {
|
||||||
|
return mMediaController.getPlaybackInfo() != null
|
||||||
|
&& mMediaController.getPlaybackInfo().getPlaybackType()
|
||||||
|
== MediaController.PlaybackInfo.PLAYBACK_TYPE_LOCAL;
|
||||||
|
}
|
||||||
|
|
||||||
boolean isVolumeControlEnabled(@NonNull MediaDevice device) {
|
boolean isVolumeControlEnabled(@NonNull MediaDevice device) {
|
||||||
// TODO(b/202500642): Also enable volume control for remote non-group sessions.
|
return isPlayBackInfoLocal()
|
||||||
return !isActiveRemoteDevice(device)
|
|| mLocalMediaManager.isMediaSessionAvailableForVolumeControl();
|
||||||
|| mVolumeAdjustmentForRemoteGroupSessions;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final MediaController.Callback mCb = new MediaController.Callback() {
|
private final MediaController.Callback mCb = new MediaController.Callback() {
|
||||||
|
|||||||
Reference in New Issue
Block a user