Loading src/android/net/util/NetworkStackUtils.java +43 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,49 @@ public class NetworkStackUtils { */ public static final String CAPTIVE_PORTAL_USE_HTTPS = "captive_portal_use_https"; /** * The URL used for HTTPS captive portal detection upon a new connection. * A 204 response code from the server is used for validation. */ public static final String CAPTIVE_PORTAL_HTTPS_URL = "captive_portal_https_url"; /** * The URL used for HTTP captive portal detection upon a new connection. * A 204 response code from the server is used for validation. */ public static final String CAPTIVE_PORTAL_HTTP_URL = "captive_portal_http_url"; /** * The URL used for fallback HTTP captive portal detection when previous HTTP * and HTTPS captive portal detection attemps did not return a conclusive answer. */ public static final String CAPTIVE_PORTAL_FALLBACK_URL = "captive_portal_fallback_url"; /** * What to do when connecting a network that presents a captive portal. * Must be one of the CAPTIVE_PORTAL_MODE_* constants above. * * The default for this setting is CAPTIVE_PORTAL_MODE_PROMPT. */ public static final String CAPTIVE_PORTAL_MODE = "captive_portal_mode"; /** * Don't attempt to detect captive portals. */ public static final int CAPTIVE_PORTAL_MODE_IGNORE = 0; /** * When detecting a captive portal, display a notification that * prompts the user to sign in. */ public static final int CAPTIVE_PORTAL_MODE_PROMPT = 1; /** * When detecting a captive portal, immediately disconnect from the * network and do not reconnect to that network in the future. */ public static final int CAPTIVE_PORTAL_MODE_AVOID = 2; static { System.loadLibrary("networkstackutilsjni"); } Loading src/com/android/server/connectivity/NetworkMonitor.java +13 −9 Original line number Diff line number Diff line Loading @@ -44,6 +44,12 @@ import static android.net.util.DataStallUtils.DEFAULT_DATA_STALL_MIN_EVALUATE_TI import static android.net.util.DataStallUtils.DEFAULT_DATA_STALL_VALID_DNS_TIME_THRESHOLD_MS; import static android.net.util.DataStallUtils.DEFAULT_DNS_LOG_SIZE; import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_FALLBACK_PROBE_SPECS; import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_FALLBACK_URL; import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_HTTPS_URL; import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_HTTP_URL; import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_MODE; import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_MODE_IGNORE; import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_MODE_PROMPT; import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_OTHER_FALLBACK_URLS; import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_USER_AGENT; import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_USE_HTTPS; Loading Loading @@ -1178,10 +1184,10 @@ public class NetworkMonitor extends StateMachine { } private boolean getIsCaptivePortalCheckEnabled() { String symbol = Settings.Global.CAPTIVE_PORTAL_MODE; int defaultValue = Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT; String symbol = CAPTIVE_PORTAL_MODE; int defaultValue = CAPTIVE_PORTAL_MODE_PROMPT; int mode = mDependencies.getSetting(mContext, symbol, defaultValue); return mode != Settings.Global.CAPTIVE_PORTAL_MODE_IGNORE; return mode != CAPTIVE_PORTAL_MODE_IGNORE; } private boolean getUseHttpsValidation() { Loading @@ -1191,8 +1197,7 @@ public class NetworkMonitor extends StateMachine { private String getCaptivePortalServerHttpsUrl() { return getSettingFromResource(mContext, R.string.config_captive_portal_https_url, R.string.default_captive_portal_https_url, Settings.Global.CAPTIVE_PORTAL_HTTPS_URL); R.string.default_captive_portal_https_url, CAPTIVE_PORTAL_HTTPS_URL); } private int getDnsProbeTimeout() { Loading Loading @@ -1231,8 +1236,7 @@ public class NetworkMonitor extends StateMachine { */ public String getCaptivePortalServerHttpUrl() { return getSettingFromResource(mContext, R.string.config_captive_portal_http_url, R.string.default_captive_portal_http_url, Settings.Global.CAPTIVE_PORTAL_HTTP_URL); R.string.default_captive_portal_http_url, CAPTIVE_PORTAL_HTTP_URL); } private int getConsecutiveDnsTimeoutThreshold() { Loading Loading @@ -1261,8 +1265,8 @@ public class NetworkMonitor extends StateMachine { private URL[] makeCaptivePortalFallbackUrls() { try { final String firstUrl = mDependencies.getSetting(mContext, Settings.Global.CAPTIVE_PORTAL_FALLBACK_URL, null); final String firstUrl = mDependencies.getSetting(mContext, CAPTIVE_PORTAL_FALLBACK_URL, null); final URL[] settingProviderUrls; if (!TextUtils.isEmpty(firstUrl)) { Loading Loading
src/android/net/util/NetworkStackUtils.java +43 −0 Original line number Diff line number Diff line Loading @@ -63,6 +63,49 @@ public class NetworkStackUtils { */ public static final String CAPTIVE_PORTAL_USE_HTTPS = "captive_portal_use_https"; /** * The URL used for HTTPS captive portal detection upon a new connection. * A 204 response code from the server is used for validation. */ public static final String CAPTIVE_PORTAL_HTTPS_URL = "captive_portal_https_url"; /** * The URL used for HTTP captive portal detection upon a new connection. * A 204 response code from the server is used for validation. */ public static final String CAPTIVE_PORTAL_HTTP_URL = "captive_portal_http_url"; /** * The URL used for fallback HTTP captive portal detection when previous HTTP * and HTTPS captive portal detection attemps did not return a conclusive answer. */ public static final String CAPTIVE_PORTAL_FALLBACK_URL = "captive_portal_fallback_url"; /** * What to do when connecting a network that presents a captive portal. * Must be one of the CAPTIVE_PORTAL_MODE_* constants above. * * The default for this setting is CAPTIVE_PORTAL_MODE_PROMPT. */ public static final String CAPTIVE_PORTAL_MODE = "captive_portal_mode"; /** * Don't attempt to detect captive portals. */ public static final int CAPTIVE_PORTAL_MODE_IGNORE = 0; /** * When detecting a captive portal, display a notification that * prompts the user to sign in. */ public static final int CAPTIVE_PORTAL_MODE_PROMPT = 1; /** * When detecting a captive portal, immediately disconnect from the * network and do not reconnect to that network in the future. */ public static final int CAPTIVE_PORTAL_MODE_AVOID = 2; static { System.loadLibrary("networkstackutilsjni"); } Loading
src/com/android/server/connectivity/NetworkMonitor.java +13 −9 Original line number Diff line number Diff line Loading @@ -44,6 +44,12 @@ import static android.net.util.DataStallUtils.DEFAULT_DATA_STALL_MIN_EVALUATE_TI import static android.net.util.DataStallUtils.DEFAULT_DATA_STALL_VALID_DNS_TIME_THRESHOLD_MS; import static android.net.util.DataStallUtils.DEFAULT_DNS_LOG_SIZE; import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_FALLBACK_PROBE_SPECS; import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_FALLBACK_URL; import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_HTTPS_URL; import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_HTTP_URL; import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_MODE; import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_MODE_IGNORE; import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_MODE_PROMPT; import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_OTHER_FALLBACK_URLS; import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_USER_AGENT; import static android.net.util.NetworkStackUtils.CAPTIVE_PORTAL_USE_HTTPS; Loading Loading @@ -1178,10 +1184,10 @@ public class NetworkMonitor extends StateMachine { } private boolean getIsCaptivePortalCheckEnabled() { String symbol = Settings.Global.CAPTIVE_PORTAL_MODE; int defaultValue = Settings.Global.CAPTIVE_PORTAL_MODE_PROMPT; String symbol = CAPTIVE_PORTAL_MODE; int defaultValue = CAPTIVE_PORTAL_MODE_PROMPT; int mode = mDependencies.getSetting(mContext, symbol, defaultValue); return mode != Settings.Global.CAPTIVE_PORTAL_MODE_IGNORE; return mode != CAPTIVE_PORTAL_MODE_IGNORE; } private boolean getUseHttpsValidation() { Loading @@ -1191,8 +1197,7 @@ public class NetworkMonitor extends StateMachine { private String getCaptivePortalServerHttpsUrl() { return getSettingFromResource(mContext, R.string.config_captive_portal_https_url, R.string.default_captive_portal_https_url, Settings.Global.CAPTIVE_PORTAL_HTTPS_URL); R.string.default_captive_portal_https_url, CAPTIVE_PORTAL_HTTPS_URL); } private int getDnsProbeTimeout() { Loading Loading @@ -1231,8 +1236,7 @@ public class NetworkMonitor extends StateMachine { */ public String getCaptivePortalServerHttpUrl() { return getSettingFromResource(mContext, R.string.config_captive_portal_http_url, R.string.default_captive_portal_http_url, Settings.Global.CAPTIVE_PORTAL_HTTP_URL); R.string.default_captive_portal_http_url, CAPTIVE_PORTAL_HTTP_URL); } private int getConsecutiveDnsTimeoutThreshold() { Loading Loading @@ -1261,8 +1265,8 @@ public class NetworkMonitor extends StateMachine { private URL[] makeCaptivePortalFallbackUrls() { try { final String firstUrl = mDependencies.getSetting(mContext, Settings.Global.CAPTIVE_PORTAL_FALLBACK_URL, null); final String firstUrl = mDependencies.getSetting(mContext, CAPTIVE_PORTAL_FALLBACK_URL, null); final URL[] settingProviderUrls; if (!TextUtils.isEmpty(firstUrl)) { Loading