Merge "Revert "MediaSession: Add methods for queue managements"" into oc-dev

am: a44d7cd25b

Change-Id: I0831739bd0eb7317ea69adc7569d86e11a1f9fb3
This commit is contained in:
Sungsoo Lim
2017-04-18 00:46:57 +00:00
committed by android-build-merger
8 changed files with 45 additions and 355 deletions

View File

@@ -24254,8 +24254,6 @@ package android.media.session {
public final class MediaController {
ctor public MediaController(android.content.Context, android.media.session.MediaSession.Token);
method public void addQueueItem(android.media.MediaDescription);
method public void addQueueItem(android.media.MediaDescription, int);
method public void adjustVolume(int, int);
method public boolean dispatchMediaButtonEvent(android.view.KeyEvent);
method public android.os.Bundle getExtras();
@@ -24274,8 +24272,6 @@ package android.media.session {
method public boolean isShuffleModeEnabled();
method public void registerCallback(android.media.session.MediaController.Callback);
method public void registerCallback(android.media.session.MediaController.Callback, android.os.Handler);
method public void removeQueueItem(android.media.MediaDescription);
method public void removeQueueItemAt(int);
method public void sendCommand(java.lang.String, android.os.Bundle, android.os.ResultReceiver);
method public void setVolumeTo(int, int);
method public void unregisterCallback(android.media.session.MediaController.Callback);
@@ -24353,14 +24349,11 @@ package android.media.session {
method public void setSessionActivity(android.app.PendingIntent);
method public void setShuffleModeEnabled(boolean);
field public static final deprecated int FLAG_HANDLES_MEDIA_BUTTONS = 1; // 0x1
field public static final int FLAG_HANDLES_QUEUE_COMMANDS = 4; // 0x4
field public static final deprecated int FLAG_HANDLES_TRANSPORT_CONTROLS = 2; // 0x2
}
public static abstract class MediaSession.Callback {
ctor public MediaSession.Callback();
method public void onAddQueueItem(android.media.MediaDescription);
method public void onAddQueueItem(android.media.MediaDescription, int);
method public void onCommand(java.lang.String, android.os.Bundle, android.os.ResultReceiver);
method public void onCustomAction(java.lang.String, android.os.Bundle);
method public void onFastForward();
@@ -24374,8 +24367,6 @@ package android.media.session {
method public void onPrepareFromMediaId(java.lang.String, android.os.Bundle);
method public void onPrepareFromSearch(java.lang.String, android.os.Bundle);
method public void onPrepareFromUri(android.net.Uri, android.os.Bundle);
method public void onRemoveQueueItem(android.media.MediaDescription);
method public void onRemoveQueueItemAt(int);
method public void onRewind();
method public void onSeekTo(long);
method public void onSetRating(android.media.Rating);

View File

@@ -26176,8 +26176,6 @@ package android.media.session {
public final class MediaController {
ctor public MediaController(android.content.Context, android.media.session.MediaSession.Token);
method public void addQueueItem(android.media.MediaDescription);
method public void addQueueItem(android.media.MediaDescription, int);
method public void adjustVolume(int, int);
method public boolean dispatchMediaButtonEvent(android.view.KeyEvent);
method public android.os.Bundle getExtras();
@@ -26196,8 +26194,6 @@ package android.media.session {
method public boolean isShuffleModeEnabled();
method public void registerCallback(android.media.session.MediaController.Callback);
method public void registerCallback(android.media.session.MediaController.Callback, android.os.Handler);
method public void removeQueueItem(android.media.MediaDescription);
method public void removeQueueItemAt(int);
method public void sendCommand(java.lang.String, android.os.Bundle, android.os.ResultReceiver);
method public void setVolumeTo(int, int);
method public void unregisterCallback(android.media.session.MediaController.Callback);
@@ -26275,14 +26271,11 @@ package android.media.session {
method public void setSessionActivity(android.app.PendingIntent);
method public void setShuffleModeEnabled(boolean);
field public static final deprecated int FLAG_HANDLES_MEDIA_BUTTONS = 1; // 0x1
field public static final int FLAG_HANDLES_QUEUE_COMMANDS = 4; // 0x4
field public static final deprecated int FLAG_HANDLES_TRANSPORT_CONTROLS = 2; // 0x2
}
public static abstract class MediaSession.Callback {
ctor public MediaSession.Callback();
method public void onAddQueueItem(android.media.MediaDescription);
method public void onAddQueueItem(android.media.MediaDescription, int);
method public void onCommand(java.lang.String, android.os.Bundle, android.os.ResultReceiver);
method public void onCustomAction(java.lang.String, android.os.Bundle);
method public void onFastForward();
@@ -26296,8 +26289,6 @@ package android.media.session {
method public void onPrepareFromMediaId(java.lang.String, android.os.Bundle);
method public void onPrepareFromSearch(java.lang.String, android.os.Bundle);
method public void onPrepareFromUri(android.net.Uri, android.os.Bundle);
method public void onRemoveQueueItem(android.media.MediaDescription);
method public void onRemoveQueueItemAt(int);
method public void onRewind();
method public void onSeekTo(long);
method public void onSetRating(android.media.Rating);

View File

@@ -24361,8 +24361,6 @@ package android.media.session {
public final class MediaController {
ctor public MediaController(android.content.Context, android.media.session.MediaSession.Token);
method public void addQueueItem(android.media.MediaDescription);
method public void addQueueItem(android.media.MediaDescription, int);
method public void adjustVolume(int, int);
method public boolean dispatchMediaButtonEvent(android.view.KeyEvent);
method public android.os.Bundle getExtras();
@@ -24381,8 +24379,6 @@ package android.media.session {
method public boolean isShuffleModeEnabled();
method public void registerCallback(android.media.session.MediaController.Callback);
method public void registerCallback(android.media.session.MediaController.Callback, android.os.Handler);
method public void removeQueueItem(android.media.MediaDescription);
method public void removeQueueItemAt(int);
method public void sendCommand(java.lang.String, android.os.Bundle, android.os.ResultReceiver);
method public void setVolumeTo(int, int);
method public void unregisterCallback(android.media.session.MediaController.Callback);
@@ -24460,14 +24456,11 @@ package android.media.session {
method public void setSessionActivity(android.app.PendingIntent);
method public void setShuffleModeEnabled(boolean);
field public static final deprecated int FLAG_HANDLES_MEDIA_BUTTONS = 1; // 0x1
field public static final int FLAG_HANDLES_QUEUE_COMMANDS = 4; // 0x4
field public static final deprecated int FLAG_HANDLES_TRANSPORT_CONTROLS = 2; // 0x2
}
public static abstract class MediaSession.Callback {
ctor public MediaSession.Callback();
method public void onAddQueueItem(android.media.MediaDescription);
method public void onAddQueueItem(android.media.MediaDescription, int);
method public void onCommand(java.lang.String, android.os.Bundle, android.os.ResultReceiver);
method public void onCustomAction(java.lang.String, android.os.Bundle);
method public void onFastForward();
@@ -24481,8 +24474,6 @@ package android.media.session {
method public void onPrepareFromMediaId(java.lang.String, android.os.Bundle);
method public void onPrepareFromSearch(java.lang.String, android.os.Bundle);
method public void onPrepareFromUri(android.net.Uri, android.os.Bundle);
method public void onRemoveQueueItem(android.media.MediaDescription);
method public void onRemoveQueueItemAt(int);
method public void onRewind();
method public void onSeekTo(long);
method public void onSetRating(android.media.Rating);

View File

@@ -16,7 +16,6 @@
package android.media.session;
import android.content.Intent;
import android.media.MediaDescription;
import android.media.Rating;
import android.net.Uri;
import android.os.Bundle;
@@ -50,10 +49,6 @@ oneway interface ISessionCallback {
void onRepeatMode(int repeatMode);
void onShuffleMode(boolean enabled);
void onCustomAction(String action, in Bundle args);
void onAddQueueItem(in MediaDescription description);
void onAddQueueItemAt(in MediaDescription description, int index);
void onRemoveQueueItem(in MediaDescription description);
void onRemoveQueueItemAt(int index);
// These callbacks are for volume handling
void onAdjustVolume(int direction);

View File

@@ -18,7 +18,6 @@ package android.media.session;
import android.app.PendingIntent;
import android.content.Intent;
import android.content.pm.ParceledListSlice;
import android.media.MediaDescription;
import android.media.MediaMetadata;
import android.media.Rating;
import android.media.session.ISessionControllerCallback;
@@ -52,11 +51,6 @@ interface ISessionController {
MediaMetadata getMetadata();
PlaybackState getPlaybackState();
ParceledListSlice getQueue();
void addQueueItem(in MediaDescription description);
void addQueueItemAt(in MediaDescription description, int index);
void removeQueueItem(in MediaDescription description);
void removeQueueItemAt(int index);
CharSequence getQueueTitle();
Bundle getExtras();
int getRatingType();

View File

@@ -23,7 +23,6 @@ import android.content.Context;
import android.content.pm.ParceledListSlice;
import android.media.AudioAttributes;
import android.media.AudioManager;
import android.media.MediaDescription;
import android.media.MediaMetadata;
import android.media.Rating;
import android.media.VolumeProvider;
@@ -39,7 +38,6 @@ import android.util.Log;
import android.view.KeyEvent;
import java.lang.ref.WeakReference;
import java.lang.UnsupportedOperationException;
import java.util.ArrayList;
import java.util.List;
@@ -113,7 +111,8 @@ public final class MediaController {
}
/**
* Get a {@link TransportControls} instance to send transport actions to this session.
* Get a {@link TransportControls} instance to send transport actions to
* the associated session.
*
* @return A transport controls instance.
*/
@@ -152,7 +151,7 @@ public final class MediaController {
try {
return mSessionBinder.getPlaybackState();
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling getPlaybackState", e);
Log.wtf(TAG, "Error calling getPlaybackState.", e);
return null;
}
}
@@ -166,7 +165,7 @@ public final class MediaController {
try {
return mSessionBinder.getMetadata();
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling getMetadata", e);
Log.wtf(TAG, "Error calling getMetadata.", e);
return null;
}
}
@@ -184,102 +183,11 @@ public final class MediaController {
return queue.getList();
}
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling getQueue", e);
Log.wtf(TAG, "Error calling getQueue.", e);
}
return null;
}
/**
* Add a queue item from the given {@code description} at the end of the play queue
* of this session. Not all sessions may support this.
*
* @param description The {@link MediaDescription} for creating the
* {@link MediaSession.QueueItem} to be inserted.
* @throws UnsupportedOperationException If this session doesn't support this.
* @see MediaSession#FLAG_HANDLES_QUEUE_COMMANDS
*/
public void addQueueItem(MediaDescription description) {
try {
long flags = mSessionBinder.getFlags();
if ((flags & MediaSession.FLAG_HANDLES_QUEUE_COMMANDS) == 0) {
throw new UnsupportedOperationException(
"This session doesn't support queue management operations");
}
mSessionBinder.addQueueItem(description);
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling addQueueItem", e);
}
}
/**
* Add a queue item from the given {@code description} at the specified position
* in the play queue of this session. Shifts the queue item currently at that position
* (if any) and any subsequent queue items to the right (adds one to their indices).
* Not all sessions may support this.
*
* @param description The {@link MediaDescription} for creating the
* {@link MediaSession.QueueItem} to be inserted.
* @param index The index at which the created {@link MediaSession.QueueItem} is to be inserted.
* @throws UnsupportedOperationException If this session doesn't support this.
* @see MediaSession#FLAG_HANDLES_QUEUE_COMMANDS
*/
public void addQueueItem(MediaDescription description, int index) {
try {
long flags = mSessionBinder.getFlags();
if ((flags & MediaSession.FLAG_HANDLES_QUEUE_COMMANDS) == 0) {
throw new UnsupportedOperationException(
"This session doesn't support queue management operations");
}
mSessionBinder.addQueueItemAt(description, index);
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling addQueueItemAt", e);
}
}
/**
* Remove the first occurrence of the specified {@link MediaSession.QueueItem}
* with the given {@link MediaDescription description} in the play queue of the associated
* session. Not all sessions may support this.
*
* @param description The {@link MediaDescription} for denoting the
* {@link MediaSession.QueueItem} to be removed.
* @throws UnsupportedOperationException If this session doesn't support this.
* @see MediaSession#FLAG_HANDLES_QUEUE_COMMANDS
*/
public void removeQueueItem(MediaDescription description) {
try {
long flags = mSessionBinder.getFlags();
if ((flags & MediaSession.FLAG_HANDLES_QUEUE_COMMANDS) == 0) {
throw new UnsupportedOperationException(
"This session doesn't support queue management operations");
}
mSessionBinder.removeQueueItem(description);
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling removeQueueItem", e);
}
}
/**
* Remove an queue item at the specified position in the play queue
* of this session. Not all sessions may support this.
*
* @param index The index of the element to be removed.
* @throws UnsupportedOperationException If this session doesn't support this.
* @see MediaSession#FLAG_HANDLES_QUEUE_COMMANDS
*/
public void removeQueueItemAt(int index) {
try {
long flags = mSessionBinder.getFlags();
if ((flags & MediaSession.FLAG_HANDLES_QUEUE_COMMANDS) == 0) {
throw new UnsupportedOperationException(
"This session doesn't support queue management operations");
}
mSessionBinder.removeQueueItemAt(index);
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling removeQueueItemAt", e);
}
}
/**
* Get the queue title for this session.
*/
@@ -322,7 +230,7 @@ public final class MediaController {
try {
return mSessionBinder.getRatingType();
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling getRatingType", e);
Log.wtf(TAG, "Error calling getRatingType.", e);
return Rating.RATING_NONE;
}
}
@@ -337,7 +245,7 @@ public final class MediaController {
try {
return mSessionBinder.getRepeatMode();
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling getRepeatMode", e);
Log.wtf(TAG, "Error calling getRepeatMode.", e);
return PlaybackState.REPEAT_MODE_NONE;
}
}
@@ -351,7 +259,7 @@ public final class MediaController {
try {
return mSessionBinder.isShuffleModeEnabled();
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling isShuffleModeEnabled", e);
Log.wtf(TAG, "Error calling isShuffleModeEnabled.", e);
return false;
}
}
@@ -365,7 +273,7 @@ public final class MediaController {
try {
return mSessionBinder.getFlags();
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling getFlags", e);
Log.wtf(TAG, "Error calling getFlags.", e);
}
return 0;
}
@@ -382,7 +290,7 @@ public final class MediaController {
result.maxVolume, result.currentVolume);
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling getAudioInfo", e);
Log.wtf(TAG, "Error calling getAudioInfo.", e);
}
return null;
}
@@ -397,7 +305,7 @@ public final class MediaController {
try {
return mSessionBinder.getLaunchPendingIntent();
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling getPendingIntent", e);
Log.wtf(TAG, "Error calling getPendingIntent.", e);
}
return null;
}
@@ -426,7 +334,7 @@ public final class MediaController {
try {
mSessionBinder.setVolumeTo(value, flags, mContext.getPackageName());
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling setVolumeTo", e);
Log.wtf(TAG, "Error calling setVolumeTo.", e);
}
}
@@ -447,7 +355,7 @@ public final class MediaController {
try {
mSessionBinder.adjustVolume(direction, flags, mContext.getPackageName());
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling adjustVolumeBy", e);
Log.wtf(TAG, "Error calling adjustVolumeBy.", e);
}
}
@@ -513,7 +421,7 @@ public final class MediaController {
try {
mSessionBinder.sendCommand(command, args, cb);
} catch (RemoteException e) {
Log.d(TAG, "Dead object in sendCommand", e);
Log.d(TAG, "Dead object in sendCommand.", e);
}
}
@@ -527,7 +435,7 @@ public final class MediaController {
try {
mPackageName = mSessionBinder.getPackageName();
} catch (RemoteException e) {
Log.d(TAG, "Dead object in getPackageName", e);
Log.d(TAG, "Dead object in getPackageName.", e);
}
}
return mPackageName;
@@ -544,7 +452,7 @@ public final class MediaController {
try {
mTag = mSessionBinder.getTag();
} catch (RemoteException e) {
Log.d(TAG, "Dead object in getTag", e);
Log.d(TAG, "Dead object in getTag.", e);
}
}
return mTag;
@@ -744,7 +652,7 @@ public final class MediaController {
try {
mSessionBinder.prepare();
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling prepare", e);
Log.wtf(TAG, "Error calling prepare.", e);
}
}
@@ -763,12 +671,12 @@ public final class MediaController {
public void prepareFromMediaId(String mediaId, Bundle extras) {
if (TextUtils.isEmpty(mediaId)) {
throw new IllegalArgumentException(
"You must specify a non-empty String for prepareFromMediaId");
"You must specify a non-empty String for prepareFromMediaId.");
}
try {
mSessionBinder.prepareFromMediaId(mediaId, extras);
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling prepare(" + mediaId + ")", e);
Log.wtf(TAG, "Error calling prepare(" + mediaId + ").", e);
}
}
@@ -794,7 +702,7 @@ public final class MediaController {
try {
mSessionBinder.prepareFromSearch(query, extras);
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling prepare(" + query + ")", e);
Log.wtf(TAG, "Error calling prepare(" + query + ").", e);
}
}
@@ -813,12 +721,12 @@ public final class MediaController {
public void prepareFromUri(Uri uri, Bundle extras) {
if (uri == null || Uri.EMPTY.equals(uri)) {
throw new IllegalArgumentException(
"You must specify a non-empty Uri for prepareFromUri");
"You must specify a non-empty Uri for prepareFromUri.");
}
try {
mSessionBinder.prepareFromUri(uri, extras);
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling prepare(" + uri + ")", e);
Log.wtf(TAG, "Error calling prepare(" + uri + ").", e);
}
}
@@ -829,7 +737,7 @@ public final class MediaController {
try {
mSessionBinder.play();
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling play", e);
Log.wtf(TAG, "Error calling play.", e);
}
}
@@ -843,12 +751,12 @@ public final class MediaController {
public void playFromMediaId(String mediaId, Bundle extras) {
if (TextUtils.isEmpty(mediaId)) {
throw new IllegalArgumentException(
"You must specify a non-empty String for playFromMediaId");
"You must specify a non-empty String for playFromMediaId.");
}
try {
mSessionBinder.playFromMediaId(mediaId, extras);
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling play(" + mediaId + ")", e);
Log.wtf(TAG, "Error calling play(" + mediaId + ").", e);
}
}
@@ -870,7 +778,7 @@ public final class MediaController {
try {
mSessionBinder.playFromSearch(query, extras);
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling play(" + query + ")", e);
Log.wtf(TAG, "Error calling play(" + query + ").", e);
}
}
@@ -884,12 +792,12 @@ public final class MediaController {
public void playFromUri(Uri uri, Bundle extras) {
if (uri == null || Uri.EMPTY.equals(uri)) {
throw new IllegalArgumentException(
"You must specify a non-empty Uri for playFromUri");
"You must specify a non-empty Uri for playFromUri.");
}
try {
mSessionBinder.playFromUri(uri, extras);
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling play(" + uri + ")", e);
Log.wtf(TAG, "Error calling play(" + uri + ").", e);
}
}
@@ -901,7 +809,7 @@ public final class MediaController {
try {
mSessionBinder.skipToQueueItem(id);
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling skipToItem(" + id + ")", e);
Log.wtf(TAG, "Error calling skipToItem(" + id + ").", e);
}
}
@@ -913,7 +821,7 @@ public final class MediaController {
try {
mSessionBinder.pause();
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling pause", e);
Log.wtf(TAG, "Error calling pause.", e);
}
}
@@ -925,7 +833,7 @@ public final class MediaController {
try {
mSessionBinder.stop();
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling stop", e);
Log.wtf(TAG, "Error calling stop.", e);
}
}
@@ -938,7 +846,7 @@ public final class MediaController {
try {
mSessionBinder.seekTo(pos);
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling seekTo", e);
Log.wtf(TAG, "Error calling seekTo.", e);
}
}
@@ -950,7 +858,7 @@ public final class MediaController {
try {
mSessionBinder.fastForward();
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling fastForward", e);
Log.wtf(TAG, "Error calling fastForward.", e);
}
}
@@ -961,7 +869,7 @@ public final class MediaController {
try {
mSessionBinder.next();
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling next", e);
Log.wtf(TAG, "Error calling next.", e);
}
}
@@ -973,7 +881,7 @@ public final class MediaController {
try {
mSessionBinder.rewind();
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling rewind", e);
Log.wtf(TAG, "Error calling rewind.", e);
}
}
@@ -984,7 +892,7 @@ public final class MediaController {
try {
mSessionBinder.previous();
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling previous", e);
Log.wtf(TAG, "Error calling previous.", e);
}
}
@@ -999,7 +907,7 @@ public final class MediaController {
try {
mSessionBinder.rate(rating);
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling rate", e);
Log.wtf(TAG, "Error calling rate.", e);
}
}
@@ -1015,7 +923,7 @@ public final class MediaController {
try {
mSessionBinder.repeatMode(repeatMode);
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling setRepeatMode", e);
Log.wtf(TAG, "Error calling setRepeatMode.", e);
}
}
@@ -1028,7 +936,7 @@ public final class MediaController {
try {
mSessionBinder.shuffleMode(enabled);
} catch (RemoteException e) {
Log.wtf(TAG, "Error calling shuffleMode", e);
Log.wtf(TAG, "Error calling shuffleMode.", e);
}
}
@@ -1042,7 +950,7 @@ public final class MediaController {
public void sendCustomAction(@NonNull PlaybackState.CustomAction customAction,
@Nullable Bundle args) {
if (customAction == null) {
throw new IllegalArgumentException("CustomAction cannot be null");
throw new IllegalArgumentException("CustomAction cannot be null.");
}
sendCustomAction(customAction.getAction(), args);
}
@@ -1058,12 +966,12 @@ public final class MediaController {
*/
public void sendCustomAction(@NonNull String action, @Nullable Bundle args) {
if (TextUtils.isEmpty(action)) {
throw new IllegalArgumentException("CustomAction cannot be null");
throw new IllegalArgumentException("CustomAction cannot be null.");
}
try {
mSessionBinder.sendCustomAction(action, args);
} catch (RemoteException e) {
Log.d(TAG, "Dead object in sendCustomAction", e);
Log.d(TAG, "Dead object in sendCustomAction.", e);
}
}
}

View File

@@ -92,12 +92,6 @@ public final class MediaSession {
@Deprecated
public static final int FLAG_HANDLES_TRANSPORT_CONTROLS = 1 << 1;
/**
* Set this flag on the session to indicate that it handles queue
* management commands through its {@link Callback}.
*/
public static final int FLAG_HANDLES_QUEUE_COMMANDS = 1 << 2;
/**
* System only flag for a session that needs to have priority over all other
* sessions. This flag ensures this session will receive media button events
@@ -112,7 +106,6 @@ public final class MediaSession {
@IntDef(flag = true, value = {
FLAG_HANDLES_MEDIA_BUTTONS,
FLAG_HANDLES_TRANSPORT_CONTROLS,
FLAG_HANDLES_QUEUE_COMMANDS,
FLAG_EXCLUSIVE_GLOBAL_PRIORITY })
public @interface SessionFlags { }
@@ -658,22 +651,6 @@ public final class MediaSession {
postToCallback(CallbackMessageHandler.MSG_CUSTOM_ACTION, action, args);
}
private void dispatchAddQueueItem(MediaDescription description) {
postToCallback(CallbackMessageHandler.MSG_ADD_QUEUE_ITEM, description);
}
private void dispatchAddQueueItem(MediaDescription description, int index) {
postToCallback(CallbackMessageHandler.MSG_ADD_QUEUE_ITEM_AT, description, index);
}
private void dispatchRemoveQueueItem(MediaDescription description) {
postToCallback(CallbackMessageHandler.MSG_REMOVE_QUEUE_ITEM, description);
}
private void dispatchRemoveQueueItemAt(int index) {
postToCallback(CallbackMessageHandler.MSG_REMOVE_QUEUE_ITEM_AT, index);
}
private void dispatchMediaButton(Intent mediaButtonIntent) {
postToCallback(CallbackMessageHandler.MSG_MEDIA_BUTTON, mediaButtonIntent);
}
@@ -695,22 +672,10 @@ public final class MediaSession {
postToCallback(CallbackMessageHandler.MSG_COMMAND, cmd);
}
private void postToCallback(int what, int arg1) {
postToCallback(what, null, arg1);
}
private void postToCallback(int what, Object obj) {
postToCallback(what, obj, null);
}
private void postToCallback(int what, Object obj, int arg1) {
synchronized (mLock) {
if (mCallback != null) {
mCallback.post(what, obj, arg1);
}
}
}
private void postToCallback(int what, Object obj, Bundle extras) {
synchronized (mLock) {
if (mCallback != null) {
@@ -1084,47 +1049,6 @@ public final class MediaSession {
*/
public void onCustomAction(@NonNull String action, @Nullable Bundle extras) {
}
/**
* Called when a {@link MediaController} wants to add a {@link QueueItem} with the given
* {@link MediaDescription description} at the end of the play queue.
*
* @param description The {@link MediaDescription} for creating the {@link QueueItem} to be
* inserted.
*/
public void onAddQueueItem(MediaDescription description) {
}
/**
* Called when a {@link MediaController} wants to add a {@link QueueItem} with the given
* {@link MediaDescription description} at the specified position in the play queue.
*
* @param description The {@link MediaDescription} for creating the {@link QueueItem} to be
* inserted.
* @param index The index at which the created {@link QueueItem} is to be inserted.
*/
public void onAddQueueItem(MediaDescription description, int index) {
}
/**
* Called when a {@link MediaController} wants to remove the first occurrence of the
* specified {@link QueueItem} with the given {@link MediaDescription description}
* in the play queue.
*
* @param description The {@link MediaDescription} for denoting the {@link QueueItem} to be
* removed.
*/
public void onRemoveQueueItem(MediaDescription description) {
}
/**
* Called when a {@link MediaController} wants to remove a {@link QueueItem} at the
* specified position in the play queue.
*
* @param index The index of the element to be removed.
*/
public void onRemoveQueueItemAt(int index) {
}
}
/**
@@ -1320,38 +1244,6 @@ public final class MediaSession {
}
}
@Override
public void onAddQueueItem(MediaDescription description) {
MediaSession session = mMediaSession.get();
if (session != null) {
session.dispatchAddQueueItem(description);
}
}
@Override
public void onAddQueueItemAt(MediaDescription description, int index) {
MediaSession session = mMediaSession.get();
if (session != null) {
session.dispatchAddQueueItem(description, index);
}
}
@Override
public void onRemoveQueueItem(MediaDescription description) {
MediaSession session = mMediaSession.get();
if (session != null) {
session.dispatchRemoveQueueItem(description);
}
}
@Override
public void onRemoveQueueItemAt(int index) {
MediaSession session = mMediaSession.get();
if (session != null) {
session.dispatchRemoveQueueItemAt(index);
}
}
@Override
public void onAdjustVolume(int direction) {
MediaSession session = mMediaSession.get();
@@ -1490,10 +1382,6 @@ public final class MediaSession {
private static final int MSG_CUSTOM_ACTION = 22;
private static final int MSG_ADJUST_VOLUME = 23;
private static final int MSG_SET_VOLUME = 24;
private static final int MSG_ADD_QUEUE_ITEM = 25;
private static final int MSG_ADD_QUEUE_ITEM_AT = 26;
private static final int MSG_REMOVE_QUEUE_ITEM = 27;
private static final int MSG_REMOVE_QUEUE_ITEM_AT = 28;
private MediaSession.Callback mCallback;
@@ -1583,7 +1471,7 @@ public final class MediaSession {
mCallback.onSetRating((Rating) msg.obj);
break;
case MSG_REPEAT_MODE:
mCallback.onSetRepeatMode(msg.arg1);
mCallback.onSetRepeatMode((int) msg.obj);
break;
case MSG_SHUFFLE_MODE:
mCallback.onSetShuffleModeEnabled((boolean) msg.obj);
@@ -1591,24 +1479,12 @@ public final class MediaSession {
case MSG_CUSTOM_ACTION:
mCallback.onCustomAction((String) msg.obj, msg.getData());
break;
case MSG_ADD_QUEUE_ITEM:
mCallback.onAddQueueItem((MediaDescription) msg.obj);
break;
case MSG_ADD_QUEUE_ITEM_AT:
mCallback.onAddQueueItem((MediaDescription) msg.obj, msg.arg1);
break;
case MSG_REMOVE_QUEUE_ITEM:
mCallback.onRemoveQueueItem((MediaDescription) msg.obj);
break;
case MSG_REMOVE_QUEUE_ITEM_AT:
mCallback.onRemoveQueueItemAt(msg.arg1);
break;
case MSG_ADJUST_VOLUME:
synchronized (mLock) {
vp = mVolumeProvider;
}
if (vp != null) {
vp.onAdjustVolume(msg.arg1);
vp.onAdjustVolume((int) msg.obj);
}
break;
case MSG_SET_VOLUME:
@@ -1616,7 +1492,7 @@ public final class MediaSession {
vp = mVolumeProvider;
}
if (vp != null) {
vp.onSetVolumeTo(msg.arg1);
vp.onSetVolumeTo((int) msg.obj);
}
break;
}

View File

@@ -1142,38 +1142,6 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
}
}
public void addQueueItem(MediaDescription description) {
try {
mCb.onAddQueueItem(description);
} catch (RemoteException e) {
Slog.e(TAG, "Remote failure in addQueueItem.", e);
}
}
public void addQueueItemAt(MediaDescription description, int index) {
try {
mCb.onAddQueueItemAt(description, index);
} catch (RemoteException e) {
Slog.e(TAG, "Remote failure in addQueueItemAt.", e);
}
}
public void removeQueueItem(MediaDescription description) {
try {
mCb.onRemoveQueueItem(description);
} catch (RemoteException e) {
Slog.e(TAG, "Remote failure in removeQueueItem.", e);
}
}
public void removeQueueItemAt(int index) {
try {
mCb.onRemoveQueueItemAt(index);
} catch (RemoteException e) {
Slog.e(TAG, "Remote failure in removeQueueItem.", e);
}
}
public void adjustVolume(int direction) {
try {
mCb.onAdjustVolume(direction);
@@ -1448,30 +1416,6 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
}
}
@Override
public void addQueueItem(MediaDescription description) {
updateCallingPackage();
mSessionCb.addQueueItem(description);
}
@Override
public void addQueueItemAt(MediaDescription description, int index) {
updateCallingPackage();
mSessionCb.addQueueItemAt(description, index);
}
@Override
public void removeQueueItem(MediaDescription description) {
updateCallingPackage();
mSessionCb.removeQueueItem(description);
}
@Override
public void removeQueueItemAt(int index) {
updateCallingPackage();
mSessionCb.removeQueueItemAt(index);
}
@Override
public CharSequence getQueueTitle() {
return mQueueTitle;