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

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

Merge "Add getFlags and getSessionToken to MediaController" into lmp-dev

parents 14185765 76fca4e1
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -16584,10 +16584,12 @@ package android.media.session {
    method public void adjustVolume(int, int);
    method public android.media.routing.MediaRouter.Delegate createMediaRouterDelegate();
    method public boolean dispatchMediaButtonEvent(android.view.KeyEvent);
    method public long getFlags();
    method public android.media.MediaMetadata getMetadata();
    method public android.media.session.PlaybackState getPlaybackState();
    method public java.util.List<android.media.session.MediaSession.Track> getQueue();
    method public int getRatingType();
    method public android.media.session.MediaSession.Token getSessionToken();
    method public android.media.session.MediaController.TransportControls getTransportControls();
    method public android.media.session.MediaController.VolumeInfo getVolumeInfo();
    method public void removeCallback(android.media.session.MediaController.Callback);
+13 −3
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ public final class MediaController {

    private final ISessionController mSessionBinder;

    private final MediaSession.Token mToken;
    private final CallbackStub mCbStub = new CallbackStub(this);
    private final ArrayList<MessageHandler> mCallbacks = new ArrayList<MessageHandler>();
    private final Object mLock = new Object();
@@ -85,6 +86,7 @@ public final class MediaController {
        }
        mSessionBinder = sessionBinder;
        mTransportControls = new TransportControls();
        mToken = new MediaSession.Token(sessionBinder);
    }

    /**
@@ -208,12 +210,11 @@ public final class MediaController {
    }

    /**
     * Get the flags for this session.
     * Get the flags for this session. Flags are defined in {@link MediaSession}.
     *
     * @return The current set of flags for the session.
     * @hide
     */
    public long getFlags() {
    public @MediaSession.SessionFlags long getFlags() {
        try {
            return mSessionBinder.getFlags();
        } catch (RemoteException e) {
@@ -239,6 +240,15 @@ public final class MediaController {
        return null;
    }

    /**
     * Get the token for the session this is connected to.
     *
     * @return The token for the connected session.
     */
    public @NonNull MediaSession.Token getSessionToken() {
        return mToken;
    }

    /**
     * Set the volume of the output this session is playing on. The command will
     * be ignored if it does not support
+12 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.media.session;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.PendingIntent;
@@ -42,6 +43,8 @@ import android.os.UserHandle;
import android.text.TextUtils;
import android.util.Log;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
@@ -95,6 +98,14 @@ public final class MediaSession {
     */
    public static final int FLAG_EXCLUSIVE_GLOBAL_PRIORITY = 1 << 16;

    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(flag = true, value = {
            FLAG_HANDLES_MEDIA_BUTTONS,
            FLAG_HANDLES_TRANSPORT_CONTROLS,
            FLAG_EXCLUSIVE_GLOBAL_PRIORITY })
    public @interface SessionFlags { }

    /**
     * The session uses local playback.
     */
@@ -256,7 +267,7 @@ public final class MediaSession {
     *
     * @param flags The flags to set for this session.
     */
    public void setFlags(int flags) {
    public void setFlags(@SessionFlags int flags) {
        try {
            mBinder.setFlags(flags);
        } catch (RemoteException e) {