diff options
| author | 2019-01-21 22:35:03 +0900 | |
|---|---|---|
| committer | 2019-01-21 22:35:03 +0900 | |
| commit | 5886d3d5717968c0deff4eb44cb068d2d7188ab1 (patch) | |
| tree | 2190767bcb420c5e344275bf9548bfc4232f6941 | |
| parent | 9cb3f789b6ad61bd784742c64d395b31b1518a0e (diff) | |
MediaController2: Add getConnectedSessionToken()
Bug: 122055262
Test: MediaController2Test in CtsMediaTestCases
Change-Id: I64e1a268add047dfa1438e01155ea460f58f4b91
| -rw-r--r-- | api/current.txt | 1 | ||||
| -rw-r--r-- | media/java/android/media/MediaController2.java | 17 |
2 files changed, 18 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt index 6122e5208985..2f1e8db78f9c 100644 --- a/api/current.txt +++ b/api/current.txt @@ -24533,6 +24533,7 @@ package android.media { ctor public MediaController2(@NonNull android.content.Context, @NonNull android.media.Session2Token, @NonNull java.util.concurrent.Executor, @NonNull android.media.MediaController2.ControllerCallback); method public void cancelSessionCommand(@NonNull Object); method public void close(); + method public android.media.Session2Token getConnectedSessionToken(); method public boolean isPlaybackActive(); method @NonNull public Object sendSessionCommand(@NonNull android.media.Session2Command, @Nullable android.os.Bundle); } diff --git a/media/java/android/media/MediaController2.java b/media/java/android/media/MediaController2.java index 7c5335b71627..dd971959dd25 100644 --- a/media/java/android/media/MediaController2.java +++ b/media/java/android/media/MediaController2.java @@ -152,6 +152,7 @@ public class MediaController2 implements AutoCloseable { // No-op } } + mConnectedToken = null; mPendingCommands.clear(); mRequestedCommandSeqNumbers.clear(); mCallbackExecutor.execute(() -> { @@ -162,6 +163,22 @@ public class MediaController2 implements AutoCloseable { } /** + * Returns {@link Session2Token} of the connected session. + * If it is not connected yet, it returns {@code null}. + * <p> + * This may differ with the {@link Session2Token} from the constructor. For example, if the + * controller is created with the token for MediaSession2Service, this would return + * token for the {@link MediaSession2} in the service. + * + * @return Session2Token of the connected session, or {@code null} if not connected + */ + public Session2Token getConnectedSessionToken() { + synchronized (mLock) { + return mConnectedToken; + } + } + + /** * Returns whether the session's playback is active. * * @return {@code true} if playback active. {@code false} otherwise. |