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

Commit 1b358959 authored by Santiago Seifert's avatar Santiago Seifert
Browse files

Fix route visibility enforcement for proxy routers

Test: atest CtsMediaRouterTestCases
Test: atest CtsMediaHostTestCases
Test: Manually using media routing demo app and 3rd party media app
Bug: b/416436531
Flag: com.android.media.flags.enable_fix_for_route_visibility
Change-Id: I81c1e7faabf2483aba57352795994cb1f7f8de00
parent a9f6993e
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -88,6 +88,16 @@ flag {
    }
}

flag {
    name: "enable_fix_for_route_visibility"
    namespace: "media_better_together"
    description: "Fixes a bug causing private routes to appear on the output switcher of an app that shouldn't see them."
    bug: "416436531"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "enable_suggested_device_api"
    is_exported: true
+16 −1
Original line number Diff line number Diff line
@@ -2859,7 +2859,7 @@ class MediaRouter2ServiceImpl {
         */
        public void notifyRoutesUpdated(List<MediaRoute2Info> routes) {
            try {
                mManager.notifyRoutesUpdated(routes);
                mManager.notifyRoutesUpdated(getVisibleRoutes(routes));
            } catch (RemoteException ex) {
                logRemoteException("notifyRoutesUpdated", ex);
            }
@@ -2911,6 +2911,21 @@ class MediaRouter2ServiceImpl {
            }
        }

        private List<MediaRoute2Info> getVisibleRoutes(List<MediaRoute2Info> routes) {
            if (!Flags.enableFixForRouteVisibility() || TextUtils.isEmpty(mTargetPackageName)) {
                // If the proxy router / manager doesn't target a specific app, it sees all
                // routes.
                return routes;
            }
            List<MediaRoute2Info> filteredRoutes = new ArrayList<>();
            for (MediaRoute2Info route : routes) {
                if (route.isVisibleTo(mTargetPackageName)) {
                    filteredRoutes.add(route);
                }
            }
            return filteredRoutes;
        }

        private void logRemoteException(String operation, RemoteException exception) {
            String message =
                    TextUtils.formatSimple(