Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e64317d0 authored by Chiachang Wang's avatar Chiachang Wang Committed by Gerrit Code Review
Browse files

Merge "Remove Settings constants for NetworkStack"

parents 3f2e0d74 969eb755
Loading
Loading
Loading
Loading
+43 −0
Original line number Diff line number Diff line
@@ -62,6 +62,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");
    }
+13 −9
Original line number Diff line number Diff line
@@ -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;
@@ -1175,10 +1181,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() {
@@ -1188,8 +1194,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() {
@@ -1228,8 +1233,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() {
@@ -1258,8 +1262,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)) {