DO NOT MERGE: provide different change in downstream since merge conflict [Output Switcher] Enable volume control for single cast device
update method for checking remote group device logic by sessionInfo Bug: 202500642 Test: Verified on device Change-Id: If12c53e88976c590c38d45f7ffd9b7b84028c14d
This commit is contained in:
committed by
Shaowei Shen
parent
5e2cdc4cb9
commit
d1f381a7db
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user