Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/notifications/ChannelsInitializer.java

Issue 2807213002: [Android O] Initialize channels on first launch/upgrade (Closed)
Patch Set: Initialize channels on first launch and upgrade Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/notifications/ChannelsInitializer.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/notifications/ChannelsInitializer.java b/chrome/android/java/src/org/chromium/chrome/browser/notifications/ChannelsInitializer.java
index dfafe8deb3a348edc4639ccad8eaadea9475dec6..1f8ce6404c3e654cfde39863770414b63608a371 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/notifications/ChannelsInitializer.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/notifications/ChannelsInitializer.java
@@ -30,6 +30,11 @@ public class ChannelsInitializer {
private @interface ChannelGroupId {}
static final String CHANNEL_GROUP_ID_GENERAL = "general";
+ /**
+ * The set of predefined channels to be initialized on startup.
+ * {@link ChannelsUpdater#CHANNELS_VERSION} must be incremented every time an entry is modified,
+ * removed or added to this map.
+ */
private static final Map<String, Channel> CHANNELS;
static {
Map<String, Channel> map = new HashMap<>();
@@ -59,6 +64,18 @@ public class ChannelsInitializer {
mNotificationManager = notificationManagerProxy;
}
+ public void initializeStartupChannels() {
+ for (@ChannelId String channelId : CHANNELS.keySet()) {
+ ensureInitialized(channelId);
+ }
+ }
+
+ void deleteAllChannels() {
+ for (String channelId : mNotificationManager.getNotificationChannelIds()) {
+ mNotificationManager.deleteNotificationChannel(channelId);
+ }
+ }
+
/**
* Ensures the given channel has been created on the notification manager so a notification
* can be safely posted to it. This should only be used for channels that are predefined in
@@ -83,7 +100,7 @@ public class ChannelsInitializer {
*/
public static class Channel {
@ChannelId
- final String mId;
+ public final String mId;
final int mNameResId;
final int mImportance;
@ChannelGroupId

Powered by Google App Engine
This is Rietveld 408576698