Skip to content

Commit

Permalink
fix(android): Check if NetworkInfo is null to avoid crashes (react-na…
Browse files Browse the repository at this point in the history
…tive-netinfo#66)

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 andrejborstnik committed Jul 8, 2020
1 parent 9cfe57b commit a24b3a7
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 a24b3a7

Please sign in to comment.