Add getSelectedMediaDevice() API for output switcher

- To get the device list that has been selected to current media.

Bug: 146813761
Test: build pass
Change-Id: I39b0e23148dfd13914e882ccb2a95073c6e9b00b
This commit is contained in:
timhypeng
2020-02-17 14:53:45 +08:00
committed by tim peng
parent 71cb02dc18
commit 6bbd5558ef
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.
*