diff options
author | RoboErik <epastern@google.com> | 2014-05-12 21:20:49 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2014-05-12 21:20:49 +0000 |
commit | f33e99828f32bdbcf8e2590c9475f4cd840f189d (patch) | |
tree | 935343e211d4089f579f7c5c955d6cbea5d5a2f8 /media | |
parent | 9bbc0ca0ab5e381be8a05ee457f2b93a3f0d63bc (diff) | |
parent | a5b02329209be355eafadbdf9ee685ffa58d3148 (diff) | |
download | frameworks_base-f33e99828f32bdbcf8e2590c9475f4cd840f189d.zip frameworks_base-f33e99828f32bdbcf8e2590c9475f4cd840f189d.tar.gz frameworks_base-f33e99828f32bdbcf8e2590c9475f4cd840f189d.tar.bz2 |
Merge "Make sessions aware of user id"
Diffstat (limited to 'media')
-rw-r--r-- | media/java/android/media/session/ISessionManager.aidl | 4 | ||||
-rw-r--r-- | media/java/android/media/session/SessionManager.java | 38 |
2 files changed, 38 insertions, 4 deletions
diff --git a/media/java/android/media/session/ISessionManager.aidl b/media/java/android/media/session/ISessionManager.aidl index 7a8c22e..e341647 100644 --- a/media/java/android/media/session/ISessionManager.aidl +++ b/media/java/android/media/session/ISessionManager.aidl @@ -25,6 +25,6 @@ import android.os.Bundle; * @hide */ interface ISessionManager { - ISession createSession(String packageName, in ISessionCallback cb, String tag); - List<IBinder> getSessions(in ComponentName compName); + ISession createSession(String packageName, in ISessionCallback cb, String tag, int userId); + List<IBinder> getSessions(in ComponentName compName, int userId); }
\ No newline at end of file diff --git a/media/java/android/media/session/SessionManager.java b/media/java/android/media/session/SessionManager.java index fd022fc..1eb3b7a 100644 --- a/media/java/android/media/session/SessionManager.java +++ b/media/java/android/media/session/SessionManager.java @@ -22,6 +22,7 @@ import android.media.session.ISessionManager; import android.os.IBinder; import android.os.RemoteException; import android.os.ServiceManager; +import android.os.UserHandle; import android.service.notification.NotificationListenerService; import android.util.Log; @@ -65,10 +66,25 @@ public final class SessionManager { * @return a {@link Session} for the new session */ public Session createSession(String tag) { + return createSessionAsUser(tag, UserHandle.myUserId()); + } + + /** + * Creates a new session as the specified user. To create a session as a + * user other than your own you must hold the + * {@link android.Manifest.permission#INTERACT_ACROSS_USERS_FULL} + * permission. + * + * @param tag A short name for debugging purposes + * @param userId The user id to create the session as. + * @return a {@link Session} for the new session + * @hide + */ + public Session createSessionAsUser(String tag, int userId) { try { Session.CallbackStub cbStub = new Session.CallbackStub(); Session session = new Session(mService - .createSession(mContext.getPackageName(), cbStub, tag), cbStub); + .createSession(mContext.getPackageName(), cbStub, tag, userId), cbStub); cbStub.setMediaSession(session); return session; @@ -91,9 +107,27 @@ public final class SessionManager { * @return A list of controllers for ongoing sessions */ public List<SessionController> getActiveSessions(ComponentName notificationListener) { + return getActiveSessionsForUser(notificationListener, UserHandle.myUserId()); + } + + /** + * Get active sessions for a specific user. To retrieve actions for a user + * other than your own you must hold the + * {@link android.Manifest.permission#INTERACT_ACROSS_USERS_FULL} permission + * in addition to any other requirements. If you are an enabled notification + * listener you may only get sessions for the users you are enabled for. + * + * @param notificationListener The enabled notification listener component. + * May be null. + * @param userId The user id to fetch sessions for. + * @return A list of controllers for ongoing sessions. + * @hide + */ + public List<SessionController> getActiveSessionsForUser(ComponentName notificationListener, + int userId) { ArrayList<SessionController> controllers = new ArrayList<SessionController>(); try { - List<IBinder> binders = mService.getSessions(notificationListener); + List<IBinder> binders = mService.getSessions(notificationListener, userId); for (int i = binders.size() - 1; i >= 0; i--) { SessionController controller = SessionController.fromBinder(ISessionController.Stub .asInterface(binders.get(i))); |