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

Commit 3dd277ff authored by Iván Budnik's avatar Iván Budnik
Browse files

Remove unnecessary volume session cache

Cache was preventing correct evaluation of sessions for volume handling.

Bug: 228021646
Test: N/A
Change-Id: I3dde450625255f5e971426acba87d867f2dc07af
parent 9404e5a1
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -63,8 +63,6 @@ class MediaSessionStack {
     */
    private MediaSessionRecordImpl mMediaButtonSession;

    private MediaSessionRecordImpl mCachedVolumeDefault;

    /**
     * Cache the result of the {@link #getActiveSessions} per user.
     */
@@ -145,9 +143,6 @@ class MediaSessionStack {
            mSessions.remove(record);
            mSessions.add(0, record);
            clearCache(record.getUserId());
        } else if (record.checkPlaybackActiveState(false)) {
            // Just clear the volume cache when a state goes inactive
            mCachedVolumeDefault = null;
        }

        // In most cases, playback state isn't needed for finding media button session,
@@ -318,15 +313,11 @@ class MediaSessionStack {
    }

    public MediaSessionRecordImpl getDefaultVolumeSession() {
        if (mCachedVolumeDefault != null) {
            return mCachedVolumeDefault;
        }
        List<MediaSessionRecord> records = getPriorityList(true, UserHandle.USER_ALL);
        int size = records.size();
        for (int i = 0; i < size; i++) {
            MediaSessionRecord record = records.get(i);
            if (record.checkPlaybackActiveState(true) && record.canHandleVolumeKey()) {
                mCachedVolumeDefault = record;
                return record;
            }
        }
@@ -406,7 +397,6 @@ class MediaSessionStack {
    }

    private void clearCache(int userId) {
        mCachedVolumeDefault = null;
        mCachedActiveLists.remove(userId);
        // mCachedActiveLists may also include the list of sessions for UserHandle.USER_ALL,
        // so they also need to be cleared.