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

Commit dabe3712 authored by Santiago Seifert's avatar Santiago Seifert Committed by Android (Google) Code Review
Browse files

Merge "Make dedup id mandatory for multiple routing type support" into main

parents 32bc5fec 919bed66
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -759,12 +759,29 @@ public abstract class MediaRoute2ProviderService extends Service {

    /**
     * Updates routes of the provider and notifies the system media router service.
     *
     * @throws IllegalArgumentException If {@code routes} contains a route that {@link
     *     MediaRoute2Info#getSupportedRoutingTypes() supports} both system media routing and remote
     *     routing but doesn't contain any {@link MediaRoute2Info#getDeduplicationIds()
     *     deduplication ids}.
     */
    public final void notifyRoutes(@NonNull Collection<MediaRoute2Info> routes) {
        requireNonNull(routes, "routes must not be null");
        List<MediaRoute2Info> sanitizedRoutes = new ArrayList<>(routes.size());

        for (MediaRoute2Info route : routes) {
            if (Flags.enableMirroringInMediaRouter2()
                    && route.supportsRemoteRouting()
                    && route.supportsSystemMediaRouting()
                    && route.getDeduplicationIds().isEmpty()) {
                String errorMessage =
                        TextUtils.formatSimple(
                                "Route with id='%s' name='%s' supports both system media and remote"
                                    + " type routing, but doesn't contain a deduplication id, which"
                                    + " it needs. You can add the route id as a deduplication id.",
                                route.getOriginalId(), route.getName());
                throw new IllegalArgumentException(errorMessage);
            }
            if (route.isSystemRouteType()) {
                Log.w(
                        TAG,
+8 −0
Original line number Diff line number Diff line
@@ -983,6 +983,14 @@ final class MediaRoute2ProviderServiceProxy extends MediaRoute2Provider {
            Objects.requireNonNull(providerInfo, "providerInfo must not be null");

            for (MediaRoute2Info route : providerInfo.getRoutes()) {
                if (Flags.enableMirroringInMediaRouter2()
                        && route.supportsRemoteRouting()
                        && route.supportsSystemMediaRouting()
                        && route.getDeduplicationIds().isEmpty()) {
                    // This code is not accessible if the app is using the public API.
                    throw new SecurityException("Route is missing deduplication id: " + route);
                }

                if (route.isSystemRoute()) {
                    throw new SecurityException(
                            "Only the system is allowed to publish system routes. "