| 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());
|
| + }
|
| +}
|
|
|