Bug 1271020: Add a null check before acting upon applicationContext r=sebastian
Pre-rewrite code had a similar check
MozReview-Commit-ID: FGqPCOabkqH
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoNetworkManager.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoNetworkManager.java
@@ -258,16 +258,20 @@ public class GeckoNetworkManager extends
throw new IllegalStateException("Unknown current state: " + currentState.name());
}
}
/**
* Update current network state and connection types.
*/
private void updateNetworkStateAndConnectionType() {
+ if (applicationContext == null) {
+ Log.i(LOGTAG, "applicationContext is null while trying to update network state");
+ return;
+ }
final ConnectivityManager connectivityManager = (ConnectivityManager) applicationContext.getSystemService(
Context.CONNECTIVITY_SERVICE);
// Type/status getters below all have a defined behaviour for when connectivityManager == null
if (connectivityManager == null) {
Log.e(LOGTAG, "ConnectivityManager does not exist.");
}
currentConnectionType = NetworkUtils.getConnectionType(connectivityManager);
currentNetworkStatus = NetworkUtils.getNetworkStatus(connectivityManager);