Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NetworkInfo is null on Huawei devices #66

Merged
merged 1 commit into from Apr 17, 2019
Merged

NetworkInfo is null on Huawei devices #66

merged 1 commit into from Apr 17, 2019

Conversation

AndrewJack
Copy link
Contributor

Overview

I've seen the following crash, which seems to be limited to Huawei devices:

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.net.NetworkInfo.getSubtype()' on a null object reference
       at com.reactnativecommunity.netinfo.ConnectivityReceiver.register(ConnectivityReceiver.java:94)
       at com.reactnativecommunity.netinfo.ConnectivityReceiver.getEffectiveConnectionType(ConnectivityReceiver.java:94)
       at com.reactnativecommunity.netinfo.NetworkCallbackConnectivityReceiver.updateAndSend(NetworkCallbackConnectivityReceiver.java:66)
       at com.reactnativecommunity.netinfo.NetworkCallbackConnectivityReceiver.access$102(NetworkCallbackConnectivityReceiver.java:24)
       at com.reactnativecommunity.netinfo.NetworkCallbackConnectivityReceiver$ConnectivityNetworkCallback.onCapabilitiesChanged(NetworkCallbackConnectivityReceiver.java:111)
       at android.net.ConnectivityManager$CallbackHandler.handleMessage(ConnectivityManager.java:3089)
       at android.os.Handler.dispatchMessage(Handler.java:108)
       at android.os.Looper.loop(Looper.java:166)
       at android.os.HandlerThread.run(HandlerThread.java:65)

Test Plan

I do not have a Huawei device, but the fix and stack trace are pretty simple.

@AndrewJack
Copy link
Contributor Author

@matt-oakes
Copy link
Collaborator

Good catch. Thanks!

@matt-oakes matt-oakes merged commit 3137954 into react-native-netinfo:master Apr 17, 2019
react-native-community-bot pushed a commit that referenced this pull request Apr 17, 2019
## [2.0.4](v2.0.3...v2.0.4) (2019-04-17)

### Bug Fixes

* **android:** Check if NetworkInfo is null to avoid crashes ([#66](#66)) ([3137954](3137954))
@react-native-community-bot
Copy link
Collaborator

🎉 This PR is included in version 2.0.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

@AndrewJack AndrewJack deleted the fix/huawei_network_info_null branch April 17, 2019 17:04
andrejborstnik pushed a commit to ExodusMovement/react-native-netinfo that referenced this pull request Jul 8, 2020
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants