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

Commit 4b4f6c27 authored by Santiago Seifert's avatar Santiago Seifert
Browse files

Filter routes according to visibility when a router registers

Bug: 284287564
Test: atest MediaRouter2HostSideTest CtsMediaBetterTogetherTestCases
Change-Id: I84e18b2a981dac8666e5cd25686e2ca44ccb3970
parent 7cfd239b
Loading
Loading
Loading
Loading
+21 −6
Original line number Diff line number Diff line
@@ -1637,6 +1637,26 @@ class MediaRouter2ServiceImpl {
            mDiscoveryPreference.dump(pw, indent);
        }

        /**
         * Notifies the corresponding router that it was successfully registered.
         *
         * <p>The message sent to the router includes a snapshot of the initial state, including
         * known routes and the system {@link RoutingSessionInfo}.
         *
         * @param currentRoutes All currently known routes, which are filtered according to package
         *     visibility before being sent to the router.
         * @param currentSystemSessionInfo The current system {@link RoutingSessionInfo}.
         */
        public void notifyRegistered(
                List<MediaRoute2Info> currentRoutes, RoutingSessionInfo currentSystemSessionInfo) {
            try {
                mRouter.notifyRouterRegistered(
                        getVisibleRoutes(currentRoutes), currentSystemSessionInfo);
            } catch (RemoteException ex) {
                Slog.w(TAG, "Failed to notify router registered. Router probably died.", ex);
            }
        }

        /**
         * Sends the corresponding router an {@link
         * android.media.MediaRouter2.RouteCallback#onRoutesUpdated update} for the given {@code
@@ -2536,12 +2556,7 @@ class MediaRouter2ServiceImpl {
                return;
            }

            try {
                routerRecord.mRouter.notifyRouterRegistered(
                        currentRoutes, currentSystemSessionInfo);
            } catch (RemoteException ex) {
                Slog.w(TAG, "Failed to notify router registered. Router probably died.", ex);
            }
            routerRecord.notifyRegistered(currentRoutes, currentSystemSessionInfo);
        }

        private static void notifyRoutesUpdatedToRouterRecords(