Chromium Code Reviews| Index: net/android/java/src/org/chromium/net/AndroidNetworkLibrary.java |
| diff --git a/net/android/java/src/org/chromium/net/AndroidNetworkLibrary.java b/net/android/java/src/org/chromium/net/AndroidNetworkLibrary.java |
| index 9b45d982a6bc200d4a6f27720d664fe145f1d6a4..86fcc00ab9b4b839fbf7277020a4cb72612b976d 100644 |
| --- a/net/android/java/src/org/chromium/net/AndroidNetworkLibrary.java |
| +++ b/net/android/java/src/org/chromium/net/AndroidNetworkLibrary.java |
| @@ -4,14 +4,18 @@ |
| package org.chromium.net; |
| +import android.annotation.TargetApi; |
| import android.content.ActivityNotFoundException; |
| import android.content.Context; |
| import android.content.Intent; |
| import android.content.IntentFilter; |
| import android.net.ConnectivityManager; |
| +import android.net.Network; |
| +import android.net.NetworkCapabilities; |
| import android.net.NetworkInfo; |
| import android.net.wifi.WifiInfo; |
| import android.net.wifi.WifiManager; |
| +import android.os.Build; |
| import android.security.KeyChain; |
| import android.telephony.TelephonyManager; |
| import android.util.Log; |
| @@ -193,6 +197,31 @@ class AndroidNetworkLibrary { |
| } |
| /** |
| + * Returns true if the captive portal probe was blocked for the current network. The method |
|
pauljensen
2016/11/24 00:11:19
captive->system's captive
current->current default
tbansal1
2016/11/24 00:43:09
Done.
|
| + * would return false if the captive portal probe was not blocked on the current network, the |
|
pauljensen
2016/11/24 00:11:19
would->will
pauljensen
2016/11/24 00:11:19
remove "on the current network"
tbansal1
2016/11/24 00:43:09
Done.
tbansal1
2016/11/24 00:43:09
Done.
|
| + * login process to the captive portal has been successfully completed, or if the captive portal |
| + * status can't be determined. Requires ACCESS_NETWORK_STATE permission. Only available on |
| + * Android Marshmallow and later versions. Returns false on earlier versions. |
| + */ |
| + @TargetApi(Build.VERSION_CODES.M) |
| + @CalledByNative |
| + private static boolean getIsCaptivePortal(Context context) { |
| + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return false; |
| + ConnectivityManager connectivityManager = |
| + (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); |
| + if (connectivityManager == null) return false; |
| + |
| + Network network = connectivityManager.getActiveNetwork(); |
| + if (network == null) return false; |
| + |
| + NetworkCapabilities capabilities = connectivityManager.getNetworkCapabilities(network); |
| + // NetworkCapabilities.NET_CAPABILITY_CAPTIVE_PORTAL is only available on Marshmallow and |
| + // later versions. |
|
pauljensen
2016/11/24 00:11:19
Can we move this comment up to right before line 2
tbansal1
2016/11/24 00:43:09
Done.
|
| + return capabilities != null |
| + && capabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_CAPTIVE_PORTAL); |
| + } |
| + |
| + /** |
| * Gets the SSID of the currently associated WiFi access point if there is one. Otherwise, |
| * returns empty string. |
| */ |