MediaRouter: clear session info when disconnected
When MediaRoute2ProviderProxy disconnects, it should clear its session info but it didn't. This CL corrects it such that sessions are released correctly. In addition to that, it also releases the previous controllers when transfer w/ MediaRouter2Manager. Test: manually Change-Id: If827a9473d79e3a154688c0dfaa3075b0e0b6ef5
This commit is contained in:
@@ -247,13 +247,23 @@ public class MediaRouter2Manager {
|
||||
Objects.requireNonNull(packageName, "packageName must not be null");
|
||||
Objects.requireNonNull(route, "route must not be null");
|
||||
|
||||
boolean transferred = false;
|
||||
//TODO: instead of release all controllers, add an API to specify controllers that
|
||||
// should be released (or is the system controller).
|
||||
for (RoutingController controller : getRoutingControllers(packageName)) {
|
||||
if (controller.getSessionInfo().getTransferrableRoutes().contains(route.getId())) {
|
||||
if (!transferred && controller.getSessionInfo().getTransferrableRoutes()
|
||||
.contains(route.getId())) {
|
||||
controller.transferToRoute(route);
|
||||
return;
|
||||
transferred = true;
|
||||
} else if (!controller.getSessionInfo().isSystemSession()) {
|
||||
controller.release();
|
||||
}
|
||||
}
|
||||
|
||||
if (transferred) {
|
||||
return;
|
||||
}
|
||||
|
||||
Client client;
|
||||
synchronized (sLock) {
|
||||
client = mClient;
|
||||
|
||||
@@ -411,6 +411,12 @@ final class MediaRoute2ProviderProxy extends MediaRoute2Provider implements Serv
|
||||
mActiveConnection.dispose();
|
||||
mActiveConnection = null;
|
||||
setAndNotifyProviderState(null);
|
||||
synchronized (mLock) {
|
||||
for (RoutingSessionInfo sessionInfo : mSessionInfos) {
|
||||
mCallback.onSessionReleased(this, sessionInfo);
|
||||
}
|
||||
mSessionInfos.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user