Skip to content

Commit 1f7a39f

Browse files
RoboErikGAndroid (Google) Code Review
authored andcommitted
Merge "Fix registering global priority sessions" into lmp-dev
2 parents f4a1635 + 4d26598 commit 1f7a39f

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
@@ -90,7 +90,6 @@ public class MediaSessionService extends SystemService implements Monitor {
9090
private ContentResolver mContentResolver;
9191
private SettingsObserver mSettingsObserver;
9292

93-
private MediaSessionRecord mPrioritySession;
9493
private int mCurrentUserId = -1;
9594

9695
// Used to notify system UI when remote volume was changed. TODO find a
@@ -130,18 +129,6 @@ public void updateSession(MediaSessionRecord record) {
130129
return;
131130
}
132131
mPriorityStack.onSessionStateChange(record);
133-
if (record.isSystemPriority()) {
134-
if (record.isActive()) {
135-
if (mPrioritySession != null) {
136-
Log.w(TAG, "Replacing existing priority session with a new session");
137-
}
138-
mPrioritySession = record;
139-
} else {
140-
if (mPrioritySession == record) {
141-
mPrioritySession = null;
142-
}
143-
}
144-
}
145132
}
146133
mHandler.post(MessageHandler.MSG_SESSIONS_CHANGED, record.getUserId(), 0);
147134
}
@@ -285,9 +272,6 @@ private void destroySessionLocked(MediaSessionRecord session) {
285272

286273
mPriorityStack.removeSession(session);
287274
mAllSessions.remove(session);
288-
if (session == mPrioritySession) {
289-
mPrioritySession = null;
290-
}
291275

292276
try {
293277
session.getCallback().asBinder().unlinkToDeath(session, 0);
@@ -770,10 +754,6 @@ public void dump(FileDescriptor fd, final PrintWriter pw, String[] args) {
770754
pw.println();
771755

772756
synchronized (mLock) {
773-
pw.println("Session for calls:" + mPrioritySession);
774-
if (mPrioritySession != null) {
775-
mPrioritySession.dump(pw, "");
776-
}
777757
int count = mAllSessions.size();
778758
pw.println(count + " Sessions:");
779759
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)