diff options
author | 2019-05-20 18:05:40 -0400 | |
---|---|---|
committer | 2019-05-21 11:21:55 -0400 | |
commit | 7c72b5e69e8680298d801687e1cd6114e6d05ce1 (patch) | |
tree | 599b96aa64de41c0755549587e7bcbf10cac1843 | |
parent | 6429b70cf6e056326c77e0a58b59093804ebffe8 (diff) |
Synchronize block in onNotificationPosted
This is the only place in Assistant.java where mkeyToImpressions is not
synchronized
Fixes: 131199823
Test: make, atest ExtServicesUnitTests
Change-Id: I9abc8090d0423761dee9882c3f3459677738a848
-rw-r--r-- | packages/ExtServices/src/android/ext/services/notification/Assistant.java | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/packages/ExtServices/src/android/ext/services/notification/Assistant.java b/packages/ExtServices/src/android/ext/services/notification/Assistant.java index 73c789516754..69aa0f917a5d 100644 --- a/packages/ExtServices/src/android/ext/services/notification/Assistant.java +++ b/packages/ExtServices/src/android/ext/services/notification/Assistant.java @@ -301,13 +301,17 @@ public class Assistant extends NotificationAssistantService { sbn, ranking.getChannel(), mSmsHelper); String key = getKey( sbn.getPackageName(), sbn.getUserId(), ranking.getChannel().getId()); - ChannelImpressions ci = mkeyToImpressions.getOrDefault(key, - createChannelImpressionsWithThresholds()); - if (ranking.getImportance() > IMPORTANCE_MIN && ci.shouldTriggerBlock()) { + boolean shouldTriggerBlock; + synchronized (mkeyToImpressions) { + ChannelImpressions ci = mkeyToImpressions.getOrDefault(key, + createChannelImpressionsWithThresholds()); + mkeyToImpressions.put(key, ci); + shouldTriggerBlock = ci.shouldTriggerBlock(); + } + if (ranking.getImportance() > IMPORTANCE_MIN && shouldTriggerBlock) { adjustNotification(createNegativeAdjustment( sbn.getPackageName(), sbn.getKey(), sbn.getUserId())); } - mkeyToImpressions.put(key, ci); mLiveNotifications.put(sbn.getKey(), entry); mAgingHelper.onNotificationPosted(entry); } |