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

Commit 2bfe8e32 authored by Iván Budnik's avatar Iván Budnik
Browse files

Do not filter routes on privileged RoutingControllers

With this change, privileged RoutingControllers will stop filtering
routes by feature when providing selected, selectable, and deselectable
routes, which should unify the behaviour between regular and privileged
controllers.

Test: atest MediaRouter2Test SystemMediaRouter2Test
Bug: 289910189
Change-Id: Iae6fa3785ed79f6a8e78618868a21c472387604a
parent 8c1ea99f
Loading
Loading
Loading
Loading
+13 −20
Original line number Diff line number Diff line
@@ -1084,6 +1084,16 @@ public final class MediaRouter2 {
        return filteredRoutes;
    }

    @NonNull
    private List<MediaRoute2Info> getRoutesWithIds(@NonNull List<String> routeIds) {
        synchronized (mLock) {
            return routeIds.stream()
                    .map(mRoutes::get)
                    .filter(Objects::nonNull)
                    .collect(Collectors.toList());
        }
    }

    private void notifyRoutesAdded(List<MediaRoute2Info> routes) {
        for (RouteCallbackRecord record : mRouteCallbackRecords) {
            List<MediaRoute2Info> filteredRoutes =
@@ -1388,7 +1398,7 @@ public final class MediaRouter2 {
            synchronized (mControllerLock) {
                selectedRouteIds = mSessionInfo.getSelectedRoutes();
            }
            return mImpl.getRoutesWithIds(selectedRouteIds);
            return getRoutesWithIds(selectedRouteIds);
        }

        /**
@@ -1400,7 +1410,7 @@ public final class MediaRouter2 {
            synchronized (mControllerLock) {
                selectableRouteIds = mSessionInfo.getSelectableRoutes();
            }
            return mImpl.getRoutesWithIds(selectableRouteIds);
            return getRoutesWithIds(selectableRouteIds);
        }

        /**
@@ -1412,7 +1422,7 @@ public final class MediaRouter2 {
            synchronized (mControllerLock) {
                deselectableRouteIds = mSessionInfo.getDeselectableRoutes();
            }
            return mImpl.getRoutesWithIds(deselectableRouteIds);
            return getRoutesWithIds(deselectableRouteIds);
        }

        /**
@@ -1981,7 +1991,6 @@ public final class MediaRouter2 {
                boolean shouldNotifyStop,
                RoutingController controller);

        List<MediaRoute2Info> getRoutesWithIds(List<String> routeIds);
    }

    /**
@@ -2412,13 +2421,6 @@ public final class MediaRouter2 {
            releaseSession(controller.getRoutingSessionInfo());
        }

        @Override
        public List<MediaRoute2Info> getRoutesWithIds(List<String> routeIds) {
            return getRoutes().stream()
                    .filter(r -> routeIds.contains(r.getId()))
                    .collect(Collectors.toList());
        }

        /**
         * Sets the routing session's {@linkplain RoutingSessionInfo#getClientPackageName() client
         * package name} to {@link #mClientPackageName} if empty and returns the session.
@@ -3065,14 +3067,5 @@ public final class MediaRouter2 {
            }
        }

        @Override
        public List<MediaRoute2Info> getRoutesWithIds(List<String> routeIds) {
            synchronized (mLock) {
                return routeIds.stream()
                        .map(mRoutes::get)
                        .filter(Objects::nonNull)
                        .collect(Collectors.toList());
            }
        }
    }
}