Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Unified Diff: webrtc/api/java/android/org/webrtc/NetworkMonitorAutoDetect.java

Issue 1771383002: Filter out network-change event with a null interface name. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698