Merge "MediaRouter2: Add missing synchronized(sRouterLock) block" into rvc-dev am: 5aacc569c7
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/11782206 Change-Id: Ic6c6de8245bd6b4e5365df4d591b87cfd3ef5461
This commit is contained in:
@@ -399,11 +399,16 @@ public final class MediaRouter2 {
|
|||||||
Objects.requireNonNull(controller, "controller must not be null");
|
Objects.requireNonNull(controller, "controller must not be null");
|
||||||
Objects.requireNonNull(route, "route must not be null");
|
Objects.requireNonNull(route, "route must not be null");
|
||||||
|
|
||||||
// TODO(b/157873496): Check thread-safety, at least check "sRouterLock" for every variable
|
boolean routeFound;
|
||||||
if (!mRoutes.containsKey(route.getId())) {
|
synchronized (sRouterLock) {
|
||||||
|
// TODO: Check thread-safety
|
||||||
|
routeFound = mRoutes.containsKey(route.getId());
|
||||||
|
}
|
||||||
|
if (!routeFound) {
|
||||||
notifyTransferFailure(route);
|
notifyTransferFailure(route);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (controller.getRoutingSessionInfo().getTransferableRoutes().contains(route.getId())) {
|
if (controller.getRoutingSessionInfo().getTransferableRoutes().contains(route.getId())) {
|
||||||
controller.transferToRoute(route);
|
controller.transferToRoute(route);
|
||||||
return;
|
return;
|
||||||
@@ -572,10 +577,6 @@ public final class MediaRouter2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void addRoutesOnHandler(List<MediaRoute2Info> routes) {
|
void addRoutesOnHandler(List<MediaRoute2Info> routes) {
|
||||||
// TODO(b/157874065): When onRoutesAdded is first called,
|
|
||||||
// 1) clear mRoutes before adding the routes
|
|
||||||
// 2) Call onRouteSelected(system_route, reason_fallback) if previously selected route
|
|
||||||
// does not exist anymore. => We may need 'boolean MediaRoute2Info#isSystemRoute()'.
|
|
||||||
List<MediaRoute2Info> addedRoutes = new ArrayList<>();
|
List<MediaRoute2Info> addedRoutes = new ArrayList<>();
|
||||||
synchronized (sRouterLock) {
|
synchronized (sRouterLock) {
|
||||||
for (MediaRoute2Info route : routes) {
|
for (MediaRoute2Info route : routes) {
|
||||||
|
|||||||
Reference in New Issue
Block a user