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

Commit 6df9c2f6 authored by Santiago Seifert's avatar Santiago Seifert
Browse files

Avoid acquiring lock when feature flag is disabled

As of now, the flag doesn't prevent the acquisition of
MediaSessionService#mLock in some methods, which is causing
deadlocks.

Bug: 335454915
Flag: com.android.media.flags.enable_notifying_activity_manager_with_media_session_status_change
Test: Presubmit
Change-Id: I5b16c7f6b5c4996ff40e50274c0e968a3f355674
parent 6e44c398
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -671,6 +671,9 @@ public class MediaSessionService extends SystemService implements Monitor {
    }

    private void addUserEngagedSession(MediaSessionRecordImpl mediaSessionRecord) {
        if (!Flags.enableNotifyingActivityManagerWithMediaSessionStatusChange()) {
            return;
        }
        synchronized (mLock) {
            int uid = mediaSessionRecord.getUid();
            mUserEngagedSessionsForFgs.putIfAbsent(uid, new HashSet<>());
@@ -679,6 +682,9 @@ public class MediaSessionService extends SystemService implements Monitor {
    }

    private void removeUserEngagedSession(MediaSessionRecordImpl mediaSessionRecord) {
        if (!Flags.enableNotifyingActivityManagerWithMediaSessionStatusChange()) {
            return;
        }
        synchronized (mLock) {
            int uid = mediaSessionRecord.getUid();
            Set<MediaSessionRecordImpl> mUidUserEngagedSessionsForFgs =