| Index: webrtc/api/java/android/org/webrtc/NetworkMonitorAutoDetect.java
|
| diff --git a/webrtc/api/java/android/org/webrtc/NetworkMonitorAutoDetect.java b/webrtc/api/java/android/org/webrtc/NetworkMonitorAutoDetect.java
|
| index 9fb2e7bd3b55c86b5f09a5dd4056788fc8ac50e9..3045280cc485b28f51153a810658328c61e1857f 100644
|
| --- a/webrtc/api/java/android/org/webrtc/NetworkMonitorAutoDetect.java
|
| +++ b/webrtc/api/java/android/org/webrtc/NetworkMonitorAutoDetect.java
|
| @@ -156,8 +156,7 @@ public class NetworkMonitorAutoDetect extends BroadcastReceiver {
|
|
|
| private void onNetworkChanged(Network network) {
|
| NetworkInformation networkInformation = connectivityManagerDelegate.networkToInfo(network);
|
| - if (networkInformation.type != ConnectionType.CONNECTION_UNKNOWN
|
| - && networkInformation.type != ConnectionType.CONNECTION_NONE) {
|
| + if (networkInformation != null) {
|
| observer.onNetworkConnect(networkInformation);
|
| }
|
| }
|
| @@ -234,8 +233,7 @@ public class NetworkMonitorAutoDetect extends BroadcastReceiver {
|
| ArrayList<NetworkInformation> netInfoList = new ArrayList<NetworkInformation>();
|
| for (Network network : getAllNetworks()) {
|
| NetworkInformation info = networkToInfo(network);
|
| - if (info.name != null && info.type != ConnectionType.CONNECTION_NONE
|
| - && info.type != ConnectionType.CONNECTION_UNKNOWN) {
|
| + if (info != null) {
|
| netInfoList.add(info);
|
| }
|
| }
|
| @@ -285,10 +283,27 @@ public class NetworkMonitorAutoDetect extends BroadcastReceiver {
|
| @SuppressLint("NewApi")
|
| private NetworkInformation networkToInfo(Network network) {
|
| LinkProperties linkProperties = connectivityManager.getLinkProperties(network);
|
| + int networkId = networkToNetId(network);
|
| + if (linkProperties.getInterfaceName() == null) {
|
| + Logging.w(TAG, "Null interface name for network id " + networkId);
|
| + return null;
|
| + }
|
| +
|
| + ConnectionType connectionType = getConnectionType(getNetworkState(network));
|
| + if (connectionType == ConnectionType.CONNECTION_UNKNOWN
|
| + || connectionType == ConnectionType.CONNECTION_NONE) {
|
| + // This may not be an error. The OS may signal a network event with connection type
|
| + // NONE when the network disconnects. But in some devices, the OS may incorrectly
|
| + // report an UNKNOWN connection type. In either case, it won't benefit to send down
|
| + // a network event with this connection type.
|
| + Logging.d(TAG, "Network with id " + networkId + " has connection type " + connectionType);
|
| + return null;
|
| + }
|
| +
|
| NetworkInformation networkInformation = new NetworkInformation(
|
| linkProperties.getInterfaceName(),
|
| - getConnectionType(getNetworkState(network)),
|
| - networkToNetId(network),
|
| + connectionType,
|
| + networkId,
|
| getIPAddresses(linkProperties));
|
| return networkInformation;
|
| }
|
|
|