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

Commit be9166e3 authored by Santiago Seifert's avatar Santiago Seifert Committed by Android Build Coastguard Worker
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
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:6df9c2f6c41b695c3b9c9ea5a5ee9b6336023370)
Merged-In: I5b16c7f6b5c4996ff40e50274c0e968a3f355674
Change-Id: I5b16c7f6b5c4996ff40e50274c0e968a3f355674
parent c59cfd9a
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 =