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

Commit 941c860f authored by Iván Budnik's avatar Iván Budnik Committed by Android (Google) Code Review
Browse files

Merge "Initialize mSystemController before creating ProxyMediaRouter2Impl" into main

parents 69b2fb83 41165af8
Loading
Loading
Loading
Loading
+22 −8
Original line number Diff line number Diff line
@@ -310,8 +310,11 @@ public final class MediaRouter2 {
                IMediaRouterService.Stub.asInterface(
                        ServiceManager.getService(Context.MEDIA_ROUTER_SERVICE));

        mSystemController =
                new SystemRoutingController(
                        ProxyMediaRouter2Impl.getSystemSessionInfoImpl(
                                mMediaRouterService, clientPackageName));
        mImpl = new ProxyMediaRouter2Impl(context, clientPackageName);
        mSystemController = new SystemRoutingController(mImpl.getSystemSessionInfo());
    }

    /**
@@ -2057,13 +2060,7 @@ public final class MediaRouter2 {

        @Override
        public RoutingSessionInfo getSystemSessionInfo() {
            RoutingSessionInfo result;
            try {
                result = mMediaRouterService.getSystemSessionInfoForPackage(mClientPackageName);
            } catch (RemoteException ex) {
                throw ex.rethrowFromSystemServer();
            }
            return ensureClientPackageNameForSystemSession(result);
            return getSystemSessionInfoImpl(mMediaRouterService, mClientPackageName);
        }

        /**
@@ -2427,6 +2424,23 @@ public final class MediaRouter2 {
            releaseSession(controller.getRoutingSessionInfo());
        }

        /**
         * Retrieves the system session info for the given package.
         *
         * <p>The returned routing session is guaranteed to have a non-null {@link
         * RoutingSessionInfo#getClientPackageName() client package name}.
         *
         * <p>Extracted into a static method to allow calling this from the constructor.
         */
        /* package */ static RoutingSessionInfo getSystemSessionInfoImpl(
                @NonNull IMediaRouterService service, @NonNull String clientPackageName) {
            try {
                return service.getSystemSessionInfoForPackage(clientPackageName);
            } catch (RemoteException ex) {
                throw ex.rethrowFromSystemServer();
            }
        }

        /**
         * Sets the routing session's {@linkplain RoutingSessionInfo#getClientPackageName() client
         * package name} to {@link #mClientPackageName} if empty and returns the session.