| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.upgrade; | 5 package org.chromium.chrome.browser.upgrade; |
| 6 | 6 |
| 7 import android.annotation.SuppressLint; | |
| 8 import android.content.BroadcastReceiver; | 7 import android.content.BroadcastReceiver; |
| 9 import android.content.Context; | 8 import android.content.Context; |
| 10 import android.content.Intent; | 9 import android.content.Intent; |
| 11 import android.os.Build; | 10 import android.os.Build; |
| 12 | 11 |
| 13 /** | 12 /** |
| 14 * Triggered when Chrome's package is replaced (e.g. when it is upgraded). | 13 * Triggered when Chrome's package is replaced (e.g. when it is upgraded). |
| 15 * | 14 * |
| 16 * Before changing this class, you must understand both the Receiver and Process
Lifecycles: | 15 * Before changing this class, you must understand both the Receiver and Process
Lifecycles: |
| 17 * http://developer.android.com/reference/android/content/BroadcastReceiver.html
#ReceiverLifecycle | 16 * http://developer.android.com/reference/android/content/BroadcastReceiver.html
#ReceiverLifecycle |
| 18 * | 17 * |
| 19 * - This process runs in the foreground as long as {@link #onReceive} is runnin
g. If there are no | 18 * - This process runs in the foreground as long as {@link #onReceive} is runnin
g. If there are no |
| 20 * other application components running, Android will aggressively kill it. | 19 * other application components running, Android will aggressively kill it. |
| 21 * | 20 * |
| 22 * - Because this runs in the foreground, don't add any code that could cause ja
nk or ANRs. | 21 * - Because this runs in the foreground, don't add any code that could cause ja
nk or ANRs. |
| 23 * | 22 * |
| 24 * - This class immediately cullable by Android as soon as {@link #onReceive} re
turns. To kick off | 23 * - This class immediately cullable by Android as soon as {@link #onReceive} re
turns. To kick off |
| 25 * longer tasks, you must start a Service. | 24 * longer tasks, you must start a Service. |
| 26 */ | 25 */ |
| 27 // TODO(crbug.com/635567): Fix this properly. | |
| 28 @SuppressLint("UnsafeProtectedBroadcastReceiver") | |
| 29 public final class PackageReplacedBroadcastReceiver extends BroadcastReceiver { | 26 public final class PackageReplacedBroadcastReceiver extends BroadcastReceiver { |
| 30 @Override | 27 @Override |
| 31 public void onReceive(Context context, Intent intent) { | 28 public void onReceive(Context context, Intent intent) { |
| 29 if (!Intent.ACTION_MY_PACKAGE_REPLACED.equals(intent.getAction())) retur
n; |
| 32 if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N) return; | 30 if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N) return; |
| 33 UpgradeIntentService.startMigrationIfNecessary(context); | 31 UpgradeIntentService.startMigrationIfNecessary(context); |
| 34 } | 32 } |
| 35 } | 33 } |
| OLD | NEW |