| Index: net/android/java/src/org/chromium/net/NetworkChangeNotifier.java
|
| diff --git a/net/android/java/src/org/chromium/net/NetworkChangeNotifier.java b/net/android/java/src/org/chromium/net/NetworkChangeNotifier.java
|
| index 6549e0210f73d7a11cfc54d7fd1aa5d23ea47b45..924e3b8e4cf887c94d8d6d4bdf46f030fdc7df52 100644
|
| --- a/net/android/java/src/org/chromium/net/NetworkChangeNotifier.java
|
| +++ b/net/android/java/src/org/chromium/net/NetworkChangeNotifier.java
|
| @@ -38,9 +38,8 @@ public class NetworkChangeNotifier {
|
| private final ArrayList<Long> mNativeChangeNotifiers;
|
| private final ObserverList<ConnectionTypeObserver> mConnectionTypeObservers;
|
| private NetworkChangeNotifierAutoDetect mAutoDetector;
|
| + // Last value broadcast via ConnectionTypeChange signal.
|
| private int mCurrentConnectionType = ConnectionType.CONNECTION_UNKNOWN;
|
| - private double mCurrentMaxBandwidth = Double.POSITIVE_INFINITY;
|
| - private int mMaxBandwidthConnectionType = mCurrentConnectionType;
|
|
|
| @SuppressLint("StaticFieldLeak")
|
| private static NetworkChangeNotifier sInstance;
|
| @@ -82,14 +81,9 @@ public class NetworkChangeNotifier {
|
|
|
| @CalledByNative
|
| public int getCurrentConnectionSubtype() {
|
| - return mAutoDetector == null ? ConnectionSubtype.SUBTYPE_UNKNOWN
|
| - : NetworkChangeNotifierAutoDetect.convertToConnectionSubtype(
|
| - mAutoDetector.getCurrentNetworkState());
|
| - }
|
| -
|
| - @CalledByNative
|
| - public double getCurrentMaxBandwidthInMbps() {
|
| - return mCurrentMaxBandwidth;
|
| + return mAutoDetector == null
|
| + ? ConnectionSubtype.SUBTYPE_UNKNOWN
|
| + : mAutoDetector.getCurrentNetworkState().getConnectionSubtype();
|
| }
|
|
|
| /**
|
| @@ -115,13 +109,6 @@ public class NetworkChangeNotifier {
|
| return mAutoDetector == null ? new long[0] : mAutoDetector.getNetworksAndTypes();
|
| }
|
|
|
| - /**
|
| - * Calls a native map lookup of subtype to max bandwidth.
|
| - */
|
| - public static double getMaxBandwidthForConnectionSubtype(int subtype) {
|
| - return nativeGetMaxBandwidthForConnectionSubtype(subtype);
|
| - }
|
| -
|
| /**
|
| * Adds a native-side observer.
|
| */
|
| @@ -199,8 +186,8 @@ public class NetworkChangeNotifier {
|
| updateCurrentConnectionType(newConnectionType);
|
| }
|
| @Override
|
| - public void onMaxBandwidthChanged(double maxBandwidthMbps) {
|
| - updateCurrentMaxBandwidth(maxBandwidthMbps);
|
| + public void onConnectionSubtypeChanged(int newConnectionSubtype) {
|
| + notifyObserversOfConnectionSubtypeChange(newConnectionSubtype);
|
| }
|
| @Override
|
| public void onNetworkConnect(long netId, int connectionType) {
|
| @@ -222,9 +209,8 @@ public class NetworkChangeNotifier {
|
| policy);
|
| final NetworkChangeNotifierAutoDetect.NetworkState networkState =
|
| mAutoDetector.getCurrentNetworkState();
|
| - updateCurrentConnectionType(
|
| - NetworkChangeNotifierAutoDetect.convertToConnectionType(networkState));
|
| - updateCurrentMaxBandwidth(mAutoDetector.getCurrentMaxBandwidthInMbps(networkState));
|
| + updateCurrentConnectionType(networkState.getConnectionType());
|
| + notifyObserversOfConnectionSubtypeChange(networkState.getConnectionSubtype());
|
| }
|
| } else {
|
| destroyAutoDetector();
|
| @@ -232,7 +218,8 @@ public class NetworkChangeNotifier {
|
| }
|
|
|
| /**
|
| - * Updates the perceived network state when not auto-detecting changes to connectivity.
|
| + * For testing, updates the perceived network state when not auto-detecting changes to
|
| + * connectivity.
|
| *
|
| * @param networkAvailable True if the NetworkChangeNotifier should perceive a "connected"
|
| * state, false implies "disconnected".
|
| @@ -248,8 +235,9 @@ public class NetworkChangeNotifier {
|
| mCurrentConnectionType != ConnectionType.CONNECTION_NONE;
|
| if (connectionCurrentlyExists != forceOnline) {
|
| updateCurrentConnectionType(forceOnline ? ConnectionType.CONNECTION_UNKNOWN
|
| - : ConnectionType.CONNECTION_NONE);
|
| - updateCurrentMaxBandwidth(forceOnline ? Double.POSITIVE_INFINITY : 0.0);
|
| + : ConnectionType.CONNECTION_NONE);
|
| + notifyObserversOfConnectionSubtypeChange(forceOnline ? ConnectionSubtype.SUBTYPE_UNKNOWN
|
| + : ConnectionSubtype.SUBTYPE_NONE);
|
| }
|
| }
|
|
|
| @@ -288,11 +276,11 @@ public class NetworkChangeNotifier {
|
| getInstance().notifyObserversOfConnectionTypeChange(connectionType, netId);
|
| }
|
|
|
| - // For testing, pretend the max bandwidth has changed.
|
| + // For testing, pretend the connection subtype has changed.
|
| @CalledByNative
|
| - public static void fakeMaxBandwidthChanged(double maxBandwidthMbps) {
|
| + public static void fakeConnectionSubtypeChanged(int connectionSubtype) {
|
| setAutoDetectConnectivityState(false);
|
| - getInstance().notifyObserversOfMaxBandwidthChange(maxBandwidthMbps);
|
| + getInstance().notifyObserversOfConnectionSubtypeChange(connectionSubtype);
|
| }
|
|
|
| private void updateCurrentConnectionType(int newConnectionType) {
|
| @@ -300,16 +288,6 @@ public class NetworkChangeNotifier {
|
| notifyObserversOfConnectionTypeChange(newConnectionType);
|
| }
|
|
|
| - private void updateCurrentMaxBandwidth(double maxBandwidthMbps) {
|
| - if (maxBandwidthMbps == mCurrentMaxBandwidth
|
| - && mCurrentConnectionType == mMaxBandwidthConnectionType) {
|
| - return;
|
| - }
|
| - mCurrentMaxBandwidth = maxBandwidthMbps;
|
| - mMaxBandwidthConnectionType = mCurrentConnectionType;
|
| - notifyObserversOfMaxBandwidthChange(maxBandwidthMbps);
|
| - }
|
| -
|
| /**
|
| * Alerts all observers of a connection change.
|
| */
|
| @@ -330,9 +308,9 @@ public class NetworkChangeNotifier {
|
| /**
|
| * Alerts all observers of a bandwidth change.
|
| */
|
| - void notifyObserversOfMaxBandwidthChange(double maxBandwidthMbps) {
|
| + void notifyObserversOfConnectionSubtypeChange(int connectionSubtype) {
|
| for (Long nativeChangeNotifier : mNativeChangeNotifiers) {
|
| - nativeNotifyMaxBandwidthChanged(nativeChangeNotifier, maxBandwidthMbps);
|
| + nativeNotifyMaxBandwidthChanged(nativeChangeNotifier, connectionSubtype);
|
| }
|
| }
|
|
|
| @@ -402,7 +380,7 @@ public class NetworkChangeNotifier {
|
| long nativePtr, int newConnectionType, long defaultNetId);
|
|
|
| @NativeClassQualifiedName("NetworkChangeNotifierDelegateAndroid")
|
| - private native void nativeNotifyMaxBandwidthChanged(long nativePtr, double maxBandwidthMbps);
|
| + private native void nativeNotifyMaxBandwidthChanged(long nativePtr, int subType);
|
|
|
| @NativeClassQualifiedName("NetworkChangeNotifierDelegateAndroid")
|
| private native void nativeNotifyOfNetworkConnect(
|
| @@ -417,8 +395,6 @@ public class NetworkChangeNotifier {
|
| @NativeClassQualifiedName("NetworkChangeNotifierDelegateAndroid")
|
| private native void nativeNotifyPurgeActiveNetworkList(long nativePtr, long[] activeNetIds);
|
|
|
| - private static native double nativeGetMaxBandwidthForConnectionSubtype(int subtype);
|
| -
|
| // For testing only.
|
| public static NetworkChangeNotifierAutoDetect getAutoDetectorForTest() {
|
| return getInstance().mAutoDetector;
|
|
|