diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index 4d05c36cff3a32a9be975640aa42ab7e564eeff0..4e029fde8bf57f09b2e14ef3f67763917285a98c 100755 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -2291,7 +2291,7 @@ public class NotificationManagerService extends SystemService { @VisibleForTesting void clearNotifications() { - synchronized (mNotificationList) { + synchronized (mNotificationLock) { mEnqueuedNotifications.clear(); mNotificationList.clear(); mNotificationsByKey.clear(); @@ -2301,21 +2301,27 @@ public class NotificationManagerService extends SystemService { @VisibleForTesting void addNotification(NotificationRecord r) { - mNotificationList.add(r); - mNotificationsByKey.put(r.getSbn().getKey(), r); - if (r.getSbn().isGroup()) { - mSummaryByGroupKey.put(r.getGroupKey(), r); + synchronized (mNotificationLock) { + mNotificationList.add(r); + mNotificationsByKey.put(r.getSbn().getKey(), r); + if (r.getSbn().isGroup()) { + mSummaryByGroupKey.put(r.getGroupKey(), r); + } } } @VisibleForTesting void addEnqueuedNotification(NotificationRecord r) { - mEnqueuedNotifications.add(r); + synchronized (mNotificationLock) { + mEnqueuedNotifications.add(r); + } } @VisibleForTesting NotificationRecord getNotificationRecord(String key) { - return mNotificationsByKey.get(key); + synchronized (mNotificationLock) { + return mNotificationsByKey.get(key); + } }