| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.chrome.browser.upgrade; |
| 6 |
| 7 import android.content.BroadcastReceiver; |
| 8 import android.content.Context; |
| 9 import android.content.Intent; |
| 10 |
| 11 import org.chromium.chrome.browser.notifications.ChannelsUpdater; |
| 12 |
| 13 /** |
| 14 * A broadcast receiver for scheduling tasks that should run on device startup. |
| 15 * See {@link Intent#ACTION_BOOT_COMPLETED}. |
| 16 * |
| 17 * This can also be used for tasks that should happen on OS upgrade (since there
is no "OS_UPGRADED" |
| 18 * broadcast, the recommendation is to listen for this one and check whether the
OS upgraded). |
| 19 * |
| 20 * Currently it is just used to initialize notification channels on upgrade to O
. |
| 21 */ |
| 22 public final class BootCompletedBroadcastReceiver extends BroadcastReceiver { |
| 23 @Override |
| 24 public void onReceive(final Context context, Intent intent) { |
| 25 if (!Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) return; |
| 26 updateChannelsIfNecessary(); |
| 27 } |
| 28 |
| 29 private void updateChannelsIfNecessary() { |
| 30 if (!ChannelsUpdater.getInstance().shouldUpdateChannels()) return; |
| 31 ChannelsUpdater.getInstance().updateChannelsInBackground(goAsync()); |
| 32 } |
| 33 } |
| OLD | NEW |