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

Commit 7ffeed97 authored by Iván Budnik's avatar Iván Budnik
Browse files

Throw for showSystemOutputSwitcher() call from privileged router

Previously, a call from a privileged router would have thrown a Security
Exception from MediaRouterService in a similar way to ag/24264289.

Bug: 192657812
Test: atest MediaRouter2Test SystemMediaRouter2Test
Change-Id: I32e27d5dfdd07f1d6dc334ab5e8fd02817006ecf
parent af228ddc
Loading
Loading
Loading
Loading
+21 −8
Original line number Diff line number Diff line
@@ -439,14 +439,7 @@ public final class MediaRouter2 {
     * call is ignored because the app is in the background.
     */
    public boolean showSystemOutputSwitcher() {
        synchronized (mLock) {
            try {
                return mMediaRouterService.showMediaOutputSwitcher(mImpl.getPackageName());
            } catch (RemoteException ex) {
                ex.rethrowFromSystemServer();
            }
        }
        return false;
        return mImpl.showSystemOutputSwitcher();
    }

    /**
@@ -1950,6 +1943,8 @@ public final class MediaRouter2 {

        void setRouteListingPreference(@Nullable RouteListingPreference preference);

        boolean showSystemOutputSwitcher();

        List<MediaRoute2Info> getAllRoutes();

        void setOnGetControllerHintsListener(OnGetControllerHintsListener listener);
@@ -2096,6 +2091,12 @@ public final class MediaRouter2 {
                    "RouteListingPreference cannot be set by a privileged MediaRouter2 instance.");
        }

        @Override
        public boolean showSystemOutputSwitcher() {
            throw new UnsupportedOperationException(
                    "Cannot show system output switcher from a privileged router.");
        }

        /** Gets the list of all discovered routes. */
        @Override
        public List<MediaRoute2Info> getAllRoutes() {
@@ -2908,6 +2909,18 @@ public final class MediaRouter2 {
            }
        }

        @Override
        public boolean showSystemOutputSwitcher() {
            synchronized (mLock) {
                try {
                    return mMediaRouterService.showMediaOutputSwitcher(mImpl.getPackageName());
                } catch (RemoteException ex) {
                    ex.rethrowFromSystemServer();
                }
            }
            return false;
        }

        /**
         * Returns {@link Collections#emptyList()}. Local routes can only access routes related to
         * their {@link RouteDiscoveryPreference} through {@link #getRoutes()}.