diff options
author | RoboErik <epastern@google.com> | 2014-07-23 14:53:30 -0700 |
---|---|---|
committer | RoboErik <epastern@google.com> | 2014-07-25 16:22:16 -0700 |
commit | 76fca4e177e18b591439fdff64b8f5242a5122d0 (patch) | |
tree | 738153d1c30bb3759f5d6c30968a63bbd1708366 /media | |
parent | 9e8ade2eb7ee835963473c9cf6faaf5423b0b048 (diff) | |
download | frameworks_base-76fca4e177e18b591439fdff64b8f5242a5122d0.zip frameworks_base-76fca4e177e18b591439fdff64b8f5242a5122d0.tar.gz frameworks_base-76fca4e177e18b591439fdff64b8f5242a5122d0.tar.bz2 |
Add getFlags and getSessionToken to MediaController
getFlags was hidden, should have been public. Also added getSessionToken
as a convenience method for apps to get the token used to create a
controller.
bug:15408392
Change-Id: Icb19b43ebb7e01727eec1a4e667dafcfc3b8d4eb
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/session/MediaController.java | 16 | ||||
-rw-r--r-- | media/java/android/media/session/MediaSession.java | 13 |
2 files changed, 25 insertions, 4 deletions
diff --git a/media/java/android/media/session/MediaController.java b/media/java/android/media/session/MediaController.java index 050db21..89c61c8 100644 --- a/media/java/android/media/session/MediaController.java +++ b/media/java/android/media/session/MediaController.java @@ -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) { @@ -240,6 +241,15 @@ public final class MediaController { } /** + * 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 * {@link VolumeProvider#VOLUME_CONTROL_ABSOLUTE}. The flags in diff --git a/media/java/android/media/session/MediaSession.java b/media/java/android/media/session/MediaSession.java index be2d479..866910d 100644 --- a/media/java/android/media/session/MediaSession.java +++ b/media/java/android/media/session/MediaSession.java @@ -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) { |