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

Commit 538b1408 authored by tonihei's avatar tonihei
Browse files

Remove session from user engaged list when destroyed

This prevents references to a destroyed session being kept forever
Also more clearly clean out the final state in MediaSessionRecord

Test: Verified references are gone in heapdump
Flag: com.android.media.flags.enable_notifying_activity_manager_with_media_session_status_change
Bug: 295518668
Change-Id: If5b50c8ffc9be0078a12ca1bccf17e7b30bbd8e3
parent 6b09a7a6
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -581,8 +581,8 @@ public class MediaSessionRecord extends MediaSessionRecordImpl implements IBinde
            mSessionCb.mCb.asBinder().unlinkToDeath(this, 0);
            mDestroyed = true;
            mPlaybackState = null;
            updateUserEngagedStateIfNeededLocked(
                    /* isTimeoutExpired= */ true, /* isGlobalPrioritySessionActive= */ false);
            mUserEngagementState = USER_DISENGAGED;
            mHandler.removeCallbacks(mUserEngagementTimeoutExpirationRunnable);
            mHandler.post(MessageHandler.MSG_DESTROYED);
        }
    }
+1 −0
Original line number Diff line number Diff line
@@ -687,6 +687,7 @@ public class MediaSessionService extends SystemService implements Monitor {

        Log.d(TAG, "destroySessionLocked: record=" + session);

        removeUserEngagedSession(session);
        reportMediaInteractionEvent(session, /* userEngaged= */ false);
        mHandler.postSessionsChanged(session);
    }