mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Switch play FGS exemption to use custom action instead of commands
Custom actions are more naturally associated with a user intent than commands (that are meant to be used for automated inter-app communication without user interaction). PiperOrigin-RevId: 705797057
This commit is contained in:
parent
83b5eb0040
commit
3bce3af1a3
@ -417,8 +417,9 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
if (Util.SDK_INT >= 31 && platformController != null) {
|
||||
// Ensure the platform session gets allow-listed to start a foreground service after receiving
|
||||
// the play command.
|
||||
platformController.sendCommand(
|
||||
MediaConstants.SESSION_COMMAND_MEDIA3_PLAY_REQUEST, /* args= */ null, /* cb= */ null);
|
||||
platformController
|
||||
.getTransportControls()
|
||||
.sendCustomAction(MediaConstants.SESSION_COMMAND_MEDIA3_PLAY_REQUEST, /* args= */ null);
|
||||
}
|
||||
|
||||
dispatchRemoteSessionTaskWithPlayerCommand(
|
||||
|
@ -281,7 +281,8 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
public void onCommand(String commandName, @Nullable Bundle args, @Nullable ResultReceiver cb) {
|
||||
checkStateNotNull(commandName);
|
||||
if (commandName.equals(MediaConstants.SESSION_COMMAND_MEDIA3_PLAY_REQUEST)) {
|
||||
// Ignore, no need to handle this command here.
|
||||
// Only applicable to controllers on Media3 1.5, where this command was sent via sendCommand
|
||||
// instead of sendCustomAction. No need to handle this command here.
|
||||
return;
|
||||
}
|
||||
if (commandName.equals(MediaConstants.SESSION_COMMAND_REQUEST_SESSION3_TOKEN) && cb != null) {
|
||||
@ -305,6 +306,10 @@ import org.checkerframework.checker.initialization.qual.Initialized;
|
||||
|
||||
@Override
|
||||
public void onCustomAction(String action, @Nullable Bundle args) {
|
||||
if (action.equals(MediaConstants.SESSION_COMMAND_MEDIA3_PLAY_REQUEST)) {
|
||||
// Ignore, no need to handle the custom action.
|
||||
return;
|
||||
}
|
||||
SessionCommand command = new SessionCommand(action, /* extras= */ Bundle.EMPTY);
|
||||
dispatchSessionTaskWithSessionCommand(
|
||||
command,
|
||||
|
Loading…
x
Reference in New Issue
Block a user