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

Commit 11347f87 authored by Chiachang Wang's avatar Chiachang Wang
Browse files

Remove Settings constants for NetworkStack

The definitions reference of these constants are moved from
Settings to DeviceConfig. These definitions are @hide and the
usage in the Settings are removed. Thus, remove the definitions
from API level.

Bug: 123167629
Test: make system-api-stubs-docs-update-current-api \
      test-api-stubs-docs-update-current-api
Test: atest NetworkStackTests
Change-Id: I28c4bf2c0b72e154cea91d11007a9497c7f21570
parent 53f25dd9
Loading
Loading
Loading
Loading
+43 −0
Original line number Diff line number Diff line
@@ -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");
    }
+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;
@@ -1168,10 +1174,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() {
@@ -1181,8 +1187,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);
    }

    /**
@@ -1194,8 +1199,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() {
@@ -1224,8 +1228,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)) {