Merge "Ignore transfer to an unknown route" into rvc-dev

This commit is contained in:
TreeHugger Robot
2020-06-08 11:34:35 +00:00
committed by Android (Google) Code Review
2 changed files with 48 additions and 6 deletions

View File

@@ -342,7 +342,14 @@ public final class MediaRouter2Manager {
Objects.requireNonNull(sessionInfo, "sessionInfo must not be null");
Objects.requireNonNull(route, "route must not be null");
//TODO(b/157875504): Ignore unknown route.
synchronized (mRoutesLock) {
if (!mRoutes.containsKey(route.getId())) {
Log.w(TAG, "transfer: Ignoring an unknown route id=" + route.getId());
notifyTransferFailed(sessionInfo, route);
return;
}
}
if (sessionInfo.getTransferableRoutes().contains(route.getId())) {
transferToRoute(sessionInfo, route);
} else {
@@ -581,7 +588,7 @@ public final class MediaRouter2Manager {
public List<MediaRoute2Info> getSelectedRoutes(@NonNull RoutingSessionInfo sessionInfo) {
Objects.requireNonNull(sessionInfo, "sessionInfo must not be null");
synchronized (sLock) {
synchronized (mRoutesLock) {
return sessionInfo.getSelectedRoutes().stream().map(mRoutes::get)
.filter(Objects::nonNull)
.collect(Collectors.toList());
@@ -597,7 +604,7 @@ public final class MediaRouter2Manager {
List<String> selectedRouteIds = sessionInfo.getSelectedRoutes();
synchronized (sLock) {
synchronized (mRoutesLock) {
return sessionInfo.getSelectableRoutes().stream()
.filter(routeId -> !selectedRouteIds.contains(routeId))
.map(mRoutes::get)
@@ -615,7 +622,7 @@ public final class MediaRouter2Manager {
List<String> selectedRouteIds = sessionInfo.getSelectedRoutes();
synchronized (sLock) {
synchronized (mRoutesLock) {
return sessionInfo.getDeselectableRoutes().stream()
.filter(routeId -> selectedRouteIds.contains(routeId))
.map(mRoutes::get)