The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 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 | |
Jeff Sharkey | f0ceede | 2011-08-02 17:22:34 -0700 | [diff] [blame] | 19 | import static com.android.internal.util.Preconditions.checkNotNull; |
| 20 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 21 | import android.annotation.SdkConstant; |
| 22 | import android.annotation.SdkConstant.SdkConstantType; |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 23 | import android.os.Binder; |
Jeff Sharkey | 3a844fc | 2011-08-16 14:37:57 -0700 | [diff] [blame] | 24 | import android.os.Build.VERSION_CODES; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 25 | import android.os.RemoteException; |
Jeff Sharkey | 961e304 | 2011-08-29 16:02:57 -0700 | [diff] [blame] | 26 | import android.provider.Settings; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | |
Robert Greenwalt | 585ac0f | 2010-08-27 09:24:29 -0700 | [diff] [blame] | 28 | import java.net.InetAddress; |
Robert Greenwalt | 585ac0f | 2010-08-27 09:24:29 -0700 | [diff] [blame] | 29 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 30 | /** |
| 31 | * Class that answers queries about the state of network connectivity. It also |
| 32 | * notifies applications when network connectivity changes. Get an instance |
| 33 | * of this class by calling |
| 34 | * {@link android.content.Context#getSystemService(String) Context.getSystemService(Context.CONNECTIVITY_SERVICE)}. |
| 35 | * <p> |
| 36 | * The primary responsibilities of this class are to: |
| 37 | * <ol> |
| 38 | * <li>Monitor network connections (Wi-Fi, GPRS, UMTS, etc.)</li> |
| 39 | * <li>Send broadcast intents when network connectivity changes</li> |
| 40 | * <li>Attempt to "fail over" to another network when connectivity to a network |
| 41 | * is lost</li> |
| 42 | * <li>Provide an API that allows applications to query the coarse-grained or fine-grained |
| 43 | * state of the available networks</li> |
| 44 | * </ol> |
| 45 | */ |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 46 | public class ConnectivityManager { |
| 47 | private static final String TAG = "ConnectivityManager"; |
| 48 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 49 | /** |
| 50 | * A change in network connectivity has occurred. A connection has either |
| 51 | * been established or lost. The NetworkInfo for the affected network is |
| 52 | * sent as an extra; it should be consulted to see what kind of |
| 53 | * connectivity event occurred. |
| 54 | * <p/> |
| 55 | * If this is a connection that was the result of failing over from a |
| 56 | * disconnected network, then the FAILOVER_CONNECTION boolean extra is |
| 57 | * set to true. |
| 58 | * <p/> |
| 59 | * For a loss of connectivity, if the connectivity manager is attempting |
| 60 | * to connect (or has already connected) to another network, the |
| 61 | * NetworkInfo for the new network is also passed as an extra. This lets |
| 62 | * any receivers of the broadcast know that they should not necessarily |
| 63 | * tell the user that no data traffic will be possible. Instead, the |
| 64 | * reciever should expect another broadcast soon, indicating either that |
| 65 | * the failover attempt succeeded (and so there is still overall data |
| 66 | * connectivity), or that the failover attempt failed, meaning that all |
| 67 | * connectivity has been lost. |
| 68 | * <p/> |
| 69 | * For a disconnect event, the boolean extra EXTRA_NO_CONNECTIVITY |
| 70 | * is set to {@code true} if there are no connected networks at all. |
| 71 | */ |
| 72 | public static final String CONNECTIVITY_ACTION = "android.net.conn.CONNECTIVITY_CHANGE"; |
Jeff Sharkey | f0ceede | 2011-08-02 17:22:34 -0700 | [diff] [blame] | 73 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 74 | /** |
Jeff Sharkey | 961e304 | 2011-08-29 16:02:57 -0700 | [diff] [blame] | 75 | * Identical to {@link #CONNECTIVITY_ACTION} broadcast, but sent without any |
| 76 | * applicable {@link Settings.Secure#CONNECTIVITY_CHANGE_DELAY}. |
| 77 | * |
| 78 | * @hide |
| 79 | */ |
| 80 | public static final String CONNECTIVITY_ACTION_IMMEDIATE = |
| 81 | "android.net.conn.CONNECTIVITY_CHANGE_IMMEDIATE"; |
| 82 | |
| 83 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 84 | * The lookup key for a {@link NetworkInfo} object. Retrieve with |
| 85 | * {@link android.content.Intent#getParcelableExtra(String)}. |
Jeff Sharkey | f0ceede | 2011-08-02 17:22:34 -0700 | [diff] [blame] | 86 | * |
| 87 | * @deprecated Since {@link NetworkInfo} can vary based on UID, applications |
| 88 | * should always obtain network information through |
| 89 | * {@link #getActiveNetworkInfo()} or |
| 90 | * {@link #getAllNetworkInfo()}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 91 | */ |
Jeff Sharkey | f0ceede | 2011-08-02 17:22:34 -0700 | [diff] [blame] | 92 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 93 | public static final String EXTRA_NETWORK_INFO = "networkInfo"; |
Jeff Sharkey | f0ceede | 2011-08-02 17:22:34 -0700 | [diff] [blame] | 94 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 95 | /** |
| 96 | * The lookup key for a boolean that indicates whether a connect event |
| 97 | * is for a network to which the connectivity manager was failing over |
| 98 | * following a disconnect on another network. |
| 99 | * Retrieve it with {@link android.content.Intent#getBooleanExtra(String,boolean)}. |
| 100 | */ |
| 101 | public static final String EXTRA_IS_FAILOVER = "isFailover"; |
| 102 | /** |
| 103 | * The lookup key for a {@link NetworkInfo} object. This is supplied when |
| 104 | * there is another network that it may be possible to connect to. Retrieve with |
| 105 | * {@link android.content.Intent#getParcelableExtra(String)}. |
| 106 | */ |
| 107 | public static final String EXTRA_OTHER_NETWORK_INFO = "otherNetwork"; |
| 108 | /** |
| 109 | * The lookup key for a boolean that indicates whether there is a |
| 110 | * complete lack of connectivity, i.e., no network is available. |
| 111 | * Retrieve it with {@link android.content.Intent#getBooleanExtra(String,boolean)}. |
| 112 | */ |
| 113 | public static final String EXTRA_NO_CONNECTIVITY = "noConnectivity"; |
| 114 | /** |
| 115 | * The lookup key for a string that indicates why an attempt to connect |
| 116 | * to a network failed. The string has no particular structure. It is |
| 117 | * intended to be used in notifications presented to users. Retrieve |
| 118 | * it with {@link android.content.Intent#getStringExtra(String)}. |
| 119 | */ |
| 120 | public static final String EXTRA_REASON = "reason"; |
| 121 | /** |
| 122 | * The lookup key for a string that provides optionally supplied |
| 123 | * extra information about the network state. The information |
| 124 | * may be passed up from the lower networking layers, and its |
| 125 | * meaning may be specific to a particular network type. Retrieve |
| 126 | * it with {@link android.content.Intent#getStringExtra(String)}. |
| 127 | */ |
| 128 | public static final String EXTRA_EXTRA_INFO = "extraInfo"; |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 129 | /** |
| 130 | * The lookup key for an int that provides information about |
| 131 | * our connection to the internet at large. 0 indicates no connection, |
| 132 | * 100 indicates a great connection. Retrieve it with |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 133 | * {@link android.content.Intent#getIntExtra(String, int)}. |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 134 | * {@hide} |
| 135 | */ |
| 136 | public static final String EXTRA_INET_CONDITION = "inetCondition"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 137 | |
| 138 | /** |
| 139 | * Broadcast Action: The setting for background data usage has changed |
| 140 | * values. Use {@link #getBackgroundDataSetting()} to get the current value. |
| 141 | * <p> |
| 142 | * If an application uses the network in the background, it should listen |
| 143 | * for this broadcast and stop using the background data if the value is |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 144 | * {@code false}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 145 | */ |
| 146 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 147 | public static final String ACTION_BACKGROUND_DATA_SETTING_CHANGED = |
| 148 | "android.net.conn.BACKGROUND_DATA_SETTING_CHANGED"; |
| 149 | |
Robert Greenwalt | 1e9aac2 | 2010-09-15 17:36:33 -0700 | [diff] [blame] | 150 | /** |
| 151 | * Broadcast Action: The network connection may not be good |
| 152 | * uses {@code ConnectivityManager.EXTRA_INET_CONDITION} and |
| 153 | * {@code ConnectivityManager.EXTRA_NETWORK_INFO} to specify |
| 154 | * the network and it's condition. |
| 155 | * @hide |
| 156 | */ |
| 157 | public static final String INET_CONDITION_ACTION = |
| 158 | "android.net.conn.INET_CONDITION_ACTION"; |
| 159 | |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 160 | /** |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 161 | * Broadcast Action: A tetherable connection has come or gone |
| 162 | * TODO - finish the doc |
| 163 | * @hide |
| 164 | */ |
| 165 | public static final String ACTION_TETHER_STATE_CHANGED = |
| 166 | "android.net.conn.TETHER_STATE_CHANGED"; |
| 167 | |
| 168 | /** |
| 169 | * @hide |
Robert Greenwalt | 2a091d7 | 2010-02-11 18:18:40 -0800 | [diff] [blame] | 170 | * gives a String[] |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 171 | */ |
Robert Greenwalt | 2a091d7 | 2010-02-11 18:18:40 -0800 | [diff] [blame] | 172 | public static final String EXTRA_AVAILABLE_TETHER = "availableArray"; |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 173 | |
| 174 | /** |
| 175 | * @hide |
Robert Greenwalt | 2a091d7 | 2010-02-11 18:18:40 -0800 | [diff] [blame] | 176 | * gives a String[] |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 177 | */ |
Robert Greenwalt | 2a091d7 | 2010-02-11 18:18:40 -0800 | [diff] [blame] | 178 | public static final String EXTRA_ACTIVE_TETHER = "activeArray"; |
| 179 | |
| 180 | /** |
| 181 | * @hide |
| 182 | * gives a String[] |
| 183 | */ |
| 184 | public static final String EXTRA_ERRORED_TETHER = "erroredArray"; |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 185 | |
| 186 | /** |
Robert Greenwalt | ccf83af1 | 2011-06-02 17:30:47 -0700 | [diff] [blame] | 187 | * The absence of APN.. |
| 188 | * @hide |
| 189 | */ |
| 190 | public static final int TYPE_NONE = -1; |
| 191 | |
| 192 | /** |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 193 | * The Default Mobile data connection. When active, all data traffic |
Robert Greenwalt | 97ab2d4 | 2011-05-27 11:29:13 -0700 | [diff] [blame] | 194 | * will use this connection by default. |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 195 | */ |
| 196 | public static final int TYPE_MOBILE = 0; |
| 197 | /** |
| 198 | * The Default WIFI data connection. When active, all data traffic |
Robert Greenwalt | 97ab2d4 | 2011-05-27 11:29:13 -0700 | [diff] [blame] | 199 | * will use this connection by default. |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 200 | */ |
| 201 | public static final int TYPE_WIFI = 1; |
| 202 | /** |
| 203 | * An MMS-specific Mobile data connection. This connection may be the |
Robert Greenwalt | 1bc3c37 | 2010-01-13 11:29:03 -0800 | [diff] [blame] | 204 | * same as {@link #TYPE_MOBILE} but it may be different. This is used |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 205 | * by applications needing to talk to the carrier's Multimedia Messaging |
| 206 | * Service servers. It may coexist with default data connections. |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 207 | */ |
| 208 | public static final int TYPE_MOBILE_MMS = 2; |
| 209 | /** |
| 210 | * A SUPL-specific Mobile data connection. This connection may be the |
Robert Greenwalt | 1bc3c37 | 2010-01-13 11:29:03 -0800 | [diff] [blame] | 211 | * same as {@link #TYPE_MOBILE} but it may be different. This is used |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 212 | * by applications needing to talk to the carrier's Secure User Plane |
| 213 | * Location servers for help locating the device. It may coexist with |
| 214 | * default data connections. |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 215 | */ |
| 216 | public static final int TYPE_MOBILE_SUPL = 3; |
| 217 | /** |
| 218 | * A DUN-specific Mobile data connection. This connection may be the |
Robert Greenwalt | 1bc3c37 | 2010-01-13 11:29:03 -0800 | [diff] [blame] | 219 | * same as {@link #TYPE_MOBILE} but it may be different. This is used |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 220 | * by applicaitons performing a Dial Up Networking bridge so that |
| 221 | * the carrier is aware of DUN traffic. It may coexist with default data |
| 222 | * connections. |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 223 | */ |
| 224 | public static final int TYPE_MOBILE_DUN = 4; |
| 225 | /** |
| 226 | * A High Priority Mobile data connection. This connection is typically |
Robert Greenwalt | 1bc3c37 | 2010-01-13 11:29:03 -0800 | [diff] [blame] | 227 | * the same as {@link #TYPE_MOBILE} but the routing setup is different. |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 228 | * Only requesting processes will have access to the Mobile DNS servers |
| 229 | * and only IP's explicitly requested via {@link #requestRouteToHost} |
Robert Greenwalt | c849cdf | 2010-01-08 11:47:27 -0800 | [diff] [blame] | 230 | * will route over this interface if a default route exists. |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 231 | */ |
| 232 | public static final int TYPE_MOBILE_HIPRI = 5; |
jsh | 8214deb | 2010-03-11 15:04:43 -0800 | [diff] [blame] | 233 | /** |
| 234 | * The Default WiMAX data connection. When active, all data traffic |
Robert Greenwalt | 97ab2d4 | 2011-05-27 11:29:13 -0700 | [diff] [blame] | 235 | * will use this connection by default. |
jsh | 8214deb | 2010-03-11 15:04:43 -0800 | [diff] [blame] | 236 | */ |
| 237 | public static final int TYPE_WIMAX = 6; |
Robert Greenwalt | da3d5e6 | 2010-12-06 13:56:24 -0800 | [diff] [blame] | 238 | |
Jaikumar Ganesh | 15c7439 | 2010-12-21 22:31:44 -0800 | [diff] [blame] | 239 | /** |
Robert Greenwalt | 97ab2d4 | 2011-05-27 11:29:13 -0700 | [diff] [blame] | 240 | * The Default Bluetooth data connection. When active, all data traffic |
| 241 | * will use this connection by default. |
Jaikumar Ganesh | 15c7439 | 2010-12-21 22:31:44 -0800 | [diff] [blame] | 242 | */ |
| 243 | public static final int TYPE_BLUETOOTH = 7; |
| 244 | |
Robert Greenwalt | 6081084 | 2011-04-22 15:28:18 -0700 | [diff] [blame] | 245 | /** |
| 246 | * Dummy data connection. This should not be used on shipping devices. |
| 247 | */ |
Jaikumar Ganesh | 15c7439 | 2010-12-21 22:31:44 -0800 | [diff] [blame] | 248 | public static final int TYPE_DUMMY = 8; |
Wink Saville | 9d7d628 | 2011-03-12 14:52:01 -0800 | [diff] [blame] | 249 | |
Robert Greenwalt | 6081084 | 2011-04-22 15:28:18 -0700 | [diff] [blame] | 250 | /** |
Robert Greenwalt | 97ab2d4 | 2011-05-27 11:29:13 -0700 | [diff] [blame] | 251 | * The Default Ethernet data connection. When active, all data traffic |
| 252 | * will use this connection by default. |
Robert Greenwalt | 6081084 | 2011-04-22 15:28:18 -0700 | [diff] [blame] | 253 | */ |
Robert Greenwalt | e12aec9 | 2011-01-28 14:48:37 -0800 | [diff] [blame] | 254 | public static final int TYPE_ETHERNET = 9; |
Robert Greenwalt | 6081084 | 2011-04-22 15:28:18 -0700 | [diff] [blame] | 255 | |
Wink Saville | 9d7d628 | 2011-03-12 14:52:01 -0800 | [diff] [blame] | 256 | /** |
| 257 | * Over the air Adminstration. |
| 258 | * {@hide} |
| 259 | */ |
| 260 | public static final int TYPE_MOBILE_FOTA = 10; |
| 261 | |
| 262 | /** |
| 263 | * IP Multimedia Subsystem |
| 264 | * {@hide} |
| 265 | */ |
| 266 | public static final int TYPE_MOBILE_IMS = 11; |
| 267 | |
| 268 | /** |
| 269 | * Carrier Branded Services |
| 270 | * {@hide} |
| 271 | */ |
| 272 | public static final int TYPE_MOBILE_CBS = 12; |
| 273 | |
repo sync | aea743a | 2011-07-29 23:55:49 -0700 | [diff] [blame] | 274 | /** |
| 275 | * A Wi-Fi p2p connection. Only requesting processes will have access to |
| 276 | * the peers connected. |
| 277 | * {@hide} |
| 278 | */ |
| 279 | public static final int TYPE_WIFI_P2P = 13; |
Wink Saville | 9d7d628 | 2011-03-12 14:52:01 -0800 | [diff] [blame] | 280 | |
| 281 | /** {@hide} */ |
repo sync | aea743a | 2011-07-29 23:55:49 -0700 | [diff] [blame] | 282 | public static final int MAX_RADIO_TYPE = TYPE_WIFI_P2P; |
| 283 | |
| 284 | /** {@hide} */ |
| 285 | public static final int MAX_NETWORK_TYPE = TYPE_WIFI_P2P; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 286 | |
| 287 | public static final int DEFAULT_NETWORK_PREFERENCE = TYPE_WIFI; |
| 288 | |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 289 | private final IConnectivityManager mService; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 290 | |
Jeff Sharkey | d2a4587 | 2011-05-28 20:56:34 -0700 | [diff] [blame] | 291 | public static boolean isNetworkTypeValid(int networkType) { |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 292 | return networkType >= 0 && networkType <= MAX_NETWORK_TYPE; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 293 | } |
| 294 | |
Jeff Sharkey | d2a4587 | 2011-05-28 20:56:34 -0700 | [diff] [blame] | 295 | /** {@hide} */ |
| 296 | public static String getNetworkTypeName(int type) { |
| 297 | switch (type) { |
| 298 | case TYPE_MOBILE: |
| 299 | return "MOBILE"; |
| 300 | case TYPE_WIFI: |
| 301 | return "WIFI"; |
| 302 | case TYPE_MOBILE_MMS: |
| 303 | return "MOBILE_MMS"; |
| 304 | case TYPE_MOBILE_SUPL: |
| 305 | return "MOBILE_SUPL"; |
| 306 | case TYPE_MOBILE_DUN: |
| 307 | return "MOBILE_DUN"; |
| 308 | case TYPE_MOBILE_HIPRI: |
| 309 | return "MOBILE_HIPRI"; |
| 310 | case TYPE_WIMAX: |
| 311 | return "WIMAX"; |
| 312 | case TYPE_BLUETOOTH: |
| 313 | return "BLUETOOTH"; |
| 314 | case TYPE_DUMMY: |
| 315 | return "DUMMY"; |
| 316 | case TYPE_ETHERNET: |
| 317 | return "ETHERNET"; |
| 318 | case TYPE_MOBILE_FOTA: |
| 319 | return "MOBILE_FOTA"; |
| 320 | case TYPE_MOBILE_IMS: |
| 321 | return "MOBILE_IMS"; |
| 322 | case TYPE_MOBILE_CBS: |
| 323 | return "MOBILE_CBS"; |
repo sync | aea743a | 2011-07-29 23:55:49 -0700 | [diff] [blame] | 324 | case TYPE_WIFI_P2P: |
| 325 | return "WIFI_P2P"; |
Jeff Sharkey | d2a4587 | 2011-05-28 20:56:34 -0700 | [diff] [blame] | 326 | default: |
| 327 | return Integer.toString(type); |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | /** {@hide} */ |
| 332 | public static boolean isNetworkTypeMobile(int networkType) { |
| 333 | switch (networkType) { |
| 334 | case TYPE_MOBILE: |
| 335 | case TYPE_MOBILE_MMS: |
| 336 | case TYPE_MOBILE_SUPL: |
| 337 | case TYPE_MOBILE_DUN: |
| 338 | case TYPE_MOBILE_HIPRI: |
| 339 | case TYPE_MOBILE_FOTA: |
| 340 | case TYPE_MOBILE_IMS: |
| 341 | case TYPE_MOBILE_CBS: |
| 342 | return true; |
| 343 | default: |
| 344 | return false; |
| 345 | } |
| 346 | } |
| 347 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 348 | public void setNetworkPreference(int preference) { |
| 349 | try { |
| 350 | mService.setNetworkPreference(preference); |
| 351 | } catch (RemoteException e) { |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | public int getNetworkPreference() { |
| 356 | try { |
| 357 | return mService.getNetworkPreference(); |
| 358 | } catch (RemoteException e) { |
| 359 | return -1; |
| 360 | } |
| 361 | } |
| 362 | |
Scott Main | 671644c | 2011-10-06 19:02:28 -0700 | [diff] [blame^] | 363 | /** |
| 364 | * Gets you info about the current data network. |
| 365 | * Call {@link NetworkInfo#isConnected()} on the returned {@link NetworkInfo} |
| 366 | * to check if the device has a data connection. |
| 367 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 368 | public NetworkInfo getActiveNetworkInfo() { |
| 369 | try { |
| 370 | return mService.getActiveNetworkInfo(); |
| 371 | } catch (RemoteException e) { |
| 372 | return null; |
| 373 | } |
| 374 | } |
| 375 | |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 376 | /** {@hide} */ |
| 377 | public NetworkInfo getActiveNetworkInfoForUid(int uid) { |
| 378 | try { |
| 379 | return mService.getActiveNetworkInfoForUid(uid); |
| 380 | } catch (RemoteException e) { |
| 381 | return null; |
| 382 | } |
| 383 | } |
| 384 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 385 | public NetworkInfo getNetworkInfo(int networkType) { |
| 386 | try { |
| 387 | return mService.getNetworkInfo(networkType); |
| 388 | } catch (RemoteException e) { |
| 389 | return null; |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | public NetworkInfo[] getAllNetworkInfo() { |
| 394 | try { |
| 395 | return mService.getAllNetworkInfo(); |
| 396 | } catch (RemoteException e) { |
| 397 | return null; |
| 398 | } |
| 399 | } |
| 400 | |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 401 | /** {@hide} */ |
Robert Greenwalt | d192dad | 2010-09-14 09:18:02 -0700 | [diff] [blame] | 402 | public LinkProperties getActiveLinkProperties() { |
| 403 | try { |
| 404 | return mService.getActiveLinkProperties(); |
| 405 | } catch (RemoteException e) { |
| 406 | return null; |
| 407 | } |
| 408 | } |
| 409 | |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 410 | /** {@hide} */ |
Robert Greenwalt | d192dad | 2010-09-14 09:18:02 -0700 | [diff] [blame] | 411 | public LinkProperties getLinkProperties(int networkType) { |
| 412 | try { |
| 413 | return mService.getLinkProperties(networkType); |
| 414 | } catch (RemoteException e) { |
| 415 | return null; |
| 416 | } |
| 417 | } |
| 418 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 419 | /** {@hide} */ |
| 420 | public boolean setRadios(boolean turnOn) { |
| 421 | try { |
| 422 | return mService.setRadios(turnOn); |
| 423 | } catch (RemoteException e) { |
| 424 | return false; |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | /** {@hide} */ |
| 429 | public boolean setRadio(int networkType, boolean turnOn) { |
| 430 | try { |
| 431 | return mService.setRadio(networkType, turnOn); |
| 432 | } catch (RemoteException e) { |
| 433 | return false; |
| 434 | } |
| 435 | } |
| 436 | |
| 437 | /** |
| 438 | * Tells the underlying networking system that the caller wants to |
| 439 | * begin using the named feature. The interpretation of {@code feature} |
| 440 | * is completely up to each networking implementation. |
| 441 | * @param networkType specifies which network the request pertains to |
| 442 | * @param feature the name of the feature to be used |
| 443 | * @return an integer value representing the outcome of the request. |
| 444 | * The interpretation of this value is specific to each networking |
| 445 | * implementation+feature combination, except that the value {@code -1} |
| 446 | * always indicates failure. |
| 447 | */ |
| 448 | public int startUsingNetworkFeature(int networkType, String feature) { |
| 449 | try { |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 450 | return mService.startUsingNetworkFeature(networkType, feature, |
| 451 | new Binder()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 452 | } catch (RemoteException e) { |
| 453 | return -1; |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | /** |
| 458 | * Tells the underlying networking system that the caller is finished |
| 459 | * using the named feature. The interpretation of {@code feature} |
| 460 | * is completely up to each networking implementation. |
| 461 | * @param networkType specifies which network the request pertains to |
| 462 | * @param feature the name of the feature that is no longer needed |
| 463 | * @return an integer value representing the outcome of the request. |
| 464 | * The interpretation of this value is specific to each networking |
| 465 | * implementation+feature combination, except that the value {@code -1} |
| 466 | * always indicates failure. |
| 467 | */ |
| 468 | public int stopUsingNetworkFeature(int networkType, String feature) { |
| 469 | try { |
| 470 | return mService.stopUsingNetworkFeature(networkType, feature); |
| 471 | } catch (RemoteException e) { |
| 472 | return -1; |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | /** |
| 477 | * Ensure that a network route exists to deliver traffic to the specified |
| 478 | * host via the specified network interface. An attempt to add a route that |
| 479 | * already exists is ignored, but treated as successful. |
| 480 | * @param networkType the type of the network over which traffic to the specified |
| 481 | * host is to be routed |
| 482 | * @param hostAddress the IP address of the host to which the route is desired |
| 483 | * @return {@code true} on success, {@code false} on failure |
| 484 | */ |
| 485 | public boolean requestRouteToHost(int networkType, int hostAddress) { |
Robert Greenwalt | 585ac0f | 2010-08-27 09:24:29 -0700 | [diff] [blame] | 486 | InetAddress inetAddress = NetworkUtils.intToInetAddress(hostAddress); |
| 487 | |
| 488 | if (inetAddress == null) { |
| 489 | return false; |
| 490 | } |
| 491 | |
| 492 | return requestRouteToHostAddress(networkType, inetAddress); |
| 493 | } |
| 494 | |
| 495 | /** |
| 496 | * Ensure that a network route exists to deliver traffic to the specified |
| 497 | * host via the specified network interface. An attempt to add a route that |
| 498 | * already exists is ignored, but treated as successful. |
| 499 | * @param networkType the type of the network over which traffic to the specified |
| 500 | * host is to be routed |
| 501 | * @param hostAddress the IP address of the host to which the route is desired |
| 502 | * @return {@code true} on success, {@code false} on failure |
| 503 | * @hide |
| 504 | */ |
| 505 | public boolean requestRouteToHostAddress(int networkType, InetAddress hostAddress) { |
| 506 | byte[] address = hostAddress.getAddress(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 507 | try { |
Robert Greenwalt | 585ac0f | 2010-08-27 09:24:29 -0700 | [diff] [blame] | 508 | return mService.requestRouteToHostAddress(networkType, address); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 509 | } catch (RemoteException e) { |
| 510 | return false; |
| 511 | } |
| 512 | } |
| 513 | |
| 514 | /** |
| 515 | * Returns the value of the setting for background data usage. If false, |
| 516 | * applications should not use the network if the application is not in the |
| 517 | * foreground. Developers should respect this setting, and check the value |
| 518 | * of this before performing any background data operations. |
| 519 | * <p> |
| 520 | * All applications that have background services that use the network |
| 521 | * should listen to {@link #ACTION_BACKGROUND_DATA_SETTING_CHANGED}. |
Jeff Sharkey | 3a844fc | 2011-08-16 14:37:57 -0700 | [diff] [blame] | 522 | * <p> |
Scott Main | 4cc5333 | 2011-10-06 18:32:43 -0700 | [diff] [blame] | 523 | * @deprecated As of {@link VERSION_CODES#ICE_CREAM_SANDWICH}, availability of |
Jeff Sharkey | 3a844fc | 2011-08-16 14:37:57 -0700 | [diff] [blame] | 524 | * background data depends on several combined factors, and this method will |
| 525 | * always return {@code true}. Instead, when background data is unavailable, |
| 526 | * {@link #getActiveNetworkInfo()} will now appear disconnected. |
Danica Chang | 6fdd0c6 | 2010-08-11 14:54:43 -0700 | [diff] [blame] | 527 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 528 | * @return Whether background data usage is allowed. |
| 529 | */ |
Jeff Sharkey | 3a844fc | 2011-08-16 14:37:57 -0700 | [diff] [blame] | 530 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 531 | public boolean getBackgroundDataSetting() { |
Jeff Sharkey | 3a844fc | 2011-08-16 14:37:57 -0700 | [diff] [blame] | 532 | // assume that background data is allowed; final authority is |
| 533 | // NetworkInfo which may be blocked. |
| 534 | return true; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 535 | } |
| 536 | |
| 537 | /** |
| 538 | * Sets the value of the setting for background data usage. |
Robert Greenwalt | c03fa50 | 2010-02-23 18:58:05 -0800 | [diff] [blame] | 539 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 540 | * @param allowBackgroundData Whether an application should use data while |
| 541 | * it is in the background. |
Robert Greenwalt | c03fa50 | 2010-02-23 18:58:05 -0800 | [diff] [blame] | 542 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 543 | * @attr ref android.Manifest.permission#CHANGE_BACKGROUND_DATA_SETTING |
| 544 | * @see #getBackgroundDataSetting() |
| 545 | * @hide |
| 546 | */ |
Jeff Sharkey | 3a844fc | 2011-08-16 14:37:57 -0700 | [diff] [blame] | 547 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 548 | public void setBackgroundDataSetting(boolean allowBackgroundData) { |
Jeff Sharkey | 3a844fc | 2011-08-16 14:37:57 -0700 | [diff] [blame] | 549 | // ignored |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 550 | } |
Robert Greenwalt | c03fa50 | 2010-02-23 18:58:05 -0800 | [diff] [blame] | 551 | |
| 552 | /** |
Jeff Sharkey | f0ceede | 2011-08-02 17:22:34 -0700 | [diff] [blame] | 553 | * Return quota status for the current active network, or {@code null} if no |
| 554 | * network is active. Quota status can change rapidly, so these values |
| 555 | * shouldn't be cached. |
Jeff Sharkey | 44a3e0d | 2011-10-06 10:50:09 -0700 | [diff] [blame] | 556 | * |
| 557 | * @hide |
Jeff Sharkey | f0ceede | 2011-08-02 17:22:34 -0700 | [diff] [blame] | 558 | */ |
| 559 | public NetworkQuotaInfo getActiveNetworkQuotaInfo() { |
| 560 | try { |
| 561 | return mService.getActiveNetworkQuotaInfo(); |
| 562 | } catch (RemoteException e) { |
| 563 | return null; |
| 564 | } |
| 565 | } |
| 566 | |
| 567 | /** |
Robert Greenwalt | c03fa50 | 2010-02-23 18:58:05 -0800 | [diff] [blame] | 568 | * Gets the value of the setting for enabling Mobile data. |
| 569 | * |
| 570 | * @return Whether mobile data is enabled. |
| 571 | * @hide |
| 572 | */ |
| 573 | public boolean getMobileDataEnabled() { |
| 574 | try { |
| 575 | return mService.getMobileDataEnabled(); |
| 576 | } catch (RemoteException e) { |
| 577 | return true; |
| 578 | } |
| 579 | } |
| 580 | |
| 581 | /** |
| 582 | * Sets the persisted value for enabling/disabling Mobile data. |
| 583 | * |
Robert Greenwalt | 5a73506 | 2010-03-02 17:25:02 -0800 | [diff] [blame] | 584 | * @param enabled Whether the mobile data connection should be |
Robert Greenwalt | c03fa50 | 2010-02-23 18:58:05 -0800 | [diff] [blame] | 585 | * used or not. |
| 586 | * @hide |
| 587 | */ |
| 588 | public void setMobileDataEnabled(boolean enabled) { |
| 589 | try { |
| 590 | mService.setMobileDataEnabled(enabled); |
| 591 | } catch (RemoteException e) { |
| 592 | } |
| 593 | } |
| 594 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 595 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 596 | * {@hide} |
| 597 | */ |
| 598 | public ConnectivityManager(IConnectivityManager service) { |
Jeff Sharkey | f0ceede | 2011-08-02 17:22:34 -0700 | [diff] [blame] | 599 | mService = checkNotNull(service, "missing IConnectivityManager"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 600 | } |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 601 | |
| 602 | /** |
| 603 | * {@hide} |
| 604 | */ |
| 605 | public String[] getTetherableIfaces() { |
| 606 | try { |
| 607 | return mService.getTetherableIfaces(); |
| 608 | } catch (RemoteException e) { |
| 609 | return new String[0]; |
| 610 | } |
| 611 | } |
| 612 | |
| 613 | /** |
| 614 | * {@hide} |
| 615 | */ |
| 616 | public String[] getTetheredIfaces() { |
| 617 | try { |
| 618 | return mService.getTetheredIfaces(); |
| 619 | } catch (RemoteException e) { |
| 620 | return new String[0]; |
| 621 | } |
| 622 | } |
| 623 | |
| 624 | /** |
| 625 | * {@hide} |
| 626 | */ |
Robert Greenwalt | 5a73506 | 2010-03-02 17:25:02 -0800 | [diff] [blame] | 627 | public String[] getTetheringErroredIfaces() { |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 628 | try { |
Robert Greenwalt | 5a73506 | 2010-03-02 17:25:02 -0800 | [diff] [blame] | 629 | return mService.getTetheringErroredIfaces(); |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 630 | } catch (RemoteException e) { |
Robert Greenwalt | 5a73506 | 2010-03-02 17:25:02 -0800 | [diff] [blame] | 631 | return new String[0]; |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 632 | } |
| 633 | } |
| 634 | |
| 635 | /** |
Robert Greenwalt | 5a73506 | 2010-03-02 17:25:02 -0800 | [diff] [blame] | 636 | * @return error A TETHER_ERROR value indicating success or failure type |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 637 | * {@hide} |
| 638 | */ |
Robert Greenwalt | 5a73506 | 2010-03-02 17:25:02 -0800 | [diff] [blame] | 639 | public int tether(String iface) { |
| 640 | try { |
| 641 | return mService.tether(iface); |
| 642 | } catch (RemoteException e) { |
| 643 | return TETHER_ERROR_SERVICE_UNAVAIL; |
| 644 | } |
| 645 | } |
| 646 | |
| 647 | /** |
| 648 | * @return error A TETHER_ERROR value indicating success or failure type |
| 649 | * {@hide} |
| 650 | */ |
| 651 | public int untether(String iface) { |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 652 | try { |
| 653 | return mService.untether(iface); |
| 654 | } catch (RemoteException e) { |
Robert Greenwalt | 5a73506 | 2010-03-02 17:25:02 -0800 | [diff] [blame] | 655 | return TETHER_ERROR_SERVICE_UNAVAIL; |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 656 | } |
| 657 | } |
Robert Greenwalt | 2a091d7 | 2010-02-11 18:18:40 -0800 | [diff] [blame] | 658 | |
| 659 | /** |
| 660 | * {@hide} |
| 661 | */ |
| 662 | public boolean isTetheringSupported() { |
| 663 | try { |
| 664 | return mService.isTetheringSupported(); |
| 665 | } catch (RemoteException e) { |
| 666 | return false; |
| 667 | } |
| 668 | } |
| 669 | |
| 670 | /** |
| 671 | * {@hide} |
| 672 | */ |
| 673 | public String[] getTetherableUsbRegexs() { |
| 674 | try { |
| 675 | return mService.getTetherableUsbRegexs(); |
| 676 | } catch (RemoteException e) { |
| 677 | return new String[0]; |
| 678 | } |
| 679 | } |
| 680 | |
| 681 | /** |
| 682 | * {@hide} |
| 683 | */ |
| 684 | public String[] getTetherableWifiRegexs() { |
| 685 | try { |
| 686 | return mService.getTetherableWifiRegexs(); |
| 687 | } catch (RemoteException e) { |
| 688 | return new String[0]; |
| 689 | } |
| 690 | } |
Robert Greenwalt | 5a73506 | 2010-03-02 17:25:02 -0800 | [diff] [blame] | 691 | |
Danica Chang | 6fdd0c6 | 2010-08-11 14:54:43 -0700 | [diff] [blame] | 692 | /** |
| 693 | * {@hide} |
| 694 | */ |
| 695 | public String[] getTetherableBluetoothRegexs() { |
| 696 | try { |
| 697 | return mService.getTetherableBluetoothRegexs(); |
| 698 | } catch (RemoteException e) { |
| 699 | return new String[0]; |
| 700 | } |
| 701 | } |
| 702 | |
Mike Lockwood | 6c2260b | 2011-07-19 13:04:47 -0700 | [diff] [blame] | 703 | /** |
| 704 | * {@hide} |
| 705 | */ |
| 706 | public int setUsbTethering(boolean enable) { |
| 707 | try { |
| 708 | return mService.setUsbTethering(enable); |
| 709 | } catch (RemoteException e) { |
| 710 | return TETHER_ERROR_SERVICE_UNAVAIL; |
| 711 | } |
| 712 | } |
| 713 | |
Robert Greenwalt | 5a73506 | 2010-03-02 17:25:02 -0800 | [diff] [blame] | 714 | /** {@hide} */ |
| 715 | public static final int TETHER_ERROR_NO_ERROR = 0; |
| 716 | /** {@hide} */ |
| 717 | public static final int TETHER_ERROR_UNKNOWN_IFACE = 1; |
| 718 | /** {@hide} */ |
| 719 | public static final int TETHER_ERROR_SERVICE_UNAVAIL = 2; |
| 720 | /** {@hide} */ |
| 721 | public static final int TETHER_ERROR_UNSUPPORTED = 3; |
| 722 | /** {@hide} */ |
| 723 | public static final int TETHER_ERROR_UNAVAIL_IFACE = 4; |
| 724 | /** {@hide} */ |
| 725 | public static final int TETHER_ERROR_MASTER_ERROR = 5; |
| 726 | /** {@hide} */ |
| 727 | public static final int TETHER_ERROR_TETHER_IFACE_ERROR = 6; |
| 728 | /** {@hide} */ |
| 729 | public static final int TETHER_ERROR_UNTETHER_IFACE_ERROR = 7; |
| 730 | /** {@hide} */ |
| 731 | public static final int TETHER_ERROR_ENABLE_NAT_ERROR = 8; |
| 732 | /** {@hide} */ |
| 733 | public static final int TETHER_ERROR_DISABLE_NAT_ERROR = 9; |
| 734 | /** {@hide} */ |
| 735 | public static final int TETHER_ERROR_IFACE_CFG_ERROR = 10; |
| 736 | |
| 737 | /** |
| 738 | * @param iface The name of the interface we're interested in |
| 739 | * @return error The error code of the last error tethering or untethering the named |
| 740 | * interface |
| 741 | * {@hide} |
| 742 | */ |
| 743 | public int getLastTetherError(String iface) { |
| 744 | try { |
| 745 | return mService.getLastTetherError(iface); |
| 746 | } catch (RemoteException e) { |
| 747 | return TETHER_ERROR_SERVICE_UNAVAIL; |
| 748 | } |
Robert Greenwalt | 14f2ef4 | 2010-06-15 12:19:37 -0700 | [diff] [blame] | 749 | } |
| 750 | |
| 751 | /** |
| 752 | * Ensure the device stays awake until we connect with the next network |
| 753 | * @param forWhome The name of the network going down for logging purposes |
| 754 | * @return {@code true} on success, {@code false} on failure |
| 755 | * {@hide} |
| 756 | */ |
| 757 | public boolean requestNetworkTransitionWakelock(String forWhom) { |
| 758 | try { |
| 759 | mService.requestNetworkTransitionWakelock(forWhom); |
| 760 | return true; |
| 761 | } catch (RemoteException e) { |
| 762 | return false; |
| 763 | } |
| 764 | } |
Robert Greenwalt | ca4306c | 2010-09-09 13:15:32 -0700 | [diff] [blame] | 765 | |
Robert Greenwalt | 67fd6c9 | 2010-09-09 14:22:59 -0700 | [diff] [blame] | 766 | /** |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 767 | * @param networkType The type of network you want to report on |
| 768 | * @param percentage The quality of the connection 0 is bad, 100 is good |
| 769 | * {@hide} |
| 770 | */ |
| 771 | public void reportInetCondition(int networkType, int percentage) { |
| 772 | try { |
| 773 | mService.reportInetCondition(networkType, percentage); |
| 774 | } catch (RemoteException e) { |
| 775 | } |
| 776 | } |
Robert Greenwalt | 434203a | 2010-10-11 16:00:27 -0700 | [diff] [blame] | 777 | |
| 778 | /** |
| 779 | * @param proxyProperties The definition for the new global http proxy |
| 780 | * {@hide} |
| 781 | */ |
| 782 | public void setGlobalProxy(ProxyProperties p) { |
| 783 | try { |
| 784 | mService.setGlobalProxy(p); |
| 785 | } catch (RemoteException e) { |
| 786 | } |
| 787 | } |
| 788 | |
| 789 | /** |
| 790 | * @return proxyProperties for the current global proxy |
| 791 | * {@hide} |
| 792 | */ |
| 793 | public ProxyProperties getGlobalProxy() { |
| 794 | try { |
| 795 | return mService.getGlobalProxy(); |
| 796 | } catch (RemoteException e) { |
| 797 | return null; |
| 798 | } |
| 799 | } |
| 800 | |
| 801 | /** |
| 802 | * @return proxyProperties for the current proxy (global if set, network specific if not) |
| 803 | * {@hide} |
| 804 | */ |
| 805 | public ProxyProperties getProxy() { |
| 806 | try { |
| 807 | return mService.getProxy(); |
| 808 | } catch (RemoteException e) { |
| 809 | return null; |
| 810 | } |
| 811 | } |
Robert Greenwalt | d55a6b4 | 2011-03-25 13:09:25 -0700 | [diff] [blame] | 812 | |
| 813 | /** |
| 814 | * @param networkType The network who's dependence has changed |
| 815 | * @param met Boolean - true if network use is ok, false if not |
| 816 | * {@hide} |
| 817 | */ |
| 818 | public void setDataDependency(int networkType, boolean met) { |
| 819 | try { |
| 820 | mService.setDataDependency(networkType, met); |
| 821 | } catch (RemoteException e) { |
| 822 | } |
| 823 | } |
Robert Greenwalt | 9b2886e | 2011-08-31 11:46:42 -0700 | [diff] [blame] | 824 | |
| 825 | /** |
| 826 | * Returns true if the hardware supports the given network type |
| 827 | * else it returns false. This doesn't indicate we have coverage |
| 828 | * or are authorized onto a network, just whether or not the |
| 829 | * hardware supports it. For example a gsm phone without a sim |
| 830 | * should still return true for mobile data, but a wifi only tablet |
| 831 | * would return false. |
| 832 | * @param networkType The nework type we'd like to check |
| 833 | * @return true if supported, else false |
| 834 | * @hide |
| 835 | */ |
| 836 | public boolean isNetworkSupported(int networkType) { |
| 837 | try { |
| 838 | return mService.isNetworkSupported(networkType); |
| 839 | } catch (RemoteException e) {} |
| 840 | return false; |
| 841 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 842 | } |