Loading core/api/current.txt +1 −1 Original line number Diff line number Diff line Loading @@ -24427,7 +24427,7 @@ package android.media { method public void registerTransferCallback(@NonNull java.util.concurrent.Executor, @NonNull android.media.MediaRouter2.TransferCallback); method public void setOnGetControllerHintsListener(@Nullable android.media.MediaRouter2.OnGetControllerHintsListener); method public void setRouteListingPreference(@Nullable android.media.RouteListingPreference); method public void showSystemOutputSwitcher(); method public boolean showSystemOutputSwitcher(); method public void stop(); method public void transferTo(@NonNull android.media.MediaRoute2Info); method public void unregisterControllerCallback(@NonNull android.media.MediaRouter2.ControllerCallback); media/java/android/media/IMediaRouterService.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -94,5 +94,5 @@ interface IMediaRouterService { void setSessionVolumeWithManager(IMediaRouter2Manager manager, int requestId, String sessionId, int volume); void releaseSessionWithManager(IMediaRouter2Manager manager, int requestId, String sessionId); void showMediaOutputSwitcher(String packageName); boolean showMediaOutputSwitcher(String packageName); } media/java/android/media/MediaRouter2.java +17 −3 Original line number Diff line number Diff line Loading @@ -461,16 +461,30 @@ public final class MediaRouter2 { } /** * Shows the system UI output switcher. * Shows the system output switcher dialog. * * <p>Should only be called when the context of MediaRouter2 is in the foreground and visible on * the screen. * * <p>The appearance and precise behaviour of the system output switcher dialog may vary across * different devices, OS versions, and form factors, but the basic functionality stays the same. * * <p>See <a * href="https://developer.android.com/guide/topics/media/media-routing#output-switcher">Output * Switcher documentation</a> for more details. * * @return {@code true} if the output switcher dialog is being shown, or {@code false} if the * call is ignored because the app is in the background. */ public void showSystemOutputSwitcher() { public boolean showSystemOutputSwitcher() { synchronized (mLock) { try { mMediaRouterService.showMediaOutputSwitcher(mPackageName); return mMediaRouterService.showMediaOutputSwitcher(mPackageName); } catch (RemoteException ex) { ex.rethrowFromSystemServer(); } } return false; } /** Loading services/core/java/com/android/server/media/MediaRouterService.java +9 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.server.media; import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.RequiresPermission; Loading Loading @@ -248,12 +250,17 @@ public final class MediaRouterService extends IMediaRouterService.Stub // Binder call @Override public void showMediaOutputSwitcher(String packageName) { public boolean showMediaOutputSwitcher(String packageName) { if (!validatePackageName(Binder.getCallingUid(), packageName)) { throw new SecurityException("packageName must match the calling identity"); } final long token = Binder.clearCallingIdentity(); try { if (mContext.getSystemService(ActivityManager.class).getPackageImportance(packageName) > IMPORTANCE_FOREGROUND) { Slog.w(TAG, "showMediaOutputSwitcher only works when called from foreground"); return false; } synchronized (mLock) { StatusBarManagerInternal statusBar = LocalServices.getService(StatusBarManagerInternal.class); Loading @@ -262,6 +269,7 @@ public final class MediaRouterService extends IMediaRouterService.Stub } finally { Binder.restoreCallingIdentity(token); } return true; } // Binder call Loading Loading
core/api/current.txt +1 −1 Original line number Diff line number Diff line Loading @@ -24427,7 +24427,7 @@ package android.media { method public void registerTransferCallback(@NonNull java.util.concurrent.Executor, @NonNull android.media.MediaRouter2.TransferCallback); method public void setOnGetControllerHintsListener(@Nullable android.media.MediaRouter2.OnGetControllerHintsListener); method public void setRouteListingPreference(@Nullable android.media.RouteListingPreference); method public void showSystemOutputSwitcher(); method public boolean showSystemOutputSwitcher(); method public void stop(); method public void transferTo(@NonNull android.media.MediaRoute2Info); method public void unregisterControllerCallback(@NonNull android.media.MediaRouter2.ControllerCallback);
media/java/android/media/IMediaRouterService.aidl +1 −1 Original line number Diff line number Diff line Loading @@ -94,5 +94,5 @@ interface IMediaRouterService { void setSessionVolumeWithManager(IMediaRouter2Manager manager, int requestId, String sessionId, int volume); void releaseSessionWithManager(IMediaRouter2Manager manager, int requestId, String sessionId); void showMediaOutputSwitcher(String packageName); boolean showMediaOutputSwitcher(String packageName); }
media/java/android/media/MediaRouter2.java +17 −3 Original line number Diff line number Diff line Loading @@ -461,16 +461,30 @@ public final class MediaRouter2 { } /** * Shows the system UI output switcher. * Shows the system output switcher dialog. * * <p>Should only be called when the context of MediaRouter2 is in the foreground and visible on * the screen. * * <p>The appearance and precise behaviour of the system output switcher dialog may vary across * different devices, OS versions, and form factors, but the basic functionality stays the same. * * <p>See <a * href="https://developer.android.com/guide/topics/media/media-routing#output-switcher">Output * Switcher documentation</a> for more details. * * @return {@code true} if the output switcher dialog is being shown, or {@code false} if the * call is ignored because the app is in the background. */ public void showSystemOutputSwitcher() { public boolean showSystemOutputSwitcher() { synchronized (mLock) { try { mMediaRouterService.showMediaOutputSwitcher(mPackageName); return mMediaRouterService.showMediaOutputSwitcher(mPackageName); } catch (RemoteException ex) { ex.rethrowFromSystemServer(); } } return false; } /** Loading
services/core/java/com/android/server/media/MediaRouterService.java +9 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.server.media; import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.RequiresPermission; Loading Loading @@ -248,12 +250,17 @@ public final class MediaRouterService extends IMediaRouterService.Stub // Binder call @Override public void showMediaOutputSwitcher(String packageName) { public boolean showMediaOutputSwitcher(String packageName) { if (!validatePackageName(Binder.getCallingUid(), packageName)) { throw new SecurityException("packageName must match the calling identity"); } final long token = Binder.clearCallingIdentity(); try { if (mContext.getSystemService(ActivityManager.class).getPackageImportance(packageName) > IMPORTANCE_FOREGROUND) { Slog.w(TAG, "showMediaOutputSwitcher only works when called from foreground"); return false; } synchronized (mLock) { StatusBarManagerInternal statusBar = LocalServices.getService(StatusBarManagerInternal.class); Loading @@ -262,6 +269,7 @@ public final class MediaRouterService extends IMediaRouterService.Stub } finally { Binder.restoreCallingIdentity(token); } return true; } // Binder call Loading