summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-12-19 06:45:43 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-12-19 06:45:43 +0000
commitd27352438dccbf9a80b11d714db75fd3722468f3 (patch)
tree953188b5ce9157ab80c5496e7a4bc1ce89c4ca81
parentb761870bdf8dd88aaba9edbccf4b057607e62b38 (diff)
parent3e617ac8316905b131c2555812c1d142f180f516 (diff)
downloadbase-d27352438dccbf9a80b11d714db75fd3722468f3.tar.gz
Merge cherrypicks of ['googleplex-android-review.googlesource.com/25696986'] into tm-platform-release.
Change-Id: I2ba16cdb4693abb155624f986612a98827f3d618
-rw-r--r--services/core/java/com/android/server/notification/SnoozeHelper.java22
-rw-r--r--services/tests/uiservicestests/src/com/android/server/notification/SnoozeHelperTest.java5
2 files changed, 6 insertions, 21 deletions
diff --git a/services/core/java/com/android/server/notification/SnoozeHelper.java b/services/core/java/com/android/server/notification/SnoozeHelper.java
index 73d4b147f90a..0044912bbcf4 100644
--- a/services/core/java/com/android/server/notification/SnoozeHelper.java
+++ b/services/core/java/com/android/server/notification/SnoozeHelper.java
@@ -119,28 +119,15 @@ public final class SnoozeHelper {
protected boolean canSnooze(int numberToSnooze) {
synchronized (mLock) {
if ((mSnoozedNotifications.size() + numberToSnooze) > CONCURRENT_SNOOZE_LIMIT
- || (countPersistedNotificationsLocked() + numberToSnooze)
- > CONCURRENT_SNOOZE_LIMIT) {
+ || (mPersistedSnoozedNotifications.size()
+ + mPersistedSnoozedNotificationsWithContext.size() + numberToSnooze)
+ > CONCURRENT_SNOOZE_LIMIT) {
return false;
}
}
return true;
}
- private int countPersistedNotificationsLocked() {
- int numNotifications = 0;
- for (ArrayMap<String, String> persistedWithContext :
- mPersistedSnoozedNotificationsWithContext.values()) {
- numNotifications += persistedWithContext.size();
- }
- for (ArrayMap<String, Long> persistedWithDuration :
- mPersistedSnoozedNotifications.values()) {
- numNotifications += persistedWithDuration.size();
- }
- return numNotifications;
- }
-
-
@NonNull
protected Long getSnoozeTimeForUnpostedNotification(int userId, String pkg, String key) {
Long time = null;
@@ -359,6 +346,9 @@ public final class SnoozeHelper {
if (groupSummaryKey != null) {
NotificationRecord record = mSnoozedNotifications.remove(groupSummaryKey);
+ String trimmedKey = getTrimmedString(groupSummaryKey);
+ mPersistedSnoozedNotificationsWithContext.remove(trimmedKey);
+ mPersistedSnoozedNotifications.remove(trimmedKey);
final String trimmedKey = getTrimmedString(groupSummaryKey);
removeRecordLocked(pkg, trimmedKey, userId, mPersistedSnoozedNotifications);
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/SnoozeHelperTest.java b/services/tests/uiservicestests/src/com/android/server/notification/SnoozeHelperTest.java
index 12590ac0d66a..0c004b65e5e8 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/SnoozeHelperTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/SnoozeHelperTest.java
@@ -81,8 +81,6 @@ public class SnoozeHelperTest extends UiServiceTestCase {
private static final String XML_SNOOZED_NOTIFICATION_TIME = "time";
private static final String XML_SNOOZED_NOTIFICATION_CONTEXT_ID = "id";
private static final String XML_SNOOZED_NOTIFICATION_VERSION_LABEL = "version";
- private static final String XML_SNOOZED_NOTIFICATION_PKG = "pkg";
- private static final String XML_SNOOZED_NOTIFICATION_USER_ID = "user-id";
@Mock SnoozeHelper.Callback mCallback;
@Mock AlarmManager mAm;
@@ -344,9 +342,6 @@ public class SnoozeHelperTest extends UiServiceTestCase {
} else {
serializer.startTag(null, XML_SNOOZED_NOTIFICATION_CONTEXT);
}
- serializer.attribute(null, XML_SNOOZED_NOTIFICATION_PKG, "pkg");
- serializer.attributeInt(null, XML_SNOOZED_NOTIFICATION_USER_ID,
- UserHandle.USER_SYSTEM);
serializer.attributeInt(null, XML_SNOOZED_NOTIFICATION_VERSION_LABEL, 1);
serializer.attribute(null, XML_SNOOZED_NOTIFICATION_KEY, "key" + i);
if (timedNotification) {