Try to fix: https://github.com/apache/cordova-plugin-network-information/issues/64: working with the ConnectivityManager.NetworkCallback in case of Lollipop and above, but switching to unknown if type none in the onavailable callback.

This commit is contained in:
PVPoyer 2018-11-06 10:34:50 +01:00
parent acc02f2981
commit 60ab69fe58

View File

@ -175,12 +175,24 @@ public class NetworkManager extends CordovaPlugin {
@Override @Override
public void onAvailable(Network network) { public void onAvailable(Network network) {
LOG.d(LOG_TAG, "In the on available: ");
updateConnectionInfoIfWebViewNotNull(sockMan.getActiveNetworkInfo()); updateConnectionInfoIfWebViewNotNull(sockMan.getActiveNetworkInfo());
String connectionType = determineCurrentConnectionType();
if(TYPE_NONE.equals(connectionType)) {
LOG.d(LOG_TAG, "ConnectionType none but in the onAvailable");
LOG.d(LOG_TAG, "!!! Switching to unknown, onAvailable states there is a connectivity.");
sendUpdate(TYPE_UNKNOWN);
}
LOG.d(LOG_TAG, "End the on available: ");
} }
@Override @Override
public void onLost(Network network) { public void onLost(Network network) {
LOG.d(LOG_TAG, "In the on lost: ");
updateConnectionInfoIfWebViewNotNull(sockMan.getActiveNetworkInfo()); updateConnectionInfoIfWebViewNotNull(sockMan.getActiveNetworkInfo());
LOG.d(LOG_TAG, "End the on lost: ");
} }
}; };
sockMan.registerNetworkCallback(builder.build(), lollipopAndAboveNetworkCallback); sockMan.registerNetworkCallback(builder.build(), lollipopAndAboveNetworkCallback);