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

Unified Diff: talk/app/webrtc/java/android/org/webrtc/NetworkMonitor.java

Issue 1535943004: Multi-networking with Android L. Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years 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 | talk/app/webrtc/java/android/org/webrtc/NetworkMonitorAutoDetect.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: talk/app/webrtc/java/android/org/webrtc/NetworkMonitor.java
diff --git a/talk/app/webrtc/java/android/org/webrtc/NetworkMonitor.java b/talk/app/webrtc/java/android/org/webrtc/NetworkMonitor.java
index 581a223c19026c976c7e784e6b8bac019d556196..f7297a35ba151eb7e85855be4477ff3dee8d1c51 100644
--- a/talk/app/webrtc/java/android/org/webrtc/NetworkMonitor.java
+++ b/talk/app/webrtc/java/android/org/webrtc/NetworkMonitor.java
@@ -29,6 +29,7 @@ package org.webrtc;
import static org.webrtc.NetworkMonitorAutoDetect.ConnectionType;
import static org.webrtc.NetworkMonitorAutoDetect.INVALID_NET_ID;
+import static org.webrtc.NetworkMonitorAutoDetect.NetworkInformation;
import android.content.Context;
import android.util.Log;
@@ -43,6 +44,7 @@ import java.util.ArrayList;
* WARNING: This class is not thread-safe.
*/
public class NetworkMonitor {
+
/**
* Alerted when the connection type of the network changes.
* The alert is fired on the UI thread.
@@ -129,6 +131,14 @@ public class NetworkMonitor {
nativeNetworkObservers.remove(nativeObserver);
}
+ // Called by the native code.
+ private NetworkInformation[] getAllNetworkInfos() {
+ if (autoDetector == null) {
+ return new NetworkInformation[0];
+ }
+ return autoDetector.getAllNetworkInfos();
+ }
+
private ConnectionType getCurrentConnectionType() {
return currentConnectionType;
}
@@ -156,11 +166,14 @@ public class NetworkMonitor {
public void onConnectionTypeChanged(ConnectionType newConnectionType) {
updateCurrentConnectionType(newConnectionType);
}
+ public void onNetworkAvailable(NetworkInformation networkInfo) {
+ updateNetworkInformation(networkInfo);
+ }
},
applicationContext);
final NetworkMonitorAutoDetect.NetworkState networkState =
autoDetector.getCurrentNetworkState();
- updateCurrentConnectionType(autoDetector.getCurrentConnectionType(networkState));
+ updateCurrentConnectionType(autoDetector.getConnectionType(networkState));
}
}
@@ -181,6 +194,12 @@ public class NetworkMonitor {
}
}
+ private void updateNetworkInformation(NetworkInformation networkInfo) {
+ for (long nativeObserver : nativeNetworkObservers) {
+ nativeUpdateNetworkInformation(nativeObserver, networkInfo);
+ }
+ }
+
/**
* Adds an observer for any connection type changes.
*/
@@ -216,6 +235,8 @@ public class NetworkMonitor {
private native void nativeNotifyConnectionTypeChanged(long nativePtr);
+ private native void nativeUpdateNetworkInformation(long nativePtr, NetworkInformation networkInfo);
+
// For testing only.
static void resetInstanceForTests(Context context) {
instance = new NetworkMonitor(context);
« no previous file with comments | « no previous file | talk/app/webrtc/java/android/org/webrtc/NetworkMonitorAutoDetect.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698