diff options
author | 2023-08-01 15:15:19 +0000 | |
---|---|---|
committer | 2023-08-01 15:15:19 +0000 | |
commit | 7ffeed97ecb105a7c5895c39a8584c8ceb1047e2 (patch) | |
tree | ed3998c62a9d61a0bc61d912ad36407490738990 | |
parent | af228ddc075b636bcd23f7bfb15bd5c08499161a (diff) |
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
-rw-r--r-- | media/java/android/media/MediaRouter2.java | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/media/java/android/media/MediaRouter2.java b/media/java/android/media/MediaRouter2.java index 6b67d1452deb..1baae4abeb68 100644 --- a/media/java/android/media/MediaRouter2.java +++ b/media/java/android/media/MediaRouter2.java @@ -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()}. |