Skip to content

Commit

Permalink
fix(android): Check if NetworkInfo is null to avoid crashes (#66)
Browse files Browse the repository at this point in the history
Previously the `networkInfo` could be `null` and it would cause a crash when we try to decide the network type. This adds a `null` check to avoid this.
  • Loading branch information
AndrewJack authored and matt-oakes committed Apr 17, 2019
1 parent 4e773ba commit 3137954
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ public void setNoNetworkPermission() {
}

String getEffectiveConnectionType(NetworkInfo networkInfo) {
if (networkInfo == null) {
return EFFECTIVE_CONNECTION_TYPE_UNKNOWN;
}

switch (networkInfo.getSubtype()) {
case TelephonyManager.NETWORK_TYPE_1xRTT:
case TelephonyManager.NETWORK_TYPE_CDMA:
Expand Down

0 comments on commit 3137954

Please sign in to comment.