Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1f7a39fe authored by RoboErik's avatar RoboErik Committed by Android (Google) Code Review
Browse files

Merge "Fix registering global priority sessions" into lmp-dev

parents f4a16350 4d265986
Loading
Loading
Loading
Loading
+0 −20
Original line number Diff line number Diff line
@@ -90,7 +90,6 @@ public class MediaSessionService extends SystemService implements Monitor {
    private ContentResolver mContentResolver;
    private SettingsObserver mSettingsObserver;

    private MediaSessionRecord mPrioritySession;
    private int mCurrentUserId = -1;

    // Used to notify system UI when remote volume was changed. TODO find a
@@ -130,18 +129,6 @@ public class MediaSessionService extends SystemService implements Monitor {
                return;
            }
            mPriorityStack.onSessionStateChange(record);
            if (record.isSystemPriority()) {
                if (record.isActive()) {
                    if (mPrioritySession != null) {
                        Log.w(TAG, "Replacing existing priority session with a new session");
                    }
                    mPrioritySession = record;
                } else {
                    if (mPrioritySession == record) {
                        mPrioritySession = null;
                    }
                }
            }
        }
        mHandler.post(MessageHandler.MSG_SESSIONS_CHANGED, record.getUserId(), 0);
    }
@@ -285,9 +272,6 @@ public class MediaSessionService extends SystemService implements Monitor {

        mPriorityStack.removeSession(session);
        mAllSessions.remove(session);
        if (session == mPrioritySession) {
            mPrioritySession = null;
        }

        try {
            session.getCallback().asBinder().unlinkToDeath(session, 0);
@@ -770,10 +754,6 @@ public class MediaSessionService extends SystemService implements Monitor {
            pw.println();

            synchronized (mLock) {
                pw.println("Session for calls:" + mPrioritySession);
                if (mPrioritySession != null) {
                    mPrioritySession.dump(pw, "");
                }
                int count = mAllSessions.size();
                pw.println(count + " Sessions:");
                for (int i = 0; i < count; i++) {
+4 −3
Original line number Diff line number Diff line
@@ -63,9 +63,6 @@ public class MediaSessionStack {
     */
    public void addSession(MediaSessionRecord record) {
        mSessions.add(record);
        if ((record.getFlags() & MediaSession.FLAG_EXCLUSIVE_GLOBAL_PRIORITY) != 0) {
            mGlobalPrioritySession = record;
        }
        clearCache();
    }

@@ -110,6 +107,9 @@ public class MediaSessionStack {
     * @param record The record that changed.
     */
    public void onSessionStateChange(MediaSessionRecord record) {
        if ((record.getFlags() & MediaSession.FLAG_EXCLUSIVE_GLOBAL_PRIORITY) != 0) {
            mGlobalPrioritySession = record;
        }
        // For now just clear the cache. Eventually we'll selectively clear
        // depending on what changed.
        clearCache();
@@ -220,6 +220,7 @@ public class MediaSessionStack {
        ArrayList<MediaSessionRecord> sortedSessions = getPriorityListLocked(false, 0,
                UserHandle.USER_ALL);
        int count = sortedSessions.size();
        pw.println(prefix + "Global priority session is " + mGlobalPrioritySession);
        pw.println(prefix + "Sessions Stack - have " + count + " sessions:");
        String indent = prefix + "  ";
        for (int i = 0; i < count; i++) {