Loading api/current.txt +4 −0 Original line number Original line Diff line number Diff line Loading @@ -24659,6 +24659,7 @@ package android.media { ctor public MediaController2(android.content.Context, android.media.Session2Token, java.util.concurrent.Executor, android.media.MediaController2.ControllerCallback); ctor public MediaController2(android.content.Context, android.media.Session2Token, java.util.concurrent.Executor, android.media.MediaController2.ControllerCallback); method public void cancelSessionCommand(java.lang.Object); method public void cancelSessionCommand(java.lang.Object); method public void close(); method public void close(); method public boolean isPlaybackActive(); method public java.lang.Object sendSessionCommand(android.media.Session2Command, android.os.Bundle); method public java.lang.Object sendSessionCommand(android.media.Session2Command, android.os.Bundle); } } Loading @@ -24667,6 +24668,7 @@ package android.media { method public void onCommandResult(android.media.MediaController2, java.lang.Object, android.media.Session2Command, android.media.Session2Command.Result); method public void onCommandResult(android.media.MediaController2, java.lang.Object, android.media.Session2Command, android.media.Session2Command.Result); method public void onConnected(android.media.MediaController2, android.media.Session2CommandGroup); method public void onConnected(android.media.MediaController2, android.media.Session2CommandGroup); method public void onDisconnected(android.media.MediaController2); method public void onDisconnected(android.media.MediaController2); method public void onPlaybackActiveChanged(android.media.MediaController2, boolean); method public android.media.Session2Command.Result onSessionCommand(android.media.MediaController2, android.media.Session2Command, android.os.Bundle); method public android.media.Session2Command.Result onSessionCommand(android.media.MediaController2, android.media.Session2Command, android.os.Bundle); } } Loading Loading @@ -26009,7 +26011,9 @@ package android.media { method public void close(); method public void close(); method public java.lang.String getSessionId(); method public java.lang.String getSessionId(); method public android.media.Session2Token getSessionToken(); method public android.media.Session2Token getSessionToken(); method public boolean isPlaybackActive(); method public java.lang.Object sendSessionCommand(android.media.MediaSession2.ControllerInfo, android.media.Session2Command, android.os.Bundle); method public java.lang.Object sendSessionCommand(android.media.MediaSession2.ControllerInfo, android.media.Session2Command, android.os.Bundle); method public void setPlaybackActive(boolean); } } public static final class MediaSession2.Builder { public static final class MediaSession2.Builder { media/java/android/media/Controller2Link.java +49 −4 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.media; package android.media; import android.os.Binder; import android.os.Bundle; import android.os.Bundle; import android.os.Parcel; import android.os.Parcel; import android.os.Parcelable; import android.os.Parcelable; Loading Loading @@ -102,6 +103,15 @@ public final class Controller2Link implements Parcelable { } } } } /** Interface method for IMediaController2.notifyPlaybackActiveChanged */ public void notifyPlaybackActiveChanged(int seq, boolean playbackActive) { try { mIController.notifyPlaybackActiveChanged(seq, playbackActive); } catch (RemoteException e) { throw new RuntimeException(e); } } /** Interface method for IMediaController2.sendSessionCommand */ /** Interface method for IMediaController2.sendSessionCommand */ public void sendSessionCommand(int seq, Session2Command command, Bundle args, public void sendSessionCommand(int seq, Session2Command command, Bundle args, ResultReceiver resultReceiver) { ResultReceiver resultReceiver) { Loading Loading @@ -135,6 +145,11 @@ public final class Controller2Link implements Parcelable { mController.onDisconnected(seq); mController.onDisconnected(seq); } } /** Stub implementation for IMediaController2.notifyPlaybackActiveChanged */ public void onPlaybackActiveChanged(int seq, boolean playbackActive) { mController.onPlaybackActiveChanged(seq, playbackActive); } /** Stub implementation for IMediaController2.sendSessionCommand */ /** Stub implementation for IMediaController2.sendSessionCommand */ public void onSessionCommand(int seq, Session2Command command, Bundle args, public void onSessionCommand(int seq, Session2Command command, Bundle args, ResultReceiver resultReceiver) { ResultReceiver resultReceiver) { Loading @@ -149,23 +164,53 @@ public final class Controller2Link implements Parcelable { private class Controller2Stub extends IMediaController2.Stub { private class Controller2Stub extends IMediaController2.Stub { @Override @Override public void notifyConnected(int seq, Bundle connectionResult) { public void notifyConnected(int seq, Bundle connectionResult) { final long token = Binder.clearCallingIdentity(); try { Controller2Link.this.onConnected(seq, connectionResult); Controller2Link.this.onConnected(seq, connectionResult); } finally { Binder.restoreCallingIdentity(token); } } } @Override @Override public void notifyDisconnected(int seq) { public void notifyDisconnected(int seq) { final long token = Binder.clearCallingIdentity(); try { Controller2Link.this.onDisconnected(seq); Controller2Link.this.onDisconnected(seq); } finally { Binder.restoreCallingIdentity(token); } } @Override public void notifyPlaybackActiveChanged(int seq, boolean playbackActive) { final long token = Binder.clearCallingIdentity(); try { Controller2Link.this.onPlaybackActiveChanged(seq, playbackActive); } finally { Binder.restoreCallingIdentity(token); } } } @Override @Override public void sendSessionCommand(int seq, Session2Command command, Bundle args, public void sendSessionCommand(int seq, Session2Command command, Bundle args, ResultReceiver resultReceiver) { ResultReceiver resultReceiver) { final long token = Binder.clearCallingIdentity(); try { Controller2Link.this.onSessionCommand(seq, command, args, resultReceiver); Controller2Link.this.onSessionCommand(seq, command, args, resultReceiver); } finally { Binder.restoreCallingIdentity(token); } } } @Override @Override public void cancelSessionCommand(int seq) { public void cancelSessionCommand(int seq) { final long token = Binder.clearCallingIdentity(); try { Controller2Link.this.onCancelCommand(seq); Controller2Link.this.onCancelCommand(seq); } finally { Binder.restoreCallingIdentity(token); } } } } } } } media/java/android/media/IMediaController2.aidl +4 −3 Original line number Original line Diff line number Diff line Loading @@ -31,8 +31,9 @@ import android.media.Session2Command; oneway interface IMediaController2 { oneway interface IMediaController2 { void notifyConnected(int seq, in Bundle connectionResult) = 0; void notifyConnected(int seq, in Bundle connectionResult) = 0; void notifyDisconnected(int seq) = 1; void notifyDisconnected(int seq) = 1; void notifyPlaybackActiveChanged(int seq, boolean playbackActive) = 2; void sendSessionCommand(int seq, in Session2Command command, in Bundle args, void sendSessionCommand(int seq, in Session2Command command, in Bundle args, in ResultReceiver resultReceiver) = 2; in ResultReceiver resultReceiver) = 3; void cancelSessionCommand(int seq) = 3; void cancelSessionCommand(int seq) = 4; // Next Id : 4 // Next Id : 5 } } media/java/android/media/MediaConstants.java +1 −0 Original line number Original line Diff line number Diff line Loading @@ -26,6 +26,7 @@ class MediaConstants { // Bundle key for Parcelable // Bundle key for Parcelable static final String KEY_SESSION2LINK = "android.media.key.SESSION2LINK"; static final String KEY_SESSION2LINK = "android.media.key.SESSION2LINK"; static final String KEY_ALLOWED_COMMANDS = "android.media.key.ALLOWED_COMMANDS"; static final String KEY_ALLOWED_COMMANDS = "android.media.key.ALLOWED_COMMANDS"; static final String KEY_PLAYBACK_ACTIVE = "android.media.key.PLAYBACK_ACTIVE"; private MediaConstants() { private MediaConstants() { } } Loading media/java/android/media/MediaController2.java +84 −66 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ package android.media; import static android.media.MediaConstants.KEY_ALLOWED_COMMANDS; import static android.media.MediaConstants.KEY_ALLOWED_COMMANDS; import static android.media.MediaConstants.KEY_PACKAGE_NAME; import static android.media.MediaConstants.KEY_PACKAGE_NAME; import static android.media.MediaConstants.KEY_PID; import static android.media.MediaConstants.KEY_PID; import static android.media.MediaConstants.KEY_PLAYBACK_ACTIVE; import static android.media.MediaConstants.KEY_SESSION2LINK; import static android.media.MediaConstants.KEY_SESSION2LINK; import static android.media.Session2Command.RESULT_ERROR_UNKNOWN_ERROR; import static android.media.Session2Command.RESULT_ERROR_UNKNOWN_ERROR; import static android.media.Session2Command.RESULT_INFO_SKIPPED; import static android.media.Session2Command.RESULT_INFO_SKIPPED; Loading @@ -30,7 +31,6 @@ import android.content.ComponentName; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.content.ServiceConnection; import android.content.ServiceConnection; import android.os.Binder; import android.os.Bundle; import android.os.Bundle; import android.os.Handler; import android.os.Handler; import android.os.IBinder; import android.os.IBinder; Loading Loading @@ -82,6 +82,8 @@ public class MediaController2 implements AutoCloseable { private ArrayMap<ResultReceiver, Integer> mPendingCommands; private ArrayMap<ResultReceiver, Integer> mPendingCommands; //@GuardedBy("mLock") //@GuardedBy("mLock") private ArraySet<Integer> mRequestedCommandSeqNumbers; private ArraySet<Integer> mRequestedCommandSeqNumbers; //@GuardedBy("mLock") private boolean mPlaybackActive; /** /** * Create a {@link MediaController2} from the {@link Session2Token}. * Create a {@link MediaController2} from the {@link Session2Token}. Loading Loading @@ -159,6 +161,18 @@ public class MediaController2 implements AutoCloseable { } } } } /** * Returns whether the session's playback is active. * * @return {@code true} if playback active. {@code false} otherwise. * @see ControllerCallback#onPlaybackActiveChanged(MediaController2, boolean) */ public boolean isPlaybackActive() { synchronized (mLock) { return mPlaybackActive; } } /** /** * Sends a session command to the session * Sends a session command to the session * <p> * <p> Loading Loading @@ -221,11 +235,10 @@ public class MediaController2 implements AutoCloseable { // Called by Controller2Link.onConnected // Called by Controller2Link.onConnected void onConnected(int seq, Bundle connectionResult) { void onConnected(int seq, Bundle connectionResult) { final long token = Binder.clearCallingIdentity(); try { Session2Link sessionBinder = connectionResult.getParcelable(KEY_SESSION2LINK); Session2Link sessionBinder = connectionResult.getParcelable(KEY_SESSION2LINK); Session2CommandGroup allowedCommands = Session2CommandGroup allowedCommands = connectionResult.getParcelable(KEY_ALLOWED_COMMANDS); connectionResult.getParcelable(KEY_ALLOWED_COMMANDS); boolean playbackActive = connectionResult.getBoolean(KEY_PLAYBACK_ACTIVE); if (DEBUG) { if (DEBUG) { Log.d(TAG, "notifyConnected sessionBinder=" + sessionBinder Log.d(TAG, "notifyConnected sessionBinder=" + sessionBinder + ", allowedCommands=" + allowedCommands); + ", allowedCommands=" + allowedCommands); Loading @@ -238,6 +251,8 @@ public class MediaController2 implements AutoCloseable { synchronized (mLock) { synchronized (mLock) { mSessionBinder = sessionBinder; mSessionBinder = sessionBinder; mAllowedCommands = allowedCommands; mAllowedCommands = allowedCommands; mPlaybackActive = playbackActive; // Implementation for the local binder is no-op, // Implementation for the local binder is no-op, // so can be used without worrying about deadlock. // so can be used without worrying about deadlock. sessionBinder.linkToDeath(mDeathRecipient, 0); sessionBinder.linkToDeath(mDeathRecipient, 0); Loading @@ -247,27 +262,27 @@ public class MediaController2 implements AutoCloseable { mCallbackExecutor.execute(() -> { mCallbackExecutor.execute(() -> { mCallback.onConnected(MediaController2.this, allowedCommands); mCallback.onConnected(MediaController2.this, allowedCommands); }); }); } finally { Binder.restoreCallingIdentity(token); } } } // Called by Controller2Link.onDisconnected // Called by Controller2Link.onDisconnected void onDisconnected(int seq) { void onDisconnected(int seq) { final long token = Binder.clearCallingIdentity(); try { // close() will call mCallback.onDisconnected // close() will call mCallback.onDisconnected close(); close(); } finally { Binder.restoreCallingIdentity(token); } } // Called by Controller2Link.onPlaybackActiveChanged void onPlaybackActiveChanged(int seq, boolean playbackActive) { synchronized (mLock) { mPlaybackActive = playbackActive; } mCallbackExecutor.execute(() -> { mCallback.onPlaybackActiveChanged(MediaController2.this, playbackActive); }); } } // Called by Controller2Link.onSessionCommand // Called by Controller2Link.onSessionCommand void onSessionCommand(int seq, Session2Command command, Bundle args, void onSessionCommand(int seq, Session2Command command, Bundle args, @Nullable ResultReceiver resultReceiver) { @Nullable ResultReceiver resultReceiver) { final long token = Binder.clearCallingIdentity(); try { synchronized (mLock) { synchronized (mLock) { mRequestedCommandSeqNumbers.add(seq); mRequestedCommandSeqNumbers.add(seq); } } Loading @@ -290,21 +305,13 @@ public class MediaController2 implements AutoCloseable { } } } } }); }); } finally { Binder.restoreCallingIdentity(token); } } } // Called by Controller2Link.onSessionCommand // Called by Controller2Link.onSessionCommand void onCancelCommand(int seq) { void onCancelCommand(int seq) { final long token = Binder.clearCallingIdentity(); try { synchronized (mLock) { synchronized (mLock) { mRequestedCommandSeqNumbers.remove(seq); mRequestedCommandSeqNumbers.remove(seq); } } } finally { Binder.restoreCallingIdentity(token); } } } private int getNextSeqNumber() { private int getNextSeqNumber() { Loading Loading @@ -392,6 +399,17 @@ public class MediaController2 implements AutoCloseable { */ */ public void onDisconnected(@NonNull MediaController2 controller) {} public void onDisconnected(@NonNull MediaController2 controller) {} /** * Called when the playback of the session's playback activeness is changed. * * @param controller the controller for this event * @param playbackActive {@code true} if the session's playback is active. * {@code false} otherwise. * @see MediaController2#isPlaybackActive() */ public void onPlaybackActiveChanged(@NonNull MediaController2 controller, boolean playbackActive) {} /** /** * Called when the connected session sent a session command. * Called when the connected session sent a session command. * * Loading Loading
api/current.txt +4 −0 Original line number Original line Diff line number Diff line Loading @@ -24659,6 +24659,7 @@ package android.media { ctor public MediaController2(android.content.Context, android.media.Session2Token, java.util.concurrent.Executor, android.media.MediaController2.ControllerCallback); ctor public MediaController2(android.content.Context, android.media.Session2Token, java.util.concurrent.Executor, android.media.MediaController2.ControllerCallback); method public void cancelSessionCommand(java.lang.Object); method public void cancelSessionCommand(java.lang.Object); method public void close(); method public void close(); method public boolean isPlaybackActive(); method public java.lang.Object sendSessionCommand(android.media.Session2Command, android.os.Bundle); method public java.lang.Object sendSessionCommand(android.media.Session2Command, android.os.Bundle); } } Loading @@ -24667,6 +24668,7 @@ package android.media { method public void onCommandResult(android.media.MediaController2, java.lang.Object, android.media.Session2Command, android.media.Session2Command.Result); method public void onCommandResult(android.media.MediaController2, java.lang.Object, android.media.Session2Command, android.media.Session2Command.Result); method public void onConnected(android.media.MediaController2, android.media.Session2CommandGroup); method public void onConnected(android.media.MediaController2, android.media.Session2CommandGroup); method public void onDisconnected(android.media.MediaController2); method public void onDisconnected(android.media.MediaController2); method public void onPlaybackActiveChanged(android.media.MediaController2, boolean); method public android.media.Session2Command.Result onSessionCommand(android.media.MediaController2, android.media.Session2Command, android.os.Bundle); method public android.media.Session2Command.Result onSessionCommand(android.media.MediaController2, android.media.Session2Command, android.os.Bundle); } } Loading Loading @@ -26009,7 +26011,9 @@ package android.media { method public void close(); method public void close(); method public java.lang.String getSessionId(); method public java.lang.String getSessionId(); method public android.media.Session2Token getSessionToken(); method public android.media.Session2Token getSessionToken(); method public boolean isPlaybackActive(); method public java.lang.Object sendSessionCommand(android.media.MediaSession2.ControllerInfo, android.media.Session2Command, android.os.Bundle); method public java.lang.Object sendSessionCommand(android.media.MediaSession2.ControllerInfo, android.media.Session2Command, android.os.Bundle); method public void setPlaybackActive(boolean); } } public static final class MediaSession2.Builder { public static final class MediaSession2.Builder {
media/java/android/media/Controller2Link.java +49 −4 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.media; package android.media; import android.os.Binder; import android.os.Bundle; import android.os.Bundle; import android.os.Parcel; import android.os.Parcel; import android.os.Parcelable; import android.os.Parcelable; Loading Loading @@ -102,6 +103,15 @@ public final class Controller2Link implements Parcelable { } } } } /** Interface method for IMediaController2.notifyPlaybackActiveChanged */ public void notifyPlaybackActiveChanged(int seq, boolean playbackActive) { try { mIController.notifyPlaybackActiveChanged(seq, playbackActive); } catch (RemoteException e) { throw new RuntimeException(e); } } /** Interface method for IMediaController2.sendSessionCommand */ /** Interface method for IMediaController2.sendSessionCommand */ public void sendSessionCommand(int seq, Session2Command command, Bundle args, public void sendSessionCommand(int seq, Session2Command command, Bundle args, ResultReceiver resultReceiver) { ResultReceiver resultReceiver) { Loading Loading @@ -135,6 +145,11 @@ public final class Controller2Link implements Parcelable { mController.onDisconnected(seq); mController.onDisconnected(seq); } } /** Stub implementation for IMediaController2.notifyPlaybackActiveChanged */ public void onPlaybackActiveChanged(int seq, boolean playbackActive) { mController.onPlaybackActiveChanged(seq, playbackActive); } /** Stub implementation for IMediaController2.sendSessionCommand */ /** Stub implementation for IMediaController2.sendSessionCommand */ public void onSessionCommand(int seq, Session2Command command, Bundle args, public void onSessionCommand(int seq, Session2Command command, Bundle args, ResultReceiver resultReceiver) { ResultReceiver resultReceiver) { Loading @@ -149,23 +164,53 @@ public final class Controller2Link implements Parcelable { private class Controller2Stub extends IMediaController2.Stub { private class Controller2Stub extends IMediaController2.Stub { @Override @Override public void notifyConnected(int seq, Bundle connectionResult) { public void notifyConnected(int seq, Bundle connectionResult) { final long token = Binder.clearCallingIdentity(); try { Controller2Link.this.onConnected(seq, connectionResult); Controller2Link.this.onConnected(seq, connectionResult); } finally { Binder.restoreCallingIdentity(token); } } } @Override @Override public void notifyDisconnected(int seq) { public void notifyDisconnected(int seq) { final long token = Binder.clearCallingIdentity(); try { Controller2Link.this.onDisconnected(seq); Controller2Link.this.onDisconnected(seq); } finally { Binder.restoreCallingIdentity(token); } } @Override public void notifyPlaybackActiveChanged(int seq, boolean playbackActive) { final long token = Binder.clearCallingIdentity(); try { Controller2Link.this.onPlaybackActiveChanged(seq, playbackActive); } finally { Binder.restoreCallingIdentity(token); } } } @Override @Override public void sendSessionCommand(int seq, Session2Command command, Bundle args, public void sendSessionCommand(int seq, Session2Command command, Bundle args, ResultReceiver resultReceiver) { ResultReceiver resultReceiver) { final long token = Binder.clearCallingIdentity(); try { Controller2Link.this.onSessionCommand(seq, command, args, resultReceiver); Controller2Link.this.onSessionCommand(seq, command, args, resultReceiver); } finally { Binder.restoreCallingIdentity(token); } } } @Override @Override public void cancelSessionCommand(int seq) { public void cancelSessionCommand(int seq) { final long token = Binder.clearCallingIdentity(); try { Controller2Link.this.onCancelCommand(seq); Controller2Link.this.onCancelCommand(seq); } finally { Binder.restoreCallingIdentity(token); } } } } } } }
media/java/android/media/IMediaController2.aidl +4 −3 Original line number Original line Diff line number Diff line Loading @@ -31,8 +31,9 @@ import android.media.Session2Command; oneway interface IMediaController2 { oneway interface IMediaController2 { void notifyConnected(int seq, in Bundle connectionResult) = 0; void notifyConnected(int seq, in Bundle connectionResult) = 0; void notifyDisconnected(int seq) = 1; void notifyDisconnected(int seq) = 1; void notifyPlaybackActiveChanged(int seq, boolean playbackActive) = 2; void sendSessionCommand(int seq, in Session2Command command, in Bundle args, void sendSessionCommand(int seq, in Session2Command command, in Bundle args, in ResultReceiver resultReceiver) = 2; in ResultReceiver resultReceiver) = 3; void cancelSessionCommand(int seq) = 3; void cancelSessionCommand(int seq) = 4; // Next Id : 4 // Next Id : 5 } }
media/java/android/media/MediaConstants.java +1 −0 Original line number Original line Diff line number Diff line Loading @@ -26,6 +26,7 @@ class MediaConstants { // Bundle key for Parcelable // Bundle key for Parcelable static final String KEY_SESSION2LINK = "android.media.key.SESSION2LINK"; static final String KEY_SESSION2LINK = "android.media.key.SESSION2LINK"; static final String KEY_ALLOWED_COMMANDS = "android.media.key.ALLOWED_COMMANDS"; static final String KEY_ALLOWED_COMMANDS = "android.media.key.ALLOWED_COMMANDS"; static final String KEY_PLAYBACK_ACTIVE = "android.media.key.PLAYBACK_ACTIVE"; private MediaConstants() { private MediaConstants() { } } Loading
media/java/android/media/MediaController2.java +84 −66 Original line number Original line Diff line number Diff line Loading @@ -19,6 +19,7 @@ package android.media; import static android.media.MediaConstants.KEY_ALLOWED_COMMANDS; import static android.media.MediaConstants.KEY_ALLOWED_COMMANDS; import static android.media.MediaConstants.KEY_PACKAGE_NAME; import static android.media.MediaConstants.KEY_PACKAGE_NAME; import static android.media.MediaConstants.KEY_PID; import static android.media.MediaConstants.KEY_PID; import static android.media.MediaConstants.KEY_PLAYBACK_ACTIVE; import static android.media.MediaConstants.KEY_SESSION2LINK; import static android.media.MediaConstants.KEY_SESSION2LINK; import static android.media.Session2Command.RESULT_ERROR_UNKNOWN_ERROR; import static android.media.Session2Command.RESULT_ERROR_UNKNOWN_ERROR; import static android.media.Session2Command.RESULT_INFO_SKIPPED; import static android.media.Session2Command.RESULT_INFO_SKIPPED; Loading @@ -30,7 +31,6 @@ import android.content.ComponentName; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.content.ServiceConnection; import android.content.ServiceConnection; import android.os.Binder; import android.os.Bundle; import android.os.Bundle; import android.os.Handler; import android.os.Handler; import android.os.IBinder; import android.os.IBinder; Loading Loading @@ -82,6 +82,8 @@ public class MediaController2 implements AutoCloseable { private ArrayMap<ResultReceiver, Integer> mPendingCommands; private ArrayMap<ResultReceiver, Integer> mPendingCommands; //@GuardedBy("mLock") //@GuardedBy("mLock") private ArraySet<Integer> mRequestedCommandSeqNumbers; private ArraySet<Integer> mRequestedCommandSeqNumbers; //@GuardedBy("mLock") private boolean mPlaybackActive; /** /** * Create a {@link MediaController2} from the {@link Session2Token}. * Create a {@link MediaController2} from the {@link Session2Token}. Loading Loading @@ -159,6 +161,18 @@ public class MediaController2 implements AutoCloseable { } } } } /** * Returns whether the session's playback is active. * * @return {@code true} if playback active. {@code false} otherwise. * @see ControllerCallback#onPlaybackActiveChanged(MediaController2, boolean) */ public boolean isPlaybackActive() { synchronized (mLock) { return mPlaybackActive; } } /** /** * Sends a session command to the session * Sends a session command to the session * <p> * <p> Loading Loading @@ -221,11 +235,10 @@ public class MediaController2 implements AutoCloseable { // Called by Controller2Link.onConnected // Called by Controller2Link.onConnected void onConnected(int seq, Bundle connectionResult) { void onConnected(int seq, Bundle connectionResult) { final long token = Binder.clearCallingIdentity(); try { Session2Link sessionBinder = connectionResult.getParcelable(KEY_SESSION2LINK); Session2Link sessionBinder = connectionResult.getParcelable(KEY_SESSION2LINK); Session2CommandGroup allowedCommands = Session2CommandGroup allowedCommands = connectionResult.getParcelable(KEY_ALLOWED_COMMANDS); connectionResult.getParcelable(KEY_ALLOWED_COMMANDS); boolean playbackActive = connectionResult.getBoolean(KEY_PLAYBACK_ACTIVE); if (DEBUG) { if (DEBUG) { Log.d(TAG, "notifyConnected sessionBinder=" + sessionBinder Log.d(TAG, "notifyConnected sessionBinder=" + sessionBinder + ", allowedCommands=" + allowedCommands); + ", allowedCommands=" + allowedCommands); Loading @@ -238,6 +251,8 @@ public class MediaController2 implements AutoCloseable { synchronized (mLock) { synchronized (mLock) { mSessionBinder = sessionBinder; mSessionBinder = sessionBinder; mAllowedCommands = allowedCommands; mAllowedCommands = allowedCommands; mPlaybackActive = playbackActive; // Implementation for the local binder is no-op, // Implementation for the local binder is no-op, // so can be used without worrying about deadlock. // so can be used without worrying about deadlock. sessionBinder.linkToDeath(mDeathRecipient, 0); sessionBinder.linkToDeath(mDeathRecipient, 0); Loading @@ -247,27 +262,27 @@ public class MediaController2 implements AutoCloseable { mCallbackExecutor.execute(() -> { mCallbackExecutor.execute(() -> { mCallback.onConnected(MediaController2.this, allowedCommands); mCallback.onConnected(MediaController2.this, allowedCommands); }); }); } finally { Binder.restoreCallingIdentity(token); } } } // Called by Controller2Link.onDisconnected // Called by Controller2Link.onDisconnected void onDisconnected(int seq) { void onDisconnected(int seq) { final long token = Binder.clearCallingIdentity(); try { // close() will call mCallback.onDisconnected // close() will call mCallback.onDisconnected close(); close(); } finally { Binder.restoreCallingIdentity(token); } } // Called by Controller2Link.onPlaybackActiveChanged void onPlaybackActiveChanged(int seq, boolean playbackActive) { synchronized (mLock) { mPlaybackActive = playbackActive; } mCallbackExecutor.execute(() -> { mCallback.onPlaybackActiveChanged(MediaController2.this, playbackActive); }); } } // Called by Controller2Link.onSessionCommand // Called by Controller2Link.onSessionCommand void onSessionCommand(int seq, Session2Command command, Bundle args, void onSessionCommand(int seq, Session2Command command, Bundle args, @Nullable ResultReceiver resultReceiver) { @Nullable ResultReceiver resultReceiver) { final long token = Binder.clearCallingIdentity(); try { synchronized (mLock) { synchronized (mLock) { mRequestedCommandSeqNumbers.add(seq); mRequestedCommandSeqNumbers.add(seq); } } Loading @@ -290,21 +305,13 @@ public class MediaController2 implements AutoCloseable { } } } } }); }); } finally { Binder.restoreCallingIdentity(token); } } } // Called by Controller2Link.onSessionCommand // Called by Controller2Link.onSessionCommand void onCancelCommand(int seq) { void onCancelCommand(int seq) { final long token = Binder.clearCallingIdentity(); try { synchronized (mLock) { synchronized (mLock) { mRequestedCommandSeqNumbers.remove(seq); mRequestedCommandSeqNumbers.remove(seq); } } } finally { Binder.restoreCallingIdentity(token); } } } private int getNextSeqNumber() { private int getNextSeqNumber() { Loading Loading @@ -392,6 +399,17 @@ public class MediaController2 implements AutoCloseable { */ */ public void onDisconnected(@NonNull MediaController2 controller) {} public void onDisconnected(@NonNull MediaController2 controller) {} /** * Called when the playback of the session's playback activeness is changed. * * @param controller the controller for this event * @param playbackActive {@code true} if the session's playback is active. * {@code false} otherwise. * @see MediaController2#isPlaybackActive() */ public void onPlaybackActiveChanged(@NonNull MediaController2 controller, boolean playbackActive) {} /** /** * Called when the connected session sent a session command. * Called when the connected session sent a session command. * * Loading