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

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

Issue 1774343002: Filter out the network in networkmonitor if the linkProperties is null. (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 3045280cc485b28f51153a810658328c61e1857f..e0af09ba86e1b9b87091097e78ebb1ebd52fc481 100644
--- a/webrtc/api/java/android/org/webrtc/NetworkMonitorAutoDetect.java
+++ b/webrtc/api/java/android/org/webrtc/NetworkMonitorAutoDetect.java
@@ -143,15 +143,14 @@ public class NetworkMonitorAutoDetect extends BroadcastReceiver {
public void onLosing(Network network, int maxMsToLive) {
// Tell the network is going to lose in MaxMsToLive milliseconds.
// We may use this signal later.
- Logging.d(TAG, "Network with handle " + networkToNetId(network) +
- " is about to lose in " + maxMsToLive + "ms");
+ Logging.d(TAG,
+ "Network " + network.toString() + " is about to lose in " + maxMsToLive + "ms");
}
@Override
public void onLost(Network network) {
- int handle = networkToNetId(network);
- Logging.d(TAG, "Network with handle " + handle + " is disconnected");
- observer.onNetworkDisconnect(handle);
+ Logging.d(TAG, "Network " + network.toString() + " is disconnected");
+ observer.onNetworkDisconnect(networkToNetId(network));
}
private void onNetworkChanged(Network network) {
@@ -283,9 +282,13 @@ public class NetworkMonitorAutoDetect extends BroadcastReceiver {
@SuppressLint("NewApi")
private NetworkInformation networkToInfo(Network network) {
LinkProperties linkProperties = connectivityManager.getLinkProperties(network);
- int networkId = networkToNetId(network);
+ // getLinkProperties will return null if the network is unknown.
+ if (linkProperties == null) {
+ Logging.w(TAG, "Detected unknown network: " + network.toString());
+ return null;
+ }
if (linkProperties.getInterfaceName() == null) {
- Logging.w(TAG, "Null interface name for network id " + networkId);
+ Logging.w(TAG, "Null interface name for network " + network.toString());
return null;
}
@@ -296,14 +299,14 @@ public class NetworkMonitorAutoDetect extends BroadcastReceiver {
// 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);
+ Logging.d(TAG, "Network " + network.toString() + " has connection type " + connectionType);
return null;
}
NetworkInformation networkInformation = new NetworkInformation(
linkProperties.getInterfaceName(),
connectionType,
- networkId,
+ networkToNetId(network),
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