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

Commit 87237d70 authored by Geoffrey Pitsch's avatar Geoffrey Pitsch
Browse files

Ensure removeForegroundService checks both lists under lock

Prior CL didn't lock properly and would still fail if a
notification was both enqueued and posted at the same time.

Test: runtest systemui-notification
Change-Id: I1bdd779ecb872f1a02ffc38b6007239eb522b521
Fixes: 36550043
parent 061db23b
Loading
Loading
Loading
Loading
+26 −24
Original line number Diff line number Diff line
@@ -3071,17 +3071,22 @@ public class NotificationManagerService extends SystemService {
        public void removeForegroundServiceFlagFromNotification(String pkg, int notificationId,
                int userId) {
            checkCallerIsSystem();
            synchronized (mNotificationLock) {
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    synchronized (mNotificationLock) {
                        removeForegroundServiceFlagByListLocked(mEnqueuedNotifications, pkg, notificationId, userId);
                        removeForegroundServiceFlagByListLocked(mNotificationList, pkg, notificationId, userId);
                    }
                }
            });
        }

        private void removeForegroundServiceFlagByListLocked(
                ArrayList<NotificationRecord> notificationList, String pkg, int notificationId, int userId) {
            NotificationRecord r =
                                findNotificationLocked(pkg, null, notificationId, userId);
                    findNotificationByListLocked(notificationList, pkg, null, notificationId, userId);
            if (r == null) {
                            Log.d(TAG,
                                    "stripForegroundServiceFlag: Could not find notification with "
                                    + "pkg=" + pkg + " / id=" + notificationId
                                    + " / userId=" + userId);
                return;
            }
            StatusBarNotification sbn = r.sbn;
@@ -3095,9 +3100,6 @@ public class NotificationManagerService extends SystemService {
            mListeners.notifyPostedLocked(sbn, sbn /* oldSbn */);
            mGroupHelper.onNotificationPosted(sbn);
        }
                });
            }
        }
    };

    void enqueueNotificationInternal(final String pkg, final String opPkg, final int callingUid,