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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/offlinepages/DeviceConditions.java

Issue 2830843002: [Offline pages] Updates to background scheduling to use BTS (Closed)
Patch Set: Fixing the crash on NCN not being initialized Created 3 years, 7 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/offlinepages/DeviceConditions.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/DeviceConditions.java b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/DeviceConditions.java
index 1b617b469fa63acb8066050721ccdee155173886..b0956a9eb945a9281fbc318dec40e63bc5ba1b56 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/DeviceConditions.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/offlinepages/DeviceConditions.java
@@ -113,8 +113,12 @@ public class DeviceConditions {
}
private static int getConnectionType(Context context) {
- // Get the connection type from chromium's internal object.
- int connectionType = NetworkChangeNotifier.getInstance().getCurrentConnectionType();
+ int connectionType = ConnectionType.CONNECTION_NONE;
+
+ // If we are starting in the background, native portion might not be initialized.
+ if (NetworkChangeNotifier.isInitialized()) {
+ connectionType = NetworkChangeNotifier.getInstance().getCurrentConnectionType();
+ }
// Sometimes the NetworkConnectionNotifier lags the actual connection type, especially when
// the GCM NM wakes us from doze state. If we are really connected, report the connection

Powered by Google App Engine
This is Rietveld 408576698