Skip to content

Commit 4d26598

Browse files
committed
Fix registering global priority sessions
We were never setting a global priority session due to a change in the way sessions were registered. This makes sure a global session gets set correctly. bug:16930866 Change-Id: I859846c9265e98bb1a37ff9d22808137e787ce18
1 parent 3afd00e commit 4d26598

2 files changed

Lines changed: 4 additions & 23 deletions

File tree

services/core/java/com/android/server/media/MediaSessionService.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ public class MediaSessionService extends SystemService implements Monitor {
8787
private IAudioService mAudioService;
8888
private ContentResolver mContentResolver;
8989

90-
private MediaSessionRecord mPrioritySession;
9190
private int mCurrentUserId = -1;
9291

9392
// Used to notify system UI when remote volume was changed. TODO find a
@@ -125,18 +124,6 @@ public void updateSession(MediaSessionRecord record) {
125124
return;
126125
}
127126
mPriorityStack.onSessionStateChange(record);
128-
if (record.isSystemPriority()) {
129-
if (record.isActive()) {
130-
if (mPrioritySession != null) {
131-
Log.w(TAG, "Replacing existing priority session with a new session");
132-
}
133-
mPrioritySession = record;
134-
} else {
135-
if (mPrioritySession == record) {
136-
mPrioritySession = null;
137-
}
138-
}
139-
}
140127
}
141128
mHandler.post(MessageHandler.MSG_SESSIONS_CHANGED, record.getUserId(), 0);
142129
}
@@ -258,9 +245,6 @@ private void destroySessionLocked(MediaSessionRecord session) {
258245

259246
mPriorityStack.removeSession(session);
260247
mAllSessions.remove(session);
261-
if (session == mPrioritySession) {
262-
mPrioritySession = null;
263-
}
264248

265249
try {
266250
session.getCallback().asBinder().unlinkToDeath(session, 0);
@@ -716,10 +700,6 @@ public void dump(FileDescriptor fd, final PrintWriter pw, String[] args) {
716700
pw.println();
717701

718702
synchronized (mLock) {
719-
pw.println("Session for calls:" + mPrioritySession);
720-
if (mPrioritySession != null) {
721-
mPrioritySession.dump(pw, "");
722-
}
723703
int count = mAllSessions.size();
724704
pw.println(count + " Sessions:");
725705
for (int i = 0; i < count; i++) {

services/core/java/com/android/server/media/MediaSessionStack.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ public class MediaSessionStack {
6363
*/
6464
public void addSession(MediaSessionRecord record) {
6565
mSessions.add(record);
66-
if ((record.getFlags() & MediaSession.FLAG_EXCLUSIVE_GLOBAL_PRIORITY) != 0) {
67-
mGlobalPrioritySession = record;
68-
}
6966
clearCache();
7067
}
7168

@@ -110,6 +107,9 @@ public boolean onPlaystateChange(MediaSessionRecord record, int oldState, int ne
110107
* @param record The record that changed.
111108
*/
112109
public void onSessionStateChange(MediaSessionRecord record) {
110+
if ((record.getFlags() & MediaSession.FLAG_EXCLUSIVE_GLOBAL_PRIORITY) != 0) {
111+
mGlobalPrioritySession = record;
112+
}
113113
// For now just clear the cache. Eventually we'll selectively clear
114114
// depending on what changed.
115115
clearCache();
@@ -220,6 +220,7 @@ public void dump(PrintWriter pw, String prefix) {
220220
ArrayList<MediaSessionRecord> sortedSessions = getPriorityListLocked(false, 0,
221221
UserHandle.USER_ALL);
222222
int count = sortedSessions.size();
223+
pw.println(prefix + "Global priority session is " + mGlobalPrioritySession);
223224
pw.println(prefix + "Sessions Stack - have " + count + " sessions:");
224225
String indent = prefix + " ";
225226
for (int i = 0; i < count; i++) {

0 commit comments

Comments
 (0)