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

Commit c4ca1b56 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Ensure removeForegroundService checks both lists under lock" into oc-dev

parents aadf525e 87237d70
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,