summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorYuri Lin <yurilin@google.com>2021-03-23 17:24:55 -0400
committerYuri Lin <yurilin@google.com>2021-04-05 10:49:07 -0400
commit048571dd5714340ab37ca5304136dcd083d23c53 (patch)
tree30d76fb4015263232f1db6b89a2020e04a3c740f /core/java/android
parent8a49089585d5f93739e67842a9ab977b869dbf90 (diff)
Remove notification channels from history when they're deleted.
To make this possible, this change adds functionality for notification channel removal to NotificationHistory, NotificationHistoryDatabase, and NotificationHistoryManager and corresponding tests. This change does not remove the notifications from deleted channels from the "recently dismissed" list (stored in mArchive); will follow up with that later. Test: atest NotificationHistoryTest, NotificationHistoryDatabaseTest, NotificationManagerServiceTest; manual via creating channels, deleting them and verifying Bug: 169349809 Change-Id: I7b1c137e516d14703665750f06554ac7ca44c90e
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/app/NotificationHistory.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/core/java/android/app/NotificationHistory.java b/core/java/android/app/NotificationHistory.java
index 0c8188b9a51e..eb9ec869af12 100644
--- a/core/java/android/app/NotificationHistory.java
+++ b/core/java/android/app/NotificationHistory.java
@@ -404,6 +404,26 @@ public final class NotificationHistory implements Parcelable {
}
/**
+ * Removes all notifications from a channel and regenerates the string pool
+ */
+ public boolean removeChannelFromWrite(String packageName, String channelId) {
+ boolean removed = false;
+ for (int i = mNotificationsToWrite.size() - 1; i >= 0; i--) {
+ HistoricalNotification hn = mNotificationsToWrite.get(i);
+ if (packageName.equals(hn.getPackage())
+ && Objects.equals(channelId, hn.getChannelId())) {
+ removed = true;
+ mNotificationsToWrite.remove(i);
+ }
+ }
+ if (removed) {
+ poolStringsFromNotifications();
+ }
+
+ return removed;
+ }
+
+ /**
* Gets pooled strings in order to write them to disk
*/
public @NonNull String[] getPooledStringsToWrite() {