summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jeff DeCew <jeffdq@google.com> 2024-06-04 14:31:13 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2024-06-04 14:31:13 +0000
commitdbf21119ebd615e44c43c96ad62ab3237a5634a2 (patch)
treea0e1be683b2086679eb3e2f3ae0b1180cb40b670
parent8a053fe3b46d55a86507f3da6b80d6bc759eec76 (diff)
parenta64fca5861335907bc64b0d87b72efd01b8b36ff (diff)
Merge "NotificationManagerService: add right lock for some methods." into main am: a64fca5861
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/3109837 Change-Id: I11a3044a8adafc3ec4950b0e6e06b28ee1ec5f12 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rwxr-xr-xservices/core/java/com/android/server/notification/NotificationManagerService.java20
1 files changed, 13 insertions, 7 deletions
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 3a7ac0bd659d..02265aca79de 100755
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -2408,7 +2408,7 @@ public class NotificationManagerService extends SystemService {
@VisibleForTesting
void clearNotifications() {
- synchronized (mNotificationList) {
+ synchronized (mNotificationLock) {
mEnqueuedNotifications.clear();
mNotificationList.clear();
mNotificationsByKey.clear();
@@ -2418,21 +2418,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);
+ }
}