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); |