Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -16718,6 +16718,7 @@ package android.media.session { method public void onPlaybackStateChanged(android.media.session.PlaybackState); method public void onQueueChanged(java.util.List<android.media.session.MediaSession.Track>); method public void onQueueTitleChanged(java.lang.CharSequence); method public void onSessionDestroyed(); method public void onSessionEvent(java.lang.String, android.os.Bundle); method public void onVolumeInfoChanged(android.media.session.MediaController.VolumeInfo); } cmds/media/src/com/android/commands/media/Media.java +7 −0 Original line number Diff line number Diff line Loading @@ -178,6 +178,13 @@ public class Media extends BaseCommand { public ControllerMonitor(ISessionController controller) { mController = controller; } @Override public void onSessionDestroyed() { System.out.println("onSessionDestroyed. Enter q to quit."); } @Override public void onEvent(String event, Bundle extras) { System.out.println("onSessionEvent event=" + event + ", extras=" + extras); Loading media/java/android/media/session/ISessionControllerCallback.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.os.Bundle; */ oneway interface ISessionControllerCallback { void onEvent(String event, in Bundle extras); void onSessionDestroyed(); // These callbacks are for the TransportController void onPlaybackStateChanged(in PlaybackState state); Loading media/java/android/media/session/MediaController.java +19 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,7 @@ public final class MediaController { private static final int MSG_UPDATE_QUEUE = 5; private static final int MSG_UPDATE_QUEUE_TITLE = 6; private static final int MSG_UPDATE_EXTRAS = 7; private static final int MSG_DESTROYED = 8; private final ISessionController mSessionBinder; Loading Loading @@ -507,6 +508,13 @@ public final class MediaController { * registered using {@link #addCallback} */ public static abstract class Callback { /** * Override to handle the session being destroyed. The session is no * longer valid after this call and calls to it will be ignored. */ public void onSessionDestroyed() { } /** * Override to handle custom events sent by the session owner without a * specified interface. Controllers should only handle these for Loading Loading @@ -862,6 +870,14 @@ public final class MediaController { mController = new WeakReference<MediaController>(controller); } @Override public void onSessionDestroyed() { MediaController controller = mController.get(); if (controller != null) { controller.postMessage(MSG_DESTROYED, null, null); } } @Override public void onEvent(String event, Bundle extras) { MediaController controller = mController.get(); Loading Loading @@ -955,6 +971,9 @@ public final class MediaController { case MSG_UPDATE_VOLUME: mCallback.onVolumeInfoChanged((VolumeInfo) msg.obj); break; case MSG_DESTROYED: mCallback.onSessionDestroyed(); break; } } Loading services/core/java/com/android/server/media/MediaSessionRecord.java +37 −0 Original line number Diff line number Diff line Loading @@ -397,6 +397,7 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { return; } mDestroyed = true; mHandler.post(MessageHandler.MSG_DESTROYED); } } Loading Loading @@ -575,6 +576,29 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { } } private void pushSessionDestroyed() { synchronized (mLock) { // This is the only method that may be (and can only be) called // after the session is destroyed. if (!mDestroyed) { return; } for (int i = mControllerCallbacks.size() - 1; i >= 0; i--) { ISessionControllerCallback cb = mControllerCallbacks.get(i); try { cb.onSessionDestroyed(); } catch (DeadObjectException e) { Log.w(TAG, "Removing dead callback in pushEvent.", e); mControllerCallbacks.remove(i); } catch (RemoteException e) { Log.w(TAG, "unexpected exception in pushEvent.", e); } } // After notifying clear all listeners mControllerCallbacks.clear(); } } private PlaybackState getStateWithUpdatedPosition() { PlaybackState state = mPlaybackState; long duration = -1; Loading Loading @@ -919,6 +943,16 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { @Override public void registerCallbackListener(ISessionControllerCallback cb) { synchronized (mLock) { // If this session is already destroyed tell the caller and // don't add them. if (mDestroyed) { try { cb.onSessionDestroyed(); } catch (Exception e) { // ignored } return; } if (getControllerCbIndexForCb(cb) < 0) { mControllerCallbacks.add(cb); if (DEBUG) { Loading Loading @@ -1123,6 +1157,7 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { private static final int MSG_SEND_EVENT = 6; private static final int MSG_UPDATE_SESSION_STATE = 7; private static final int MSG_UPDATE_VOLUME = 8; private static final int MSG_DESTROYED = 9; public MessageHandler(Looper looper) { super(looper); Loading Loading @@ -1154,6 +1189,8 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { case MSG_UPDATE_VOLUME: pushVolumeUpdate(); break; case MSG_DESTROYED: pushSessionDestroyed(); } } Loading Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -16718,6 +16718,7 @@ package android.media.session { method public void onPlaybackStateChanged(android.media.session.PlaybackState); method public void onQueueChanged(java.util.List<android.media.session.MediaSession.Track>); method public void onQueueTitleChanged(java.lang.CharSequence); method public void onSessionDestroyed(); method public void onSessionEvent(java.lang.String, android.os.Bundle); method public void onVolumeInfoChanged(android.media.session.MediaController.VolumeInfo); }
cmds/media/src/com/android/commands/media/Media.java +7 −0 Original line number Diff line number Diff line Loading @@ -178,6 +178,13 @@ public class Media extends BaseCommand { public ControllerMonitor(ISessionController controller) { mController = controller; } @Override public void onSessionDestroyed() { System.out.println("onSessionDestroyed. Enter q to quit."); } @Override public void onEvent(String event, Bundle extras) { System.out.println("onSessionEvent event=" + event + ", extras=" + extras); Loading
media/java/android/media/session/ISessionControllerCallback.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.os.Bundle; */ oneway interface ISessionControllerCallback { void onEvent(String event, in Bundle extras); void onSessionDestroyed(); // These callbacks are for the TransportController void onPlaybackStateChanged(in PlaybackState state); Loading
media/java/android/media/session/MediaController.java +19 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,7 @@ public final class MediaController { private static final int MSG_UPDATE_QUEUE = 5; private static final int MSG_UPDATE_QUEUE_TITLE = 6; private static final int MSG_UPDATE_EXTRAS = 7; private static final int MSG_DESTROYED = 8; private final ISessionController mSessionBinder; Loading Loading @@ -507,6 +508,13 @@ public final class MediaController { * registered using {@link #addCallback} */ public static abstract class Callback { /** * Override to handle the session being destroyed. The session is no * longer valid after this call and calls to it will be ignored. */ public void onSessionDestroyed() { } /** * Override to handle custom events sent by the session owner without a * specified interface. Controllers should only handle these for Loading Loading @@ -862,6 +870,14 @@ public final class MediaController { mController = new WeakReference<MediaController>(controller); } @Override public void onSessionDestroyed() { MediaController controller = mController.get(); if (controller != null) { controller.postMessage(MSG_DESTROYED, null, null); } } @Override public void onEvent(String event, Bundle extras) { MediaController controller = mController.get(); Loading Loading @@ -955,6 +971,9 @@ public final class MediaController { case MSG_UPDATE_VOLUME: mCallback.onVolumeInfoChanged((VolumeInfo) msg.obj); break; case MSG_DESTROYED: mCallback.onSessionDestroyed(); break; } } Loading
services/core/java/com/android/server/media/MediaSessionRecord.java +37 −0 Original line number Diff line number Diff line Loading @@ -397,6 +397,7 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { return; } mDestroyed = true; mHandler.post(MessageHandler.MSG_DESTROYED); } } Loading Loading @@ -575,6 +576,29 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { } } private void pushSessionDestroyed() { synchronized (mLock) { // This is the only method that may be (and can only be) called // after the session is destroyed. if (!mDestroyed) { return; } for (int i = mControllerCallbacks.size() - 1; i >= 0; i--) { ISessionControllerCallback cb = mControllerCallbacks.get(i); try { cb.onSessionDestroyed(); } catch (DeadObjectException e) { Log.w(TAG, "Removing dead callback in pushEvent.", e); mControllerCallbacks.remove(i); } catch (RemoteException e) { Log.w(TAG, "unexpected exception in pushEvent.", e); } } // After notifying clear all listeners mControllerCallbacks.clear(); } } private PlaybackState getStateWithUpdatedPosition() { PlaybackState state = mPlaybackState; long duration = -1; Loading Loading @@ -919,6 +943,16 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { @Override public void registerCallbackListener(ISessionControllerCallback cb) { synchronized (mLock) { // If this session is already destroyed tell the caller and // don't add them. if (mDestroyed) { try { cb.onSessionDestroyed(); } catch (Exception e) { // ignored } return; } if (getControllerCbIndexForCb(cb) < 0) { mControllerCallbacks.add(cb); if (DEBUG) { Loading Loading @@ -1123,6 +1157,7 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { private static final int MSG_SEND_EVENT = 6; private static final int MSG_UPDATE_SESSION_STATE = 7; private static final int MSG_UPDATE_VOLUME = 8; private static final int MSG_DESTROYED = 9; public MessageHandler(Looper looper) { super(looper); Loading Loading @@ -1154,6 +1189,8 @@ public class MediaSessionRecord implements IBinder.DeathRecipient { case MSG_UPDATE_VOLUME: pushVolumeUpdate(); break; case MSG_DESTROYED: pushSessionDestroyed(); } } Loading