diff options
author | RoboErik <epastern@google.com> | 2014-05-07 17:05:49 -0700 |
---|---|---|
committer | RoboErik <epastern@google.com> | 2014-05-08 14:24:14 -0700 |
commit | a5b02329209be355eafadbdf9ee685ffa58d3148 (patch) | |
tree | ac6b3b03bc6d55431a8604cd217a6f455241a463 /media/java | |
parent | 12319badd62471aee422c3383d30656a528ea2b1 (diff) | |
download | frameworks_base-a5b02329209be355eafadbdf9ee685ffa58d3148.zip frameworks_base-a5b02329209be355eafadbdf9ee685ffa58d3148.tar.gz frameworks_base-a5b02329209be355eafadbdf9ee685ffa58d3148.tar.bz2 |
Make sessions aware of user id
This tags all sessions with the user id that they were created for. It
also adds API for creating and querying sessions for a specific user.
This does not wrap providers per user yet which will be done in a
separate CL.
Change-Id: Icdaf701b0614a95301657998602c45208d548c27
Diffstat (limited to 'media/java')
-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))); |