From e6f542d62037e9830c0ae5749a32874c44cf2334 Mon Sep 17 00:00:00 2001 From: Brent Erickson Date: Tue, 7 Nov 2017 14:49:32 -0800 Subject: [PATCH] When subscribing for network connectivity broadcasts, also query the value so we always have the most up-to-date value. Summary: We've seen cases (based on logs) where NetInfo is reporting no connectivity, but network requests still work. This will keep status up to date after app foreground <-> backgrounds, since we don't listen to broadcasts when backgrounded. This is rather difficult to test given we haven't nailed an internal repro (evidence is solely based on device/app logs). Testing has been done to ensure that there are no behavioural changes on devices that were previously working (no regressions). Closes https://github.com/facebook/react-native/pull/15558 Differential Revision: D6264708 Pulled By: hramos fbshipit-source-id: 1648cadb59949103d0a595614b38024ec9236719 --- .../java/com/facebook/react/modules/netinfo/NetInfoModule.java | 1 + 1 file changed, 1 insertion(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/netinfo/NetInfoModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/netinfo/NetInfoModule.java index 0cc918d9d..58c57387e 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/netinfo/NetInfoModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/netinfo/NetInfoModule.java @@ -124,6 +124,7 @@ public class NetInfoModule extends ReactContextBaseJavaModule filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); getReactApplicationContext().registerReceiver(mConnectivityBroadcastReceiver, filter); mConnectivityBroadcastReceiver.setRegistered(true); + updateAndSendConnectionType(); } private void unregisterReceiver() {