summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorRoboErik <epastern@google.com>2014-07-24 18:35:11 -0700
committerRoboErik <epastern@google.com>2014-07-25 16:22:59 -0700
commitaa4e23bbb36994708ba72c5f4c83255025d99e07 (patch)
treeba6776a3c108a1a31351c212abfb1ba800f34a15 /services
parentb214efbb9170a9f6a4991684a63ca59680074cc7 (diff)
downloadframeworks_base-aa4e23bbb36994708ba72c5f4c83255025d99e07.zip
frameworks_base-aa4e23bbb36994708ba72c5f4c83255025d99e07.tar.gz
frameworks_base-aa4e23bbb36994708ba72c5f4c83255025d99e07.tar.bz2
Add getPackageName to MediaController
This removes the MediaSessionInfo class and adds a method on the controller to get the package name. This also converts code that depended on the session's UUID to use the token for comparison or the Tag in the case of test code that needs a string identifier. Change-Id: Icb8dc76c70e23e897da8fd07651c524b96372bf9
Diffstat (limited to 'services')
-rw-r--r--services/core/java/com/android/server/media/MediaSessionRecord.java40
-rw-r--r--services/core/java/com/android/server/media/MediaSessionService.java12
2 files changed, 33 insertions, 19 deletions
diff --git a/services/core/java/com/android/server/media/MediaSessionRecord.java b/services/core/java/com/android/server/media/MediaSessionRecord.java
index d0bcfd408..2f1bd60 100644
--- a/services/core/java/com/android/server/media/MediaSessionRecord.java
+++ b/services/core/java/com/android/server/media/MediaSessionRecord.java
@@ -34,14 +34,9 @@ import android.media.session.ISessionController;
import android.media.session.ISessionControllerCallback;
import android.media.session.MediaController;
import android.media.session.MediaSession;
-import android.media.session.MediaSessionInfo;
import android.media.session.ParcelableVolumeInfo;
import android.media.session.PlaybackState;
import android.media.AudioAttributes;
-import android.media.AudioManager;
-import android.media.MediaMetadata;
-import android.media.Rating;
-import android.media.VolumeProvider;
import android.net.Uri;
import android.os.Binder;
import android.os.Bundle;
@@ -86,7 +81,7 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
private final int mOwnerPid;
private final int mOwnerUid;
private final int mUserId;
- private final MediaSessionInfo mSessionInfo;
+ private final String mPackageName;
private final String mTag;
private final ControllerStub mController;
private final SessionStub mSession;
@@ -131,8 +126,7 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
mOwnerPid = ownerPid;
mOwnerUid = ownerUid;
mUserId = userId;
- mSessionInfo = new MediaSessionInfo(UUID.randomUUID().toString(), ownerPackageName,
- ownerPid);
+ mPackageName = ownerPackageName;
mTag = tag;
mController = new ControllerStub();
mSession = new SessionStub();
@@ -166,8 +160,17 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
*
* @return Info that identifies this session.
*/
- public MediaSessionInfo getSessionInfo() {
- return mSessionInfo;
+ public String getPackageName() {
+ return mPackageName;
+ }
+
+ /**
+ * Get the tag for the session.
+ *
+ * @return The session's tag.
+ */
+ public String getTag() {
+ return mTag;
}
/**
@@ -409,9 +412,10 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
pw.println(prefix + mTag + " " + this);
final String indent = prefix + " ";
+ // We print the hashcode for matching with the list in user records
pw.println(indent + "ownerPid=" + mOwnerPid + ", ownerUid=" + mOwnerUid
+ ", userId=" + mUserId);
- pw.println(indent + "info=" + mSessionInfo.toString());
+ pw.println(indent + "package=" + mPackageName);
pw.println(indent + "active=" + mIsActive);
pw.println(indent + "flags=" + mFlags);
pw.println(indent + "rating type=" + mRatingType);
@@ -420,6 +424,11 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
pw.println(indent + "metadata:" + getShortMetadataString());
}
+ @Override
+ public String toString() {
+ return mPackageName + "/" + mTag;
+ }
+
private String getShortMetadataString() {
int fields = mMetadata == null ? 0 : mMetadata.size();
String title = mMetadata == null ? null : mMetadata
@@ -928,8 +937,13 @@ public class MediaSessionRecord implements IBinder.DeathRecipient {
}
@Override
- public MediaSessionInfo getSessionInfo() {
- return mSessionInfo;
+ public String getPackageName() {
+ return mPackageName;
+ }
+
+ @Override
+ public String getTag() {
+ return mTag;
}
@Override
diff --git a/services/core/java/com/android/server/media/MediaSessionService.java b/services/core/java/com/android/server/media/MediaSessionService.java
index ce2899d..92644ce 100644
--- a/services/core/java/com/android/server/media/MediaSessionService.java
+++ b/services/core/java/com/android/server/media/MediaSessionService.java
@@ -516,9 +516,9 @@ public class MediaSessionService extends SystemService implements Monitor {
int size = mSessions.size();
pw.println(indent + size + " Sessions:");
for (int i = 0; i < size; i++) {
- // Just print the session info, the full session dump will
+ // Just print the short version, the full session dump will
// already be in the list of all sessions.
- pw.println(indent + mSessions.get(i).getSessionInfo());
+ pw.println(indent + mSessions.get(i).toString());
}
}
}
@@ -759,9 +759,9 @@ public class MediaSessionService extends SystemService implements Monitor {
private void dispatchAdjustVolumeLocked(int suggestedStream, int direction, int flags,
MediaSessionRecord session) {
if (DEBUG) {
- String sessionInfo = session == null ? null : session.getSessionInfo().toString();
- Log.d(TAG, "Adjusting session " + sessionInfo + " by " + direction + ". flags=" + flags
- + ", suggestedStream=" + suggestedStream);
+ String description = session == null ? null : session.toString();
+ Log.d(TAG, "Adjusting session " + description + " by " + direction + ". flags="
+ + flags + ", suggestedStream=" + suggestedStream);
}
if (session == null) {
@@ -824,7 +824,7 @@ public class MediaSessionService extends SystemService implements Monitor {
MediaSessionRecord session) {
if (session != null) {
if (DEBUG) {
- Log.d(TAG, "Sending media key to " + session.getSessionInfo());
+ Log.d(TAG, "Sending media key to " + session.toString());
}
if (needWakeLock) {
mKeyEventReceiver.aquireWakeLockLocked();