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

Commit a87ff22f authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix route visibility enforcement for proxy routers" into main

parents aab3eaf7 1b358959
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(