Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 47a7d247 authored by RoboErik's avatar RoboErik Committed by Android (Google) Code Review
Browse files

Merge "Api updates to MediaSession components" into lmp-dev

parents da3475db d2b8c947
Loading
Loading
Loading
Loading
+17 −16
Original line number Diff line number Diff line
@@ -16382,16 +16382,16 @@ package android.media.session {
    method public void addCallback(android.media.session.MediaController.Callback, android.os.Handler);
    method public void adjustVolume(int, int);
    method public boolean dispatchMediaButtonEvent(android.view.KeyEvent);
    method public android.media.session.MediaController.AudioInfo getAudioInfo();
    method public android.os.Bundle getExtras();
    method public long getFlags();
    method public android.app.PendingIntent getLaunchActivity();
    method public android.media.MediaMetadata getMetadata();
    method public java.lang.String getPackageName();
    method public android.media.session.MediaController.PlaybackInfo getPlaybackInfo();
    method public android.media.session.PlaybackState getPlaybackState();
    method public java.util.List<android.media.session.MediaSession.Item> getQueue();
    method public java.lang.CharSequence getQueueTitle();
    method public int getRatingType();
    method public android.app.PendingIntent getSessionActivity();
    method public android.media.session.MediaSession.Token getSessionToken();
    method public android.media.session.MediaController.TransportControls getTransportControls();
    method public void removeCallback(android.media.session.MediaController.Callback);
@@ -16399,17 +16399,9 @@ package android.media.session {
    method public void setVolumeTo(int, int);
  }
  public static final class MediaController.AudioInfo {
    method public android.media.AudioAttributes getAudioAttributes();
    method public int getCurrentVolume();
    method public int getMaxVolume();
    method public int getVolumeControl();
    method public int getVolumeType();
  }
  public static abstract class MediaController.Callback {
    ctor public MediaController.Callback();
    method public void onAudioInfoChanged(android.media.session.MediaController.AudioInfo);
    method public void onAudioInfoChanged(android.media.session.MediaController.PlaybackInfo);
    method public void onExtrasChanged(android.os.Bundle);
    method public void onMetadataChanged(android.media.MediaMetadata);
    method public void onPlaybackStateChanged(android.media.session.PlaybackState);
@@ -16419,6 +16411,16 @@ package android.media.session {
    method public void onSessionEvent(java.lang.String, android.os.Bundle);
  }
  public static final class MediaController.PlaybackInfo {
    method public android.media.AudioAttributes getAudioAttributes();
    method public int getCurrentVolume();
    method public int getMaxVolume();
    method public int getPlaybackType();
    method public int getVolumeControl();
    field public static final int PLAYBACK_TYPE_LOCAL = 1; // 0x1
    field public static final int PLAYBACK_TYPE_REMOTE = 2; // 0x2
  }
  public final class MediaController.TransportControls {
    method public void fastForward();
    method public void pause();
@@ -16448,7 +16450,6 @@ package android.media.session {
    method public void setCallback(android.media.session.MediaSession.Callback, android.os.Handler);
    method public void setExtras(android.os.Bundle);
    method public void setFlags(int);
    method public void setLaunchActivity(android.app.PendingIntent);
    method public void setMediaButtonReceiver(android.app.PendingIntent);
    method public void setMetadata(android.media.MediaMetadata);
    method public void setPlaybackState(android.media.session.PlaybackState);
@@ -16456,10 +16457,9 @@ package android.media.session {
    method public void setPlaybackToRemote(android.media.VolumeProvider);
    method public void setQueue(java.util.List<android.media.session.MediaSession.Item>);
    method public void setQueueTitle(java.lang.CharSequence);
    method public void setSessionActivity(android.app.PendingIntent);
    field public static final int FLAG_HANDLES_MEDIA_BUTTONS = 1; // 0x1
    field public static final int FLAG_HANDLES_TRANSPORT_CONTROLS = 2; // 0x2
    field public static final int PLAYBACK_TYPE_LOCAL = 1; // 0x1
    field public static final int PLAYBACK_TYPE_REMOTE = 2; // 0x2
  }
  public static abstract class MediaSession.Callback {
@@ -16506,6 +16506,7 @@ package android.media.session {
  public final class MediaSessionManager {
    method public void addOnActiveSessionsChangedListener(android.media.session.MediaSessionManager.OnActiveSessionsChangedListener, android.content.ComponentName);
    method public void addOnActiveSessionsChangedListener(android.media.session.MediaSessionManager.OnActiveSessionsChangedListener, android.content.ComponentName, android.os.Handler);
    method public java.util.List<android.media.session.MediaController> getActiveSessions(android.content.ComponentName);
    method public void removeOnActiveSessionsChangedListener(android.media.session.MediaSessionManager.OnActiveSessionsChangedListener);
  }
@@ -16517,7 +16518,7 @@ package android.media.session {
  public final class PlaybackState implements android.os.Parcelable {
    method public int describeContents();
    method public long getActions();
    method public long getBufferPosition();
    method public long getBufferedPosition();
    method public java.util.List<android.media.session.PlaybackState.CustomAction> getCustomActions();
    method public java.lang.CharSequence getErrorMessage();
    method public long getLastPositionUpdateTime();
@@ -16561,7 +16562,7 @@ package android.media.session {
    method public android.media.session.PlaybackState build();
    method public android.media.session.PlaybackState.Builder setActions(long);
    method public android.media.session.PlaybackState.Builder setActiveItem(long);
    method public android.media.session.PlaybackState.Builder setBufferPosition(long);
    method public android.media.session.PlaybackState.Builder setBufferedPosition(long);
    method public android.media.session.PlaybackState.Builder setErrorMessage(java.lang.CharSequence);
    method public android.media.session.PlaybackState.Builder setState(int, long, float, long);
    method public android.media.session.PlaybackState.Builder setState(int, long, float);
+31 −20
Original line number Diff line number Diff line
@@ -247,14 +247,14 @@ public final class MediaController {
    }

    /**
     * Get the current audio info for this session.
     * Get the current playback info for this session.
     *
     * @return The current audio info or null.
     * @return The current playback info or null.
     */
    public @Nullable AudioInfo getAudioInfo() {
    public @Nullable PlaybackInfo getPlaybackInfo() {
        try {
            ParcelableVolumeInfo result = mSessionBinder.getVolumeAttributes();
            return new AudioInfo(result.volumeType, result.audioAttrs, result.controlType,
            return new PlaybackInfo(result.volumeType, result.audioAttrs, result.controlType,
                    result.maxVolume, result.currentVolume);

        } catch (RemoteException e) {
@@ -269,7 +269,7 @@ public final class MediaController {
     *
     * @return A {@link PendingIntent} to launch UI or null.
     */
    public @Nullable PendingIntent getLaunchActivity() {
    public @Nullable PendingIntent getSessionActivity() {
        try {
            return mSessionBinder.getLaunchPendingIntent();
        } catch (RemoteException e) {
@@ -293,9 +293,10 @@ public final class MediaController {
     * {@link VolumeProvider#VOLUME_CONTROL_ABSOLUTE}. The flags in
     * {@link AudioManager} may be used to affect the handling.
     *
     * @see #getAudioInfo()
     * @see #getPlaybackInfo()
     * @param value The value to set it to, between 0 and the reported max.
     * @param flags Any flags to pass with the command.
     * @param flags Flags from {@link AudioManager} to include with the volume
     *            request.
     */
    public void setVolumeTo(int value, int flags) {
        try {
@@ -314,7 +315,7 @@ public final class MediaController {
     * {@link VolumeProvider#VOLUME_CONTROL_ABSOLUTE}. The flags in
     * {@link AudioManager} may be used to affect the handling.
     *
     * @see #getAudioInfo()
     * @see #getPlaybackInfo()
     * @param direction The direction to adjust the volume in.
     * @param flags Any flags to pass with the command.
     */
@@ -565,7 +566,7 @@ public final class MediaController {
         *
         * @param info The current audio info for this session.
         */
        public void onAudioInfoChanged(AudioInfo info) {
        public void onAudioInfoChanged(PlaybackInfo info) {
        }
    }

@@ -773,9 +774,19 @@ public final class MediaController {
    }

    /**
     * Holds information about the way audio is handled for this session.
     * Holds information about the current playback and how audio is handled for
     * this session.
     */
    public static final class PlaybackInfo {
        /**
         * The session uses remote playback.
         */
    public static final class AudioInfo {
        public static final int PLAYBACK_TYPE_REMOTE = 2;
        /**
         * The session uses local playback.
         */
        public static final int PLAYBACK_TYPE_LOCAL = 1;

        private final int mVolumeType;
        private final int mVolumeControl;
        private final int mMaxVolume;
@@ -785,7 +796,7 @@ public final class MediaController {
        /**
         * @hide
         */
        public AudioInfo(int type, AudioAttributes attrs, int control, int max, int current) {
        public PlaybackInfo(int type, AudioAttributes attrs, int control, int max, int current) {
            mVolumeType = type;
            mAudioAttrs = attrs;
            mVolumeControl = control;
@@ -794,22 +805,22 @@ public final class MediaController {
        }

        /**
         * Get the type of volume handling, either local or remote. One of:
         * Get the type of playback which affects volume handling. One of:
         * <ul>
         * <li>{@link MediaSession#PLAYBACK_TYPE_LOCAL}</li>
         * <li>{@link MediaSession#PLAYBACK_TYPE_REMOTE}</li>
         * <li>{@link #PLAYBACK_TYPE_LOCAL}</li>
         * <li>{@link #PLAYBACK_TYPE_REMOTE}</li>
         * </ul>
         *
         * @return The type of volume handling this session is using.
         * @return The type of playback this session is using.
         */
        public int getVolumeType() {
        public int getPlaybackType() {
            return mVolumeType;
        }

        /**
         * Get the audio attributes for this session. The attributes will affect
         * volume handling for the session. When the volume type is
         * {@link MediaSession#PLAYBACK_TYPE_REMOTE} these may be ignored by the
         * {@link PlaybackInfo#PLAYBACK_TYPE_REMOTE} these may be ignored by the
         * remote volume handler.
         *
         * @return The attributes for this session.
@@ -920,7 +931,7 @@ public final class MediaController {
        public void onVolumeInfoChanged(ParcelableVolumeInfo pvi) {
            MediaController controller = mController.get();
            if (controller != null) {
                AudioInfo info = new AudioInfo(pvi.volumeType, pvi.audioAttrs, pvi.controlType,
                PlaybackInfo info = new PlaybackInfo(pvi.volumeType, pvi.audioAttrs, pvi.controlType,
                        pvi.maxVolume, pvi.currentVolume);
                controller.postMessage(MSG_UPDATE_VOLUME, info, null);
            }
@@ -958,7 +969,7 @@ public final class MediaController {
                    mCallback.onExtrasChanged((Bundle) msg.obj);
                    break;
                case MSG_UPDATE_VOLUME:
                    mCallback.onAudioInfoChanged((AudioInfo) msg.obj);
                    mCallback.onAudioInfoChanged((PlaybackInfo) msg.obj);
                    break;
                case MSG_DESTROYED:
                    mCallback.onSessionDestroyed();
+1 −11
Original line number Diff line number Diff line
@@ -101,16 +101,6 @@ public final class MediaSession {
            FLAG_EXCLUSIVE_GLOBAL_PRIORITY })
    public @interface SessionFlags { }

    /**
     * The session uses local playback.
     */
    public static final int PLAYBACK_TYPE_LOCAL = 1;

    /**
     * The session uses remote playback.
     */
    public static final int PLAYBACK_TYPE_REMOTE = 2;

    private final Object mLock = new Object();

    private final MediaSession.Token mSessionToken;
@@ -215,7 +205,7 @@ public final class MediaSession {
     *
     * @param pi The intent to launch to show UI for this Session.
     */
    public void setLaunchActivity(@Nullable PendingIntent pi) {
    public void setSessionActivity(@Nullable PendingIntent pi) {
        try {
            mBinder.setLaunchPendingIntent(pi);
        } catch (RemoteException e) {
+22 −1
Original line number Diff line number Diff line
@@ -148,8 +148,29 @@ public final class MediaSessionManager {
    public void addOnActiveSessionsChangedListener(
            @NonNull OnActiveSessionsChangedListener sessionListener,
            @Nullable ComponentName notificationListener) {
        addOnActiveSessionsChangedListener(sessionListener, notificationListener, null);
    }

    /**
     * Add a listener to be notified when the list of active sessions
     * changes.This requires the
     * android.Manifest.permission.MEDIA_CONTENT_CONTROL permission be held by
     * the calling app. You may also retrieve this list if your app is an
     * enabled notification listener using the
     * {@link NotificationListenerService} APIs, in which case you must pass the
     * {@link ComponentName} of your enabled listener. Updates will be posted to
     * the handler specified or to the caller's thread if the handler is null.
     *
     * @param sessionListener The listener to add.
     * @param notificationListener The enabled notification listener component.
     *            May be null.
     * @param handler The handler to post events to.
     */
    public void addOnActiveSessionsChangedListener(
            @NonNull OnActiveSessionsChangedListener sessionListener,
            @Nullable ComponentName notificationListener, @Nullable Handler handler) {
        addOnActiveSessionsChangedListener(sessionListener, notificationListener,
                UserHandle.myUserId(), null);
                UserHandle.myUserId(), handler);
    }

    /**
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ import android.os.Parcelable;

/**
 * Convenience class for passing information about the audio configuration of a
 * session. The public implementation is {@link MediaController.AudioInfo}.
 * session. The public implementation is {@link MediaController.PlaybackInfo}.
 *
 * @hide
 */
Loading