From 7bbdcac990a8bcf939b8012c642cbe2249e64758 Mon Sep 17 00:00:00 2001 From: Marvin W Date: Tue, 28 Aug 2018 14:18:19 +0200 Subject: [PATCH] Handle NetworkInfo being null --- .../src/main/java/org/microg/gms/gcm/GcmPrefs.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/play-services-core/src/main/java/org/microg/gms/gcm/GcmPrefs.java b/play-services-core/src/main/java/org/microg/gms/gcm/GcmPrefs.java index 5a3084f0..d0cc000f 100644 --- a/play-services-core/src/main/java/org/microg/gms/gcm/GcmPrefs.java +++ b/play-services-core/src/main/java/org/microg/gms/gcm/GcmPrefs.java @@ -100,6 +100,7 @@ public class GcmPrefs implements SharedPreferences.OnSharedPreferenceChangeListe } public String getNetworkPrefForInfo(NetworkInfo info) { + if (info == null) return PREF_NETWORK_OTHER; if (info.isRoaming()) return PREF_NETWORK_ROAMING; switch (info.getType()) { case ConnectivityManager.TYPE_MOBILE: @@ -190,7 +191,7 @@ public class GcmPrefs implements SharedPreferences.OnSharedPreferenceChangeListe } public boolean isEnabledFor(NetworkInfo info) { - return isEnabled() && getHeartbeatMsFor(info) >= 0; + return isEnabled() && info != null && getHeartbeatMsFor(info) >= 0; } public boolean isGcmLogEnabled() {