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

Commit 3de7c414 authored by Donghyun Cho's avatar Donghyun Cho
Browse files

MediaSession: Define an extra field for staying paused after play

Introduced a new constant EXTRA_PREPARE_ONLY, which allows
MediaController to ask MediaSession to stay paused right after play
requests are called. If this field is set to true in extra bundle and it
is passed during playFromMediaId, playFromSearch, and playFromUri
requests, MediaSession will prepare the given media, but not start
playing it.

Bug: 25841735
Change-Id: I2a2f71a251bd6f475698fe8a5bb696ac70003e2b
parent 6cfdf6b6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -22064,6 +22064,7 @@ package android.media.session {
    method public void setRatingType(int);
    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_PREPARE_ONLY = 4; // 0x4
    field public static final int FLAG_HANDLES_TRANSPORT_CONTROLS = 2; // 0x2
  }
@@ -22142,6 +22143,7 @@ package android.media.session {
    field public static final long ACTION_SKIP_TO_QUEUE_ITEM = 4096L; // 0x1000L
    field public static final long ACTION_STOP = 1L; // 0x1L
    field public static final android.os.Parcelable.Creator<android.media.session.PlaybackState> CREATOR;
    field public static final java.lang.String EXTRA_PREPARE_ONLY = "android.media.session.extra.PREPARE_ONLY";
    field public static final long PLAYBACK_POSITION_UNKNOWN = -1L; // 0xffffffffffffffffL
    field public static final int STATE_BUFFERING = 6; // 0x6
    field public static final int STATE_CONNECTING = 8; // 0x8
+2 −0
Original line number Diff line number Diff line
@@ -23481,6 +23481,7 @@ package android.media.session {
    method public void setRatingType(int);
    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_PREPARE_ONLY = 4; // 0x4
    field public static final int FLAG_HANDLES_TRANSPORT_CONTROLS = 2; // 0x2
  }
@@ -23559,6 +23560,7 @@ package android.media.session {
    field public static final long ACTION_SKIP_TO_QUEUE_ITEM = 4096L; // 0x1000L
    field public static final long ACTION_STOP = 1L; // 0x1L
    field public static final android.os.Parcelable.Creator<android.media.session.PlaybackState> CREATOR;
    field public static final java.lang.String EXTRA_PREPARE_ONLY = "android.media.session.extra.PREPARE_ONLY";
    field public static final long PLAYBACK_POSITION_UNKNOWN = -1L; // 0xffffffffffffffffL
    field public static final int STATE_BUFFERING = 6; // 0x6
    field public static final int STATE_CONNECTING = 8; // 0x8
+2 −0
Original line number Diff line number Diff line
@@ -22072,6 +22072,7 @@ package android.media.session {
    method public void setRatingType(int);
    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_PREPARE_ONLY = 4; // 0x4
    field public static final int FLAG_HANDLES_TRANSPORT_CONTROLS = 2; // 0x2
  }
@@ -22150,6 +22151,7 @@ package android.media.session {
    field public static final long ACTION_SKIP_TO_QUEUE_ITEM = 4096L; // 0x1000L
    field public static final long ACTION_STOP = 1L; // 0x1L
    field public static final android.os.Parcelable.Creator<android.media.session.PlaybackState> CREATOR;
    field public static final java.lang.String EXTRA_PREPARE_ONLY = "android.media.session.extra.PREPARE_ONLY";
    field public static final long PLAYBACK_POSITION_UNKNOWN = -1L; // 0xffffffffffffffffL
    field public static final int STATE_BUFFERING = 6; // 0x6
    field public static final int STATE_CONNECTING = 8; // 0x8
+3 −0
Original line number Diff line number Diff line
@@ -605,6 +605,7 @@ public final class MediaController {
        /**
         * Request that the player start playback for a specific media id.
         *
         * @see PlaybackState#EXTRA_PREPARE_ONLY
         * @param mediaId The id of the requested media.
         * @param extras Optional extras that can include extra information about the media item
         *               to be played.
@@ -626,6 +627,7 @@ public final class MediaController {
         * An empty or null query should be treated as a request to play any
         * music.
         *
         * @see PlaybackState#EXTRA_PREPARE_ONLY
         * @param query The search query.
         * @param extras Optional extras that can include extra information
         *            about the query.
@@ -646,6 +648,7 @@ public final class MediaController {
        /**
         * Request that the player start playback for a specific {@link Uri}.
         *
         * @see PlaybackState#EXTRA_PREPARE_ONLY
         * @param uri  The URI of the requested media.
         * @param extras Optional extras that can include extra information about the media item
         *               to be played.
+7 −0
Original line number Diff line number Diff line
@@ -86,6 +86,12 @@ public final class MediaSession {
     */
    public static final int FLAG_HANDLES_TRANSPORT_CONTROLS = 1 << 1;

    /**
     * Set this flag on the session to indicate that it can handle
     * the {@link PlaybackState#EXTRA_PREPARE_ONLY} field.
     */
    public static final int FLAG_HANDLES_PREPARE_ONLY = 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
@@ -100,6 +106,7 @@ public final class MediaSession {
    @IntDef(flag = true, value = {
            FLAG_HANDLES_MEDIA_BUTTONS,
            FLAG_HANDLES_TRANSPORT_CONTROLS,
            FLAG_HANDLES_PREPARE_ONLY,
            FLAG_EXCLUSIVE_GLOBAL_PRIORITY })
    public @interface SessionFlags { }

Loading