Merge "DO NOT MERGE: provide different change in downstream since merge conflict [Output Switcher] Enable volume control for single cast device" into sc-v2-dev

This commit is contained in:
Shaowei Shen
2022-02-16 03:48:36 +00:00
committed by Android (Google) Code Review
3 changed files with 41 additions and 6 deletions

View File

@@ -164,6 +164,31 @@ public class InfoMediaManager extends MediaManager {
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.
*

View File

@@ -195,6 +195,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
*/

View File

@@ -84,7 +84,6 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback {
private final SystemUIDialogManager mDialogManager;
private final List<MediaDevice> mGroupMediaDevices = new CopyOnWriteArrayList<>();
private final boolean mAboveStatusbar;
private final boolean mVolumeAdjustmentForRemoteGroupSessions;
private final NotificationEntryManager mNotificationEntryManager;
@VisibleForTesting
final List<MediaDevice> mMediaDevices = new CopyOnWriteArrayList<>();
@@ -117,8 +116,6 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback {
mMetricLogger = new MediaOutputMetricLogger(mContext, mPackageName);
mUiEventLogger = uiEventLogger;
mDialogLaunchAnimator = dialogLaunchAnimator;
mVolumeAdjustmentForRemoteGroupSessions = mContext.getResources().getBoolean(
com.android.internal.R.bool.config_volumeAdjustmentForRemoteGroupSessions);
mDialogManager = dialogManager;
}
@@ -496,10 +493,15 @@ public class MediaOutputController implements LocalMediaManager.DeviceCallback {
|| 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) {
// TODO(b/202500642): Also enable volume control for remote non-group sessions.
return !isActiveRemoteDevice(device)
|| mVolumeAdjustmentForRemoteGroupSessions;
return isPlayBackInfoLocal()
|| mLocalMediaManager.isMediaSessionAvailableForVolumeControl();
}
private final MediaController.Callback mCb = new MediaController.Callback() {