Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 47d289e2 authored by Kyunglyul Hyun's avatar Kyunglyul Hyun
Browse files

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
parent d1b467f7
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -247,11 +247,21 @@ 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;
+6 −0
Original line number Diff line number Diff line
@@ -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();
            }
        }
    }