Merge "Add getSelectedMediaDevice() API for output switcher"

This commit is contained in:
tim peng
2020-02-18 09:01:19 +00:00
committed by Android (Google) Code Review
2 changed files with 37 additions and 0 deletions

View File

@@ -192,6 +192,34 @@ public class InfoMediaManager extends MediaManager {
return deviceList;
}
/**
* Get the MediaDevice list that has been selected to current media.
*
* @return list of MediaDevice
*/
List<MediaDevice> getSelectedMediaDevice() {
final List<MediaDevice> deviceList = new ArrayList<>();
if (TextUtils.isEmpty(mPackageName)) {
Log.w(TAG, "getSelectedMediaDevice() package name is null or empty!");
return deviceList;
}
final RoutingSessionInfo info = getRoutingSessionInfo();
if (info != null) {
for (MediaRoute2Info route : mRouterManager.getControllerForSession(info)
.getSelectedRoutes()) {
deviceList.add(new InfoMediaDevice(mContext, mRouterManager,
route, mPackageName));
}
return deviceList;
}
Log.w(TAG, "getSelectedMediaDevice() cannot found selectable MediaDevice from : "
+ mPackageName);
return deviceList;
}
/**
* Adjust the volume of {@link android.media.RoutingSessionInfo}.
*

View File

@@ -281,6 +281,15 @@ public class LocalMediaManager implements BluetoothCallback {
return mInfoMediaManager.getSelectableMediaDevice();
}
/**
* Get the MediaDevice list that has been selected to current media.
*
* @return list of MediaDevice
*/
public List<MediaDevice> getSelectedMediaDevice() {
return mInfoMediaManager.getSelectedMediaDevice();
}
/**
* Adjust the volume of session.
*