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

Commit 228d634a authored by tonihei's avatar tonihei
Browse files

Simplify notification tracking in MediaSessionService

We are only really interested in new notifications for a
foreground service, so can ignore all non-FGS notifications
and also all follow-up notification updates for the same
notification. This should be a no-op change (no test failures)
and just reduces the number of calls through to ActivityManager.

Flag: com.android.media.flags.enable_notifying_activity_manager_with_media_session_status_change
Test: atest ActivityManagerNotifyMediaFGSTypeTest
Bug: 281762171
Change-Id: I3351f412edd48fcd523aa131f727b02ffdf536f2
parent a99ba3dd
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -3269,13 +3269,21 @@ public class MediaSessionService extends SystemService implements Monitor {
            if (!postedNotification.isMediaNotification()) {
                return;
            }
            if ((postedNotification.flags & Notification.FLAG_FOREGROUND_SERVICE) == 0) {
                // Ignore notifications posted without a foreground service.
                return;
            }
            synchronized (mLock) {
                Map<String, StatusBarNotification> notifications = mMediaNotifications.get(uid);
                if (notifications == null) {
                    notifications = new HashMap<>();
                    mMediaNotifications.put(uid, notifications);
                }
                notifications.put(sbn.getKey(), sbn);
                StatusBarNotification previousSbn = notifications.put(sbn.getKey(), sbn);
                if (previousSbn != null) {
                    // Only act on the first notification update.
                    return;
                }
                MediaSessionRecordImpl userEngagedRecord =
                        getUserEngagedMediaSessionRecordForNotification(uid, postedNotification);
                if (userEngagedRecord != null) {