| 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..1656e2c38565ed038441a860e007ae0f9eb28304 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 system's captive portal probe was blocked for the current default data
|
| + * network. The method will return false if the captive portal probe was not blocked, the 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) {
|
| + // NetworkCapabilities.NET_CAPABILITY_CAPTIVE_PORTAL is only available on Marshmallow and
|
| + // later versions.
|
| + 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);
|
| + 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.
|
| */
|
|
|