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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/upgrade/BootCompletedBroadcastReceiver.java

Issue 2840843003: [Android O] Initialize notification channels on OS upgrade (Closed)
Patch Set: 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/upgrade/BootCompletedBroadcastReceiver.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/upgrade/BootCompletedBroadcastReceiver.java b/chrome/android/java/src/org/chromium/chrome/browser/upgrade/BootCompletedBroadcastReceiver.java
new file mode 100644
index 0000000000000000000000000000000000000000..653d2207fc87dba6d59868958b77eee31e43439a
--- /dev/null
+++ b/chrome/android/java/src/org/chromium/chrome/browser/upgrade/BootCompletedBroadcastReceiver.java
@@ -0,0 +1,33 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.upgrade;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+
+import org.chromium.chrome.browser.notifications.ChannelsUpdater;
+
+/**
+ * A broadcast receiver for scheduling tasks that should run on device startup.
+ * See {@link Intent#ACTION_BOOT_COMPLETED}.
+ *
+ * This can also be used for tasks that should happen on OS upgrade (since there is no "OS_UPGRADED"
+ * broadcast, the recommendation is to listen for this one and check whether the OS upgraded).
+ *
+ * Currently it is just used to initialize notification channels on upgrade to O.
+ */
+public final class BootCompletedBroadcastReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(final Context context, Intent intent) {
+ if (!Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) return;
+ updateChannelsIfNecessary();
+ }
+
+ private void updateChannelsIfNecessary() {
+ if (!ChannelsUpdater.getInstance().shouldUpdateChannels()) return;
+ ChannelsUpdater.getInstance().updateChannelsInBackground(goAsync());
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698