Loading Android.mk +9 −8 Original line number Diff line number Diff line Loading @@ -307,6 +307,7 @@ LOCAL_SRC_FILES += \ media/java/android/media/routeprovider/IRouteConnection.aidl \ media/java/android/media/routeprovider/IRouteProvider.aidl \ media/java/android/media/routeprovider/IRouteProviderCallback.aidl \ media/java/android/media/session/IActiveSessionsListener.aidl \ media/java/android/media/session/ISessionController.aidl \ media/java/android/media/session/ISessionControllerCallback.aidl \ media/java/android/media/session/ISession.aidl \ Loading media/java/android/media/session/IActiveSessionsListener.aidl 0 → 100644 +26 −0 Original line number Diff line number Diff line /* Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.media.session; import android.media.session.MediaSessionToken; /** * Listens for changes to the list of active sessions. * @hide */ oneway interface IActiveSessionsListener { void onActiveSessionsChanged(in List<MediaSessionToken> sessions); } No newline at end of file media/java/android/media/session/ISessionManager.aidl +4 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.media.session; import android.content.ComponentName; import android.media.session.IActiveSessionsListener; import android.media.session.ISession; import android.media.session.ISessionCallback; import android.os.Bundle; Loading @@ -30,4 +31,7 @@ interface ISessionManager { List<IBinder> getSessions(in ComponentName compName, int userId); void dispatchMediaKeyEvent(in KeyEvent keyEvent, boolean needWakeLock); void dispatchAdjustVolumeBy(int suggestedStream, int delta, int flags); void addSessionsListener(in IActiveSessionsListener listener, in ComponentName compName, int userId); void removeSessionsListener(in IActiveSessionsListener listener); } No newline at end of file media/java/android/media/session/MediaSessionManager.java +75 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,50 @@ public final class MediaSessionManager { return controllers; } /** * Add a listener to be notified when the list of active sessions * changes.This requires the * android.Manifest.permission.MEDIA_CONTENT_CONTROL permission be held by * the calling app. You may also retrieve this list if your app is an * enabled notification listener using the * {@link NotificationListenerService} APIs, in which case you must pass the * {@link ComponentName} of your enabled listener. * * @param sessionListener The listener to add. * @param notificationListener The enabled notification listener component. * May be null. * @param userId The userId to listen for changes on. * @hide */ public void addActiveSessionsListener(SessionListener sessionListener, ComponentName notificationListener, int userId) { if (sessionListener == null) { throw new IllegalArgumentException("listener may not be null"); } try { mService.addSessionsListener(sessionListener.mStub, notificationListener, userId); } catch (RemoteException e) { Log.e(TAG, "Error in addActiveSessionsListener.", e); } } /** * Stop receiving active sessions updates on the specified listener. * * @param listener The listener to remove. * @hide */ public void removeActiveSessionsListener(SessionListener listener) { if (listener == null) { throw new IllegalArgumentException("listener may not be null"); } try { mService.removeSessionsListener(listener.mStub); } catch (RemoteException e) { Log.e(TAG, "Error in removeActiveSessionsListener.", e); } } /** * Send a media key event. The receiver will be selected automatically. * Loading Loading @@ -184,4 +228,35 @@ public final class MediaSessionManager { Log.e(TAG, "Failed to send adjust volume.", e); } } /** * Listens for changes to the list of active sessions. This can be added * using {@link #addActiveSessionsListener}. * * @hide */ public static abstract class SessionListener { /** * Called when the list of active sessions has changed. This can be due * to a session being added or removed or the order of sessions * changing. * * @param controllers The updated list of controllers for the user that * changed. */ public abstract void onActiveSessionsChanged(List<MediaController> controllers); private final IActiveSessionsListener.Stub mStub = new IActiveSessionsListener.Stub() { @Override public void onActiveSessionsChanged(List<MediaSessionToken> tokens) throws RemoteException { ArrayList<MediaController> controllers = new ArrayList<MediaController>(); int size = tokens.size(); for (int i = 0; i < size; i++) { controllers.add(MediaController.fromToken(tokens.get(i))); } SessionListener.this.onActiveSessionsChanged(controllers); } }; } } media/java/android/media/session/MediaSessionToken.java +1 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ public final class MediaSessionToken implements Parcelable { /** * @hide */ MediaSessionToken(ISessionController binder) { public MediaSessionToken(ISessionController binder) { mBinder = binder; } Loading Loading
Android.mk +9 −8 Original line number Diff line number Diff line Loading @@ -307,6 +307,7 @@ LOCAL_SRC_FILES += \ media/java/android/media/routeprovider/IRouteConnection.aidl \ media/java/android/media/routeprovider/IRouteProvider.aidl \ media/java/android/media/routeprovider/IRouteProviderCallback.aidl \ media/java/android/media/session/IActiveSessionsListener.aidl \ media/java/android/media/session/ISessionController.aidl \ media/java/android/media/session/ISessionControllerCallback.aidl \ media/java/android/media/session/ISession.aidl \ Loading
media/java/android/media/session/IActiveSessionsListener.aidl 0 → 100644 +26 −0 Original line number Diff line number Diff line /* Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.media.session; import android.media.session.MediaSessionToken; /** * Listens for changes to the list of active sessions. * @hide */ oneway interface IActiveSessionsListener { void onActiveSessionsChanged(in List<MediaSessionToken> sessions); } No newline at end of file
media/java/android/media/session/ISessionManager.aidl +4 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.media.session; import android.content.ComponentName; import android.media.session.IActiveSessionsListener; import android.media.session.ISession; import android.media.session.ISessionCallback; import android.os.Bundle; Loading @@ -30,4 +31,7 @@ interface ISessionManager { List<IBinder> getSessions(in ComponentName compName, int userId); void dispatchMediaKeyEvent(in KeyEvent keyEvent, boolean needWakeLock); void dispatchAdjustVolumeBy(int suggestedStream, int delta, int flags); void addSessionsListener(in IActiveSessionsListener listener, in ComponentName compName, int userId); void removeSessionsListener(in IActiveSessionsListener listener); } No newline at end of file
media/java/android/media/session/MediaSessionManager.java +75 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,50 @@ public final class MediaSessionManager { return controllers; } /** * Add a listener to be notified when the list of active sessions * changes.This requires the * android.Manifest.permission.MEDIA_CONTENT_CONTROL permission be held by * the calling app. You may also retrieve this list if your app is an * enabled notification listener using the * {@link NotificationListenerService} APIs, in which case you must pass the * {@link ComponentName} of your enabled listener. * * @param sessionListener The listener to add. * @param notificationListener The enabled notification listener component. * May be null. * @param userId The userId to listen for changes on. * @hide */ public void addActiveSessionsListener(SessionListener sessionListener, ComponentName notificationListener, int userId) { if (sessionListener == null) { throw new IllegalArgumentException("listener may not be null"); } try { mService.addSessionsListener(sessionListener.mStub, notificationListener, userId); } catch (RemoteException e) { Log.e(TAG, "Error in addActiveSessionsListener.", e); } } /** * Stop receiving active sessions updates on the specified listener. * * @param listener The listener to remove. * @hide */ public void removeActiveSessionsListener(SessionListener listener) { if (listener == null) { throw new IllegalArgumentException("listener may not be null"); } try { mService.removeSessionsListener(listener.mStub); } catch (RemoteException e) { Log.e(TAG, "Error in removeActiveSessionsListener.", e); } } /** * Send a media key event. The receiver will be selected automatically. * Loading Loading @@ -184,4 +228,35 @@ public final class MediaSessionManager { Log.e(TAG, "Failed to send adjust volume.", e); } } /** * Listens for changes to the list of active sessions. This can be added * using {@link #addActiveSessionsListener}. * * @hide */ public static abstract class SessionListener { /** * Called when the list of active sessions has changed. This can be due * to a session being added or removed or the order of sessions * changing. * * @param controllers The updated list of controllers for the user that * changed. */ public abstract void onActiveSessionsChanged(List<MediaController> controllers); private final IActiveSessionsListener.Stub mStub = new IActiveSessionsListener.Stub() { @Override public void onActiveSessionsChanged(List<MediaSessionToken> tokens) throws RemoteException { ArrayList<MediaController> controllers = new ArrayList<MediaController>(); int size = tokens.size(); for (int i = 0; i < size; i++) { controllers.add(MediaController.fromToken(tokens.get(i))); } SessionListener.this.onActiveSessionsChanged(controllers); } }; } }
media/java/android/media/session/MediaSessionToken.java +1 −1 Original line number Diff line number Diff line Loading @@ -31,7 +31,7 @@ public final class MediaSessionToken implements Parcelable { /** * @hide */ MediaSessionToken(ISessionController binder) { public MediaSessionToken(ISessionController binder) { mBinder = binder; } Loading