Commit 687362e6 by tonihei

Document that custom commands can only be sent if they are defined

Custom commands from controller to session are blocked if they are
not listed in the available session command list. This isn't well
documented in the Javadoc currently.

#minor-release

PiperOrigin-RevId: 514733568
(cherry picked from commit 20669fca)
parent e7f49a8c
...@@ -905,13 +905,14 @@ public class MediaController implements Player { ...@@ -905,13 +905,14 @@ public class MediaController implements Player {
/** /**
* Sends a custom command to the session. * Sends a custom command to the session.
* *
* <p>A command is not accepted if it is not a custom command or the command is not in the list of
* {@linkplain #getAvailableSessionCommands() available session commands}.
*
* <p>Interoperability: When connected to {@link * <p>Interoperability: When connected to {@link
* android.support.v4.media.session.MediaSessionCompat}, {@link SessionResult#resultCode} will * android.support.v4.media.session.MediaSessionCompat}, {@link SessionResult#resultCode} will
* return the custom result code from the {@code android.os.ResultReceiver#onReceiveResult(int, * return the custom result code from the {@code android.os.ResultReceiver#onReceiveResult(int,
* Bundle)} instead of the standard result codes defined in the {@link SessionResult}. * Bundle)} instead of the standard result codes defined in the {@link SessionResult}.
* *
* <p>A command is not accepted if it is not a custom command.
*
* @param command The custom command. * @param command The custom command.
* @param args The additional arguments. May be empty. * @param args The additional arguments. May be empty.
* @return A {@link ListenableFuture} of {@link SessionResult} representing the pending * @return A {@link ListenableFuture} of {@link SessionResult} representing the pending
......
...@@ -1042,6 +1042,10 @@ public class MediaSession { ...@@ -1042,6 +1042,10 @@ public class MediaSession {
* Called when a controller sent a custom command through {@link * Called when a controller sent a custom command through {@link
* MediaController#sendCustomCommand(SessionCommand, Bundle)}. * MediaController#sendCustomCommand(SessionCommand, Bundle)}.
* *
* <p>{@link MediaController} instances are only allowed to send a command if the command has
* been added to the {@link MediaSession.ConnectionResult#availableSessionCommands list of
* available session commands} in {@link #onConnect} or set via {@link #setAvailableCommands}.
*
* <p>Interoperability: This will be also called by {@link * <p>Interoperability: This will be also called by {@link
* android.support.v4.media.MediaBrowserCompat#sendCustomAction}. If so, {@code extras} from * android.support.v4.media.MediaBrowserCompat#sendCustomAction}. If so, {@code extras} from
* {@link android.support.v4.media.MediaBrowserCompat#sendCustomAction} will be considered as * {@link android.support.v4.media.MediaBrowserCompat#sendCustomAction} will be considered as
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment