paulhu | 845456e | 2021-03-17 17:19:09 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2021 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.net; |
| 18 | |
paulhu | c9925e0 | 2021-03-17 20:30:33 +0800 | [diff] [blame^] | 19 | import android.annotation.IntDef; |
| 20 | |
| 21 | import java.lang.annotation.Retention; |
| 22 | import java.lang.annotation.RetentionPolicy; |
| 23 | |
paulhu | 845456e | 2021-03-17 17:19:09 +0800 | [diff] [blame] | 24 | /** |
| 25 | * A manager class for connectivity module settings. |
| 26 | * |
| 27 | * @hide |
| 28 | */ |
| 29 | public class ConnectivitySettingsManager { |
| 30 | |
| 31 | private ConnectivitySettingsManager() {} |
| 32 | |
paulhu | c9925e0 | 2021-03-17 20:30:33 +0800 | [diff] [blame^] | 33 | /** Data activity timeout settings */ |
| 34 | |
| 35 | /** |
| 36 | * Inactivity timeout to track mobile data activity. |
| 37 | * |
| 38 | * If set to a positive integer, it indicates the inactivity timeout value in seconds to |
| 39 | * infer the data activity of mobile network. After a period of no activity on mobile |
| 40 | * networks with length specified by the timeout, an {@code ACTION_DATA_ACTIVITY_CHANGE} |
| 41 | * intent is fired to indicate a transition of network status from "active" to "idle". Any |
| 42 | * subsequent activity on mobile networks triggers the firing of {@code |
| 43 | * ACTION_DATA_ACTIVITY_CHANGE} intent indicating transition from "idle" to "active". |
| 44 | * |
| 45 | * Network activity refers to transmitting or receiving data on the network interfaces. |
| 46 | * |
| 47 | * Tracking is disabled if set to zero or negative value. |
| 48 | */ |
| 49 | public static final String DATA_ACTIVITY_TIMEOUT_MOBILE = "data_activity_timeout_mobile"; |
| 50 | |
| 51 | /** |
| 52 | * Timeout to tracking Wifi data activity. Same as {@code DATA_ACTIVITY_TIMEOUT_MOBILE} |
| 53 | * but for Wifi network. |
| 54 | */ |
| 55 | public static final String DATA_ACTIVITY_TIMEOUT_WIFI = "data_activity_timeout_wifi"; |
| 56 | |
| 57 | /** Dns resolver settings */ |
| 58 | |
| 59 | /** |
| 60 | * Sample validity in seconds to configure for the system DNS resolver. |
| 61 | */ |
| 62 | public static final String DNS_RESOLVER_SAMPLE_VALIDITY_SECONDS = |
| 63 | "dns_resolver_sample_validity_seconds"; |
| 64 | |
| 65 | /** |
| 66 | * Success threshold in percent for use with the system DNS resolver. |
| 67 | */ |
| 68 | public static final String DNS_RESOLVER_SUCCESS_THRESHOLD_PERCENT = |
| 69 | "dns_resolver_success_threshold_percent"; |
| 70 | |
| 71 | /** |
| 72 | * Minimum number of samples needed for statistics to be considered meaningful in the |
| 73 | * system DNS resolver. |
| 74 | */ |
| 75 | public static final String DNS_RESOLVER_MIN_SAMPLES = "dns_resolver_min_samples"; |
| 76 | |
| 77 | /** |
| 78 | * Maximum number taken into account for statistics purposes in the system DNS resolver. |
| 79 | */ |
| 80 | public static final String DNS_RESOLVER_MAX_SAMPLES = "dns_resolver_max_samples"; |
| 81 | |
| 82 | /** Network switch notification settings */ |
| 83 | |
| 84 | /** |
| 85 | * The maximum number of notifications shown in 24 hours when switching networks. |
| 86 | */ |
| 87 | public static final String NETWORK_SWITCH_NOTIFICATION_DAILY_LIMIT = |
| 88 | "network_switch_notification_daily_limit"; |
| 89 | |
| 90 | /** |
| 91 | * The minimum time in milliseconds between notifications when switching networks. |
| 92 | */ |
| 93 | public static final String NETWORK_SWITCH_NOTIFICATION_RATE_LIMIT_MILLIS = |
| 94 | "network_switch_notification_rate_limit_millis"; |
| 95 | |
| 96 | /** Captive portal settings */ |
| 97 | |
| 98 | /** |
| 99 | * The URL used for HTTP captive portal detection upon a new connection. |
| 100 | * A 204 response code from the server is used for validation. |
| 101 | */ |
| 102 | public static final String CAPTIVE_PORTAL_HTTP_URL = "captive_portal_http_url"; |
| 103 | |
| 104 | /** |
| 105 | * What to do when connecting a network that presents a captive portal. |
| 106 | * Must be one of the CAPTIVE_PORTAL_MODE_* constants above. |
| 107 | * |
| 108 | * The default for this setting is CAPTIVE_PORTAL_MODE_PROMPT. |
| 109 | */ |
| 110 | public static final String CAPTIVE_PORTAL_MODE = "captive_portal_mode"; |
| 111 | |
| 112 | /** |
| 113 | * Don't attempt to detect captive portals. |
| 114 | */ |
| 115 | public static final int CAPTIVE_PORTAL_MODE_IGNORE = 0; |
| 116 | |
| 117 | /** |
| 118 | * When detecting a captive portal, display a notification that |
| 119 | * prompts the user to sign in. |
| 120 | */ |
| 121 | public static final int CAPTIVE_PORTAL_MODE_PROMPT = 1; |
| 122 | |
| 123 | /** |
| 124 | * When detecting a captive portal, immediately disconnect from the |
| 125 | * network and do not reconnect to that network in the future. |
| 126 | */ |
| 127 | public static final int CAPTIVE_PORTAL_MODE_AVOID = 2; |
| 128 | |
| 129 | /** @hide */ |
| 130 | @Retention(RetentionPolicy.SOURCE) |
| 131 | @IntDef(value = { |
| 132 | CAPTIVE_PORTAL_MODE_IGNORE, |
| 133 | CAPTIVE_PORTAL_MODE_PROMPT, |
| 134 | CAPTIVE_PORTAL_MODE_AVOID, |
| 135 | }) |
| 136 | public @interface CaptivePortalMode {} |
| 137 | |
| 138 | /** Global http proxy settings */ |
| 139 | |
| 140 | /** |
| 141 | * Host name for global http proxy. Set via ConnectivityManager. |
| 142 | */ |
| 143 | public static final String GLOBAL_HTTP_PROXY_HOST = "global_http_proxy_host"; |
| 144 | |
| 145 | /** |
| 146 | * Integer host port for global http proxy. Set via ConnectivityManager. |
| 147 | */ |
| 148 | public static final String GLOBAL_HTTP_PROXY_PORT = "global_http_proxy_port"; |
| 149 | |
| 150 | /** |
| 151 | * Exclusion list for global proxy. This string contains a list of |
| 152 | * comma-separated domains where the global proxy does not apply. |
| 153 | * Domains should be listed in a comma- separated list. Example of |
| 154 | * acceptable formats: ".domain1.com,my.domain2.com" Use |
| 155 | * ConnectivityManager to set/get. |
| 156 | */ |
| 157 | public static final String GLOBAL_HTTP_PROXY_EXCLUSION_LIST = |
| 158 | "global_http_proxy_exclusion_list"; |
| 159 | |
| 160 | /** |
| 161 | * The location PAC File for the proxy. |
| 162 | */ |
| 163 | public static final String GLOBAL_HTTP_PROXY_PAC = "global_proxy_pac_url"; |
| 164 | |
| 165 | /** Private dns settings */ |
| 166 | |
| 167 | /** |
| 168 | * The requested Private DNS mode (string), and an accompanying specifier (string). |
| 169 | * |
| 170 | * Currently, the specifier holds the chosen provider name when the mode requests |
| 171 | * a specific provider. It may be used to store the provider name even when the |
| 172 | * mode changes so that temporarily disabling and re-enabling the specific |
| 173 | * provider mode does not necessitate retyping the provider hostname. |
| 174 | */ |
| 175 | public static final String PRIVATE_DNS_MODE = "private_dns_mode"; |
| 176 | |
| 177 | /** |
| 178 | * The specific Private DNS provider name. |
| 179 | */ |
| 180 | public static final String PRIVATE_DNS_SPECIFIER = "private_dns_specifier"; |
| 181 | |
| 182 | /** |
| 183 | * Forced override of the default mode (hardcoded as "automatic", nee "opportunistic"). |
| 184 | * This allows changing the default mode without effectively disabling other modes, |
| 185 | * all of which require explicit user action to enable/configure. See also b/79719289. |
| 186 | * |
| 187 | * Value is a string, suitable for assignment to PRIVATE_DNS_MODE above. |
| 188 | */ |
| 189 | public static final String PRIVATE_DNS_DEFAULT_MODE = "private_dns_default_mode"; |
| 190 | |
| 191 | /** Other settings */ |
| 192 | |
| 193 | /** |
| 194 | * The number of milliseconds to hold on to a PendingIntent based request. This delay gives |
| 195 | * the receivers of the PendingIntent an opportunity to make a new network request before |
| 196 | * the Network satisfying the request is potentially removed. |
| 197 | */ |
| 198 | public static final String CONNECTIVITY_RELEASE_PENDING_INTENT_DELAY_MS = |
| 199 | "connectivity_release_pending_intent_delay_ms"; |
| 200 | |
| 201 | /** |
| 202 | * Whether the mobile data connection should remain active even when higher |
| 203 | * priority networks like WiFi are active, to help make network switching faster. |
| 204 | * |
| 205 | * See ConnectivityService for more info. |
| 206 | * |
| 207 | * (0 = disabled, 1 = enabled) |
| 208 | */ |
| 209 | public static final String MOBILE_DATA_ALWAYS_ON = "mobile_data_always_on"; |
| 210 | |
| 211 | /** |
| 212 | * Whether the wifi data connection should remain active even when higher |
| 213 | * priority networks like Ethernet are active, to keep both networks. |
| 214 | * In the case where higher priority networks are connected, wifi will be |
| 215 | * unused unless an application explicitly requests to use it. |
| 216 | * |
| 217 | * See ConnectivityService for more info. |
| 218 | * |
| 219 | * (0 = disabled, 1 = enabled) |
| 220 | */ |
| 221 | public static final String WIFI_ALWAYS_REQUESTED = "wifi_always_requested"; |
| 222 | |
paulhu | 845456e | 2021-03-17 17:19:09 +0800 | [diff] [blame] | 223 | /** |
| 224 | * Whether to automatically switch away from wifi networks that lose Internet access. |
| 225 | * Only meaningful if config_networkAvoidBadWifi is set to 0, otherwise the system always |
| 226 | * avoids such networks. Valid values are: |
| 227 | * |
| 228 | * 0: Don't avoid bad wifi, don't prompt the user. Get stuck on bad wifi like it's 2013. |
| 229 | * null: Ask the user whether to switch away from bad wifi. |
| 230 | * 1: Avoid bad wifi. |
| 231 | */ |
| 232 | public static final String NETWORK_AVOID_BAD_WIFI = "network_avoid_bad_wifi"; |
| 233 | |
| 234 | /** |
| 235 | * User setting for ConnectivityManager.getMeteredMultipathPreference(). This value may be |
| 236 | * overridden by the system based on device or application state. If null, the value |
| 237 | * specified by config_networkMeteredMultipathPreference is used. |
| 238 | */ |
| 239 | public static final String NETWORK_METERED_MULTIPATH_PREFERENCE = |
| 240 | "network_metered_multipath_preference"; |
| 241 | } |