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; |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame] | 23 | import android.content.Context; |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 24 | import android.os.Binder; |
Jeff Sharkey | 3a844fc | 2011-08-16 14:37:57 -0700 | [diff] [blame] | 25 | import android.os.Build.VERSION_CODES; |
Robert Greenwalt | 665e1ae | 2012-08-21 19:27:00 -0700 | [diff] [blame] | 26 | import android.os.Messenger; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 27 | import android.os.RemoteException; |
Jeff Sharkey | 961e304 | 2011-08-29 16:02:57 -0700 | [diff] [blame] | 28 | import android.provider.Settings; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 | |
Robert Greenwalt | 585ac0f | 2010-08-27 09:24:29 -0700 | [diff] [blame] | 30 | import java.net.InetAddress; |
Robert Greenwalt | 585ac0f | 2010-08-27 09:24:29 -0700 | [diff] [blame] | 31 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 32 | /** |
| 33 | * Class that answers queries about the state of network connectivity. It also |
| 34 | * notifies applications when network connectivity changes. Get an instance |
| 35 | * of this class by calling |
| 36 | * {@link android.content.Context#getSystemService(String) Context.getSystemService(Context.CONNECTIVITY_SERVICE)}. |
| 37 | * <p> |
| 38 | * The primary responsibilities of this class are to: |
| 39 | * <ol> |
| 40 | * <li>Monitor network connections (Wi-Fi, GPRS, UMTS, etc.)</li> |
| 41 | * <li>Send broadcast intents when network connectivity changes</li> |
| 42 | * <li>Attempt to "fail over" to another network when connectivity to a network |
| 43 | * is lost</li> |
| 44 | * <li>Provide an API that allows applications to query the coarse-grained or fine-grained |
| 45 | * state of the available networks</li> |
| 46 | * </ol> |
| 47 | */ |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 48 | public class ConnectivityManager { |
| 49 | private static final String TAG = "ConnectivityManager"; |
| 50 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | /** |
| 52 | * A change in network connectivity has occurred. A connection has either |
| 53 | * been established or lost. The NetworkInfo for the affected network is |
| 54 | * sent as an extra; it should be consulted to see what kind of |
| 55 | * connectivity event occurred. |
| 56 | * <p/> |
| 57 | * If this is a connection that was the result of failing over from a |
| 58 | * disconnected network, then the FAILOVER_CONNECTION boolean extra is |
| 59 | * set to true. |
| 60 | * <p/> |
| 61 | * For a loss of connectivity, if the connectivity manager is attempting |
| 62 | * to connect (or has already connected) to another network, the |
| 63 | * NetworkInfo for the new network is also passed as an extra. This lets |
| 64 | * any receivers of the broadcast know that they should not necessarily |
| 65 | * tell the user that no data traffic will be possible. Instead, the |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 66 | * receiver should expect another broadcast soon, indicating either that |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 67 | * the failover attempt succeeded (and so there is still overall data |
| 68 | * connectivity), or that the failover attempt failed, meaning that all |
| 69 | * connectivity has been lost. |
| 70 | * <p/> |
| 71 | * For a disconnect event, the boolean extra EXTRA_NO_CONNECTIVITY |
| 72 | * is set to {@code true} if there are no connected networks at all. |
| 73 | */ |
Jeff Sharkey | 4fa63b2 | 2013-02-20 18:21:19 -0800 | [diff] [blame] | 74 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 75 | public static final String CONNECTIVITY_ACTION = "android.net.conn.CONNECTIVITY_CHANGE"; |
Jeff Sharkey | f0ceede | 2011-08-02 17:22:34 -0700 | [diff] [blame] | 76 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 77 | /** |
Jeff Sharkey | 961e304 | 2011-08-29 16:02:57 -0700 | [diff] [blame] | 78 | * Identical to {@link #CONNECTIVITY_ACTION} broadcast, but sent without any |
| 79 | * applicable {@link Settings.Secure#CONNECTIVITY_CHANGE_DELAY}. |
| 80 | * |
| 81 | * @hide |
| 82 | */ |
Jeff Sharkey | 4fa63b2 | 2013-02-20 18:21:19 -0800 | [diff] [blame] | 83 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jeff Sharkey | 961e304 | 2011-08-29 16:02:57 -0700 | [diff] [blame] | 84 | public static final String CONNECTIVITY_ACTION_IMMEDIATE = |
| 85 | "android.net.conn.CONNECTIVITY_CHANGE_IMMEDIATE"; |
| 86 | |
| 87 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 88 | * The lookup key for a {@link NetworkInfo} object. Retrieve with |
| 89 | * {@link android.content.Intent#getParcelableExtra(String)}. |
Jeff Sharkey | f0ceede | 2011-08-02 17:22:34 -0700 | [diff] [blame] | 90 | * |
| 91 | * @deprecated Since {@link NetworkInfo} can vary based on UID, applications |
| 92 | * should always obtain network information through |
| 93 | * {@link #getActiveNetworkInfo()} or |
| 94 | * {@link #getAllNetworkInfo()}. |
Jeff Sharkey | 75fbb4b | 2012-08-06 11:41:50 -0700 | [diff] [blame] | 95 | * @see #EXTRA_NETWORK_TYPE |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 96 | */ |
Jeff Sharkey | f0ceede | 2011-08-02 17:22:34 -0700 | [diff] [blame] | 97 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 98 | public static final String EXTRA_NETWORK_INFO = "networkInfo"; |
Jeff Sharkey | f0ceede | 2011-08-02 17:22:34 -0700 | [diff] [blame] | 99 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 100 | /** |
Jeff Sharkey | 75fbb4b | 2012-08-06 11:41:50 -0700 | [diff] [blame] | 101 | * Network type which triggered a {@link #CONNECTIVITY_ACTION} broadcast. |
| 102 | * Can be used with {@link #getNetworkInfo(int)} to get {@link NetworkInfo} |
| 103 | * state based on the calling application. |
| 104 | * |
| 105 | * @see android.content.Intent#getIntExtra(String, int) |
| 106 | */ |
| 107 | public static final String EXTRA_NETWORK_TYPE = "networkType"; |
| 108 | |
| 109 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 110 | * The lookup key for a boolean that indicates whether a connect event |
| 111 | * is for a network to which the connectivity manager was failing over |
| 112 | * following a disconnect on another network. |
| 113 | * Retrieve it with {@link android.content.Intent#getBooleanExtra(String,boolean)}. |
| 114 | */ |
| 115 | public static final String EXTRA_IS_FAILOVER = "isFailover"; |
| 116 | /** |
| 117 | * The lookup key for a {@link NetworkInfo} object. This is supplied when |
| 118 | * there is another network that it may be possible to connect to. Retrieve with |
| 119 | * {@link android.content.Intent#getParcelableExtra(String)}. |
| 120 | */ |
| 121 | public static final String EXTRA_OTHER_NETWORK_INFO = "otherNetwork"; |
| 122 | /** |
| 123 | * The lookup key for a boolean that indicates whether there is a |
| 124 | * complete lack of connectivity, i.e., no network is available. |
| 125 | * Retrieve it with {@link android.content.Intent#getBooleanExtra(String,boolean)}. |
| 126 | */ |
| 127 | public static final String EXTRA_NO_CONNECTIVITY = "noConnectivity"; |
| 128 | /** |
| 129 | * The lookup key for a string that indicates why an attempt to connect |
| 130 | * to a network failed. The string has no particular structure. It is |
| 131 | * intended to be used in notifications presented to users. Retrieve |
| 132 | * it with {@link android.content.Intent#getStringExtra(String)}. |
| 133 | */ |
| 134 | public static final String EXTRA_REASON = "reason"; |
| 135 | /** |
| 136 | * The lookup key for a string that provides optionally supplied |
| 137 | * extra information about the network state. The information |
| 138 | * may be passed up from the lower networking layers, and its |
| 139 | * meaning may be specific to a particular network type. Retrieve |
| 140 | * it with {@link android.content.Intent#getStringExtra(String)}. |
| 141 | */ |
| 142 | public static final String EXTRA_EXTRA_INFO = "extraInfo"; |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 143 | /** |
| 144 | * The lookup key for an int that provides information about |
| 145 | * our connection to the internet at large. 0 indicates no connection, |
| 146 | * 100 indicates a great connection. Retrieve it with |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 147 | * {@link android.content.Intent#getIntExtra(String, int)}. |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 148 | * {@hide} |
| 149 | */ |
| 150 | public static final String EXTRA_INET_CONDITION = "inetCondition"; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 151 | |
| 152 | /** |
Haoyu Bai | db3c867 | 2012-06-20 14:29:57 -0700 | [diff] [blame] | 153 | * Broadcast action to indicate the change of data activity status |
| 154 | * (idle or active) on a network in a recent period. |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 155 | * The network becomes active when data transmission is started, or |
| 156 | * idle if there is no data transmission for a period of time. |
Haoyu Bai | db3c867 | 2012-06-20 14:29:57 -0700 | [diff] [blame] | 157 | * {@hide} |
| 158 | */ |
| 159 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
| 160 | public static final String ACTION_DATA_ACTIVITY_CHANGE = "android.net.conn.DATA_ACTIVITY_CHANGE"; |
| 161 | /** |
| 162 | * The lookup key for an enum that indicates the network device type on which this data activity |
| 163 | * change happens. |
| 164 | * {@hide} |
| 165 | */ |
| 166 | public static final String EXTRA_DEVICE_TYPE = "deviceType"; |
| 167 | /** |
| 168 | * The lookup key for a boolean that indicates the device is active or not. {@code true} means |
| 169 | * it is actively sending or receiving data and {@code false} means it is idle. |
| 170 | * {@hide} |
| 171 | */ |
| 172 | public static final String EXTRA_IS_ACTIVE = "isActive"; |
| 173 | |
| 174 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 175 | * Broadcast Action: The setting for background data usage has changed |
| 176 | * values. Use {@link #getBackgroundDataSetting()} to get the current value. |
| 177 | * <p> |
| 178 | * If an application uses the network in the background, it should listen |
| 179 | * 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] | 180 | * {@code false}. |
Jeff Sharkey | 54ee2ad | 2012-01-30 16:29:24 -0800 | [diff] [blame] | 181 | * <p> |
| 182 | * |
| 183 | * @deprecated As of {@link VERSION_CODES#ICE_CREAM_SANDWICH}, availability |
| 184 | * of background data depends on several combined factors, and |
| 185 | * this broadcast is no longer sent. Instead, when background |
| 186 | * data is unavailable, {@link #getActiveNetworkInfo()} will now |
| 187 | * appear disconnected. During first boot after a platform |
| 188 | * upgrade, this broadcast will be sent once if |
| 189 | * {@link #getBackgroundDataSetting()} was {@code false} before |
| 190 | * the upgrade. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 191 | */ |
| 192 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Jeff Sharkey | 54ee2ad | 2012-01-30 16:29:24 -0800 | [diff] [blame] | 193 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 194 | public static final String ACTION_BACKGROUND_DATA_SETTING_CHANGED = |
| 195 | "android.net.conn.BACKGROUND_DATA_SETTING_CHANGED"; |
| 196 | |
Robert Greenwalt | 1e9aac2 | 2010-09-15 17:36:33 -0700 | [diff] [blame] | 197 | /** |
| 198 | * Broadcast Action: The network connection may not be good |
| 199 | * uses {@code ConnectivityManager.EXTRA_INET_CONDITION} and |
| 200 | * {@code ConnectivityManager.EXTRA_NETWORK_INFO} to specify |
| 201 | * the network and it's condition. |
| 202 | * @hide |
| 203 | */ |
Jeff Sharkey | 4fa63b2 | 2013-02-20 18:21:19 -0800 | [diff] [blame] | 204 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Robert Greenwalt | 1e9aac2 | 2010-09-15 17:36:33 -0700 | [diff] [blame] | 205 | public static final String INET_CONDITION_ACTION = |
| 206 | "android.net.conn.INET_CONDITION_ACTION"; |
| 207 | |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 208 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 209 | * Broadcast Action: A tetherable connection has come or gone. |
| 210 | * Uses {@code ConnectivityManager.EXTRA_AVAILABLE_TETHER}, |
| 211 | * {@code ConnectivityManager.EXTRA_ACTIVE_TETHER} and |
| 212 | * {@code ConnectivityManager.EXTRA_ERRORED_TETHER} to indicate |
| 213 | * the current state of tethering. Each include a list of |
| 214 | * interface names in that state (may be empty). |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 215 | * @hide |
| 216 | */ |
Jeff Sharkey | 4fa63b2 | 2013-02-20 18:21:19 -0800 | [diff] [blame] | 217 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 218 | public static final String ACTION_TETHER_STATE_CHANGED = |
| 219 | "android.net.conn.TETHER_STATE_CHANGED"; |
| 220 | |
| 221 | /** |
| 222 | * @hide |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 223 | * gives a String[] listing all the interfaces configured for |
| 224 | * tethering and currently available for tethering. |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 225 | */ |
Robert Greenwalt | 2a091d7 | 2010-02-11 18:18:40 -0800 | [diff] [blame] | 226 | public static final String EXTRA_AVAILABLE_TETHER = "availableArray"; |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 227 | |
| 228 | /** |
| 229 | * @hide |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 230 | * gives a String[] listing all the interfaces currently tethered |
| 231 | * (ie, has dhcp support and packets potentially forwarded/NATed) |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 232 | */ |
Robert Greenwalt | 2a091d7 | 2010-02-11 18:18:40 -0800 | [diff] [blame] | 233 | public static final String EXTRA_ACTIVE_TETHER = "activeArray"; |
| 234 | |
| 235 | /** |
| 236 | * @hide |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 237 | * gives a String[] listing all the interfaces we tried to tether and |
| 238 | * failed. Use {@link #getLastTetherError} to find the error code |
| 239 | * for any interfaces listed here. |
Robert Greenwalt | 2a091d7 | 2010-02-11 18:18:40 -0800 | [diff] [blame] | 240 | */ |
| 241 | public static final String EXTRA_ERRORED_TETHER = "erroredArray"; |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 242 | |
| 243 | /** |
Russell Brenner | 108da0c | 2013-02-12 10:03:14 -0800 | [diff] [blame] | 244 | * Broadcast Action: The captive portal tracker has finished its test. |
| 245 | * Sent only while running Setup Wizard, in lieu of showing a user |
| 246 | * notification. |
| 247 | * @hide |
| 248 | */ |
Jeff Sharkey | 4fa63b2 | 2013-02-20 18:21:19 -0800 | [diff] [blame] | 249 | @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) |
Russell Brenner | 108da0c | 2013-02-12 10:03:14 -0800 | [diff] [blame] | 250 | public static final String ACTION_CAPTIVE_PORTAL_TEST_COMPLETED = |
| 251 | "android.net.conn.CAPTIVE_PORTAL_TEST_COMPLETED"; |
| 252 | /** |
| 253 | * The lookup key for a boolean that indicates whether a captive portal was detected. |
| 254 | * Retrieve it with {@link android.content.Intent#getBooleanExtra(String,boolean)}. |
| 255 | * @hide |
| 256 | */ |
| 257 | public static final String EXTRA_IS_CAPTIVE_PORTAL = "captivePortal"; |
| 258 | |
| 259 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 260 | * The absence of a connection type. |
Robert Greenwalt | ccf83af1 | 2011-06-02 17:30:47 -0700 | [diff] [blame] | 261 | * @hide |
| 262 | */ |
| 263 | public static final int TYPE_NONE = -1; |
| 264 | |
| 265 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 266 | * The Mobile data connection. When active, all data traffic |
| 267 | * will use this network type's interface by default |
| 268 | * (it has a default route) |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 269 | */ |
| 270 | public static final int TYPE_MOBILE = 0; |
| 271 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 272 | * The WIFI data connection. When active, all data traffic |
| 273 | * will use this network type's interface by default |
| 274 | * (it has a default route). |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 275 | */ |
| 276 | public static final int TYPE_WIFI = 1; |
| 277 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 278 | * An MMS-specific Mobile data connection. This network type may use the |
| 279 | * same network interface as {@link #TYPE_MOBILE} or it may use a different |
| 280 | * one. This is used by applications needing to talk to the carrier's |
| 281 | * Multimedia Messaging Service servers. |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 282 | */ |
| 283 | public static final int TYPE_MOBILE_MMS = 2; |
| 284 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 285 | * A SUPL-specific Mobile data connection. This network type may use the |
| 286 | * same network interface as {@link #TYPE_MOBILE} or it may use a different |
| 287 | * one. This is used by applications needing to talk to the carrier's |
| 288 | * Secure User Plane Location servers for help locating the device. |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 289 | */ |
| 290 | public static final int TYPE_MOBILE_SUPL = 3; |
| 291 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 292 | * A DUN-specific Mobile data connection. This network type may use the |
| 293 | * same network interface as {@link #TYPE_MOBILE} or it may use a different |
| 294 | * one. This is sometimes by the system when setting up an upstream connection |
| 295 | * for tethering so that the carrier is aware of DUN traffic. |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 296 | */ |
| 297 | public static final int TYPE_MOBILE_DUN = 4; |
| 298 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 299 | * A High Priority Mobile data connection. This network type uses the |
| 300 | * same network interface as {@link #TYPE_MOBILE} but the routing setup |
| 301 | * is different. Only requesting processes will have access to the |
| 302 | * Mobile DNS servers and only IP's explicitly requested via {@link #requestRouteToHost} |
| 303 | * will route over this interface if no default route exists. |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 304 | */ |
| 305 | public static final int TYPE_MOBILE_HIPRI = 5; |
jsh | 8214deb | 2010-03-11 15:04:43 -0800 | [diff] [blame] | 306 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 307 | * The WiMAX data connection. When active, all data traffic |
| 308 | * will use this network type's interface by default |
| 309 | * (it has a default route). |
jsh | 8214deb | 2010-03-11 15:04:43 -0800 | [diff] [blame] | 310 | */ |
| 311 | public static final int TYPE_WIMAX = 6; |
Robert Greenwalt | da3d5e6 | 2010-12-06 13:56:24 -0800 | [diff] [blame] | 312 | |
Jaikumar Ganesh | 15c7439 | 2010-12-21 22:31:44 -0800 | [diff] [blame] | 313 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 314 | * The Bluetooth data connection. When active, all data traffic |
| 315 | * will use this network type's interface by default |
| 316 | * (it has a default route). |
Jaikumar Ganesh | 15c7439 | 2010-12-21 22:31:44 -0800 | [diff] [blame] | 317 | */ |
| 318 | public static final int TYPE_BLUETOOTH = 7; |
| 319 | |
Robert Greenwalt | 6081084 | 2011-04-22 15:28:18 -0700 | [diff] [blame] | 320 | /** |
| 321 | * Dummy data connection. This should not be used on shipping devices. |
| 322 | */ |
Jaikumar Ganesh | 15c7439 | 2010-12-21 22:31:44 -0800 | [diff] [blame] | 323 | public static final int TYPE_DUMMY = 8; |
Wink Saville | 9d7d628 | 2011-03-12 14:52:01 -0800 | [diff] [blame] | 324 | |
Robert Greenwalt | 6081084 | 2011-04-22 15:28:18 -0700 | [diff] [blame] | 325 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 326 | * The Ethernet data connection. When active, all data traffic |
| 327 | * will use this network type's interface by default |
| 328 | * (it has a default route). |
Robert Greenwalt | 6081084 | 2011-04-22 15:28:18 -0700 | [diff] [blame] | 329 | */ |
Robert Greenwalt | e12aec9 | 2011-01-28 14:48:37 -0800 | [diff] [blame] | 330 | public static final int TYPE_ETHERNET = 9; |
Robert Greenwalt | 6081084 | 2011-04-22 15:28:18 -0700 | [diff] [blame] | 331 | |
Wink Saville | 9d7d628 | 2011-03-12 14:52:01 -0800 | [diff] [blame] | 332 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 333 | * Over the air Administration. |
Wink Saville | 9d7d628 | 2011-03-12 14:52:01 -0800 | [diff] [blame] | 334 | * {@hide} |
| 335 | */ |
| 336 | public static final int TYPE_MOBILE_FOTA = 10; |
| 337 | |
| 338 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 339 | * IP Multimedia Subsystem. |
Wink Saville | 9d7d628 | 2011-03-12 14:52:01 -0800 | [diff] [blame] | 340 | * {@hide} |
| 341 | */ |
| 342 | public static final int TYPE_MOBILE_IMS = 11; |
| 343 | |
| 344 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 345 | * Carrier Branded Services. |
Wink Saville | 9d7d628 | 2011-03-12 14:52:01 -0800 | [diff] [blame] | 346 | * {@hide} |
| 347 | */ |
| 348 | public static final int TYPE_MOBILE_CBS = 12; |
| 349 | |
repo sync | aea743a | 2011-07-29 23:55:49 -0700 | [diff] [blame] | 350 | /** |
| 351 | * A Wi-Fi p2p connection. Only requesting processes will have access to |
| 352 | * the peers connected. |
| 353 | * {@hide} |
| 354 | */ |
| 355 | public static final int TYPE_WIFI_P2P = 13; |
Wink Saville | 9d7d628 | 2011-03-12 14:52:01 -0800 | [diff] [blame] | 356 | |
Wink Saville | 5e56bc5 | 2013-07-29 15:00:57 -0700 | [diff] [blame] | 357 | /** |
| 358 | * The network to use for initially attaching to the network |
| 359 | * {@hide} |
| 360 | */ |
| 361 | public static final int TYPE_MOBILE_IA = 14; |
repo sync | aea743a | 2011-07-29 23:55:49 -0700 | [diff] [blame] | 362 | |
Hui Lu | 1c5624a | 2014-01-15 11:05:36 -0500 | [diff] [blame] | 363 | /** |
| 364 | * The network that uses proxy to achieve connectivity. |
| 365 | * {@hide} |
| 366 | */ |
| 367 | public static final int TYPE_PROXY = 16; |
Wink Saville | 5e56bc5 | 2013-07-29 15:00:57 -0700 | [diff] [blame] | 368 | |
| 369 | /** {@hide} */ |
Hui Lu | 1c5624a | 2014-01-15 11:05:36 -0500 | [diff] [blame] | 370 | public static final int MAX_RADIO_TYPE = TYPE_PROXY; |
| 371 | |
| 372 | /** {@hide} */ |
| 373 | public static final int MAX_NETWORK_TYPE = TYPE_PROXY; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 374 | |
Jianzheng Zhou | dcf03f3 | 2012-11-16 13:45:20 +0800 | [diff] [blame] | 375 | /** |
| 376 | * If you want to set the default network preference,you can directly |
| 377 | * change the networkAttributes array in framework's config.xml. |
| 378 | * |
| 379 | * @deprecated Since we support so many more networks now, the single |
| 380 | * network default network preference can't really express |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 381 | * the hierarchy. Instead, the default is defined by the |
Jianzheng Zhou | dcf03f3 | 2012-11-16 13:45:20 +0800 | [diff] [blame] | 382 | * networkAttributes in config.xml. You can determine |
Robert Greenwalt | 4c8b748 | 2012-12-07 09:56:50 -0800 | [diff] [blame] | 383 | * the current value by calling {@link #getNetworkPreference()} |
Jianzheng Zhou | dcf03f3 | 2012-11-16 13:45:20 +0800 | [diff] [blame] | 384 | * from an App. |
| 385 | */ |
| 386 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 387 | public static final int DEFAULT_NETWORK_PREFERENCE = TYPE_WIFI; |
| 388 | |
Jeff Sharkey | 625239a | 2012-09-26 22:03:49 -0700 | [diff] [blame] | 389 | /** |
| 390 | * Default value for {@link Settings.Global#CONNECTIVITY_CHANGE_DELAY} in |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 391 | * milliseconds. This was introduced because IPv6 routes seem to take a |
| 392 | * moment to settle - trying network activity before the routes are adjusted |
| 393 | * can lead to packets using the wrong interface or having the wrong IP address. |
| 394 | * This delay is a bit crude, but in the future hopefully we will have kernel |
| 395 | * notifications letting us know when it's safe to use the new network. |
Jeff Sharkey | 625239a | 2012-09-26 22:03:49 -0700 | [diff] [blame] | 396 | * |
| 397 | * @hide |
| 398 | */ |
| 399 | public static final int CONNECTIVITY_CHANGE_DELAY_DEFAULT = 3000; |
| 400 | |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 401 | private final IConnectivityManager mService; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 402 | |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 403 | /** |
| 404 | * Tests if a given integer represents a valid network type. |
| 405 | * @param networkType the type to be tested |
| 406 | * @return a boolean. {@code true} if the type is valid, else {@code false} |
| 407 | */ |
Jeff Sharkey | d2a4587 | 2011-05-28 20:56:34 -0700 | [diff] [blame] | 408 | public static boolean isNetworkTypeValid(int networkType) { |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 409 | return networkType >= 0 && networkType <= MAX_NETWORK_TYPE; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 410 | } |
| 411 | |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 412 | /** |
| 413 | * Returns a non-localized string representing a given network type. |
| 414 | * ONLY used for debugging output. |
| 415 | * @param type the type needing naming |
| 416 | * @return a String for the given type, or a string version of the type ("87") |
| 417 | * if no name is known. |
| 418 | * {@hide} |
| 419 | */ |
Jeff Sharkey | d2a4587 | 2011-05-28 20:56:34 -0700 | [diff] [blame] | 420 | public static String getNetworkTypeName(int type) { |
| 421 | switch (type) { |
| 422 | case TYPE_MOBILE: |
| 423 | return "MOBILE"; |
| 424 | case TYPE_WIFI: |
| 425 | return "WIFI"; |
| 426 | case TYPE_MOBILE_MMS: |
| 427 | return "MOBILE_MMS"; |
| 428 | case TYPE_MOBILE_SUPL: |
| 429 | return "MOBILE_SUPL"; |
| 430 | case TYPE_MOBILE_DUN: |
| 431 | return "MOBILE_DUN"; |
| 432 | case TYPE_MOBILE_HIPRI: |
| 433 | return "MOBILE_HIPRI"; |
| 434 | case TYPE_WIMAX: |
| 435 | return "WIMAX"; |
| 436 | case TYPE_BLUETOOTH: |
| 437 | return "BLUETOOTH"; |
| 438 | case TYPE_DUMMY: |
| 439 | return "DUMMY"; |
| 440 | case TYPE_ETHERNET: |
| 441 | return "ETHERNET"; |
| 442 | case TYPE_MOBILE_FOTA: |
| 443 | return "MOBILE_FOTA"; |
| 444 | case TYPE_MOBILE_IMS: |
| 445 | return "MOBILE_IMS"; |
| 446 | case TYPE_MOBILE_CBS: |
| 447 | return "MOBILE_CBS"; |
repo sync | aea743a | 2011-07-29 23:55:49 -0700 | [diff] [blame] | 448 | case TYPE_WIFI_P2P: |
| 449 | return "WIFI_P2P"; |
Wink Saville | 5e56bc5 | 2013-07-29 15:00:57 -0700 | [diff] [blame] | 450 | case TYPE_MOBILE_IA: |
| 451 | return "MOBILE_IA"; |
Hui Lu | 1c5624a | 2014-01-15 11:05:36 -0500 | [diff] [blame] | 452 | case TYPE_PROXY: |
| 453 | return "PROXY"; |
Jeff Sharkey | d2a4587 | 2011-05-28 20:56:34 -0700 | [diff] [blame] | 454 | default: |
| 455 | return Integer.toString(type); |
| 456 | } |
| 457 | } |
| 458 | |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 459 | /** |
| 460 | * Checks if a given type uses the cellular data connection. |
| 461 | * This should be replaced in the future by a network property. |
| 462 | * @param networkType the type to check |
| 463 | * @return a boolean - {@code true} if uses cellular network, else {@code false} |
| 464 | * {@hide} |
| 465 | */ |
Jeff Sharkey | d2a4587 | 2011-05-28 20:56:34 -0700 | [diff] [blame] | 466 | public static boolean isNetworkTypeMobile(int networkType) { |
| 467 | switch (networkType) { |
| 468 | case TYPE_MOBILE: |
| 469 | case TYPE_MOBILE_MMS: |
| 470 | case TYPE_MOBILE_SUPL: |
| 471 | case TYPE_MOBILE_DUN: |
| 472 | case TYPE_MOBILE_HIPRI: |
| 473 | case TYPE_MOBILE_FOTA: |
| 474 | case TYPE_MOBILE_IMS: |
| 475 | case TYPE_MOBILE_CBS: |
Wink Saville | 5e56bc5 | 2013-07-29 15:00:57 -0700 | [diff] [blame] | 476 | case TYPE_MOBILE_IA: |
Jeff Sharkey | d2a4587 | 2011-05-28 20:56:34 -0700 | [diff] [blame] | 477 | return true; |
| 478 | default: |
| 479 | return false; |
| 480 | } |
| 481 | } |
| 482 | |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 483 | /** |
Jeff Sharkey | 7a1c3fc | 2013-06-04 12:29:00 -0700 | [diff] [blame] | 484 | * Checks if the given network type is backed by a Wi-Fi radio. |
| 485 | * |
| 486 | * @hide |
| 487 | */ |
| 488 | public static boolean isNetworkTypeWifi(int networkType) { |
| 489 | switch (networkType) { |
| 490 | case TYPE_WIFI: |
| 491 | case TYPE_WIFI_P2P: |
| 492 | return true; |
| 493 | default: |
| 494 | return false; |
| 495 | } |
| 496 | } |
| 497 | |
| 498 | /** |
Chad Brubaker | f336d72 | 2013-07-15 16:34:04 -0700 | [diff] [blame] | 499 | * Checks if the given network type should be exempt from VPN routing rules |
| 500 | * |
| 501 | * @hide |
| 502 | */ |
| 503 | public static boolean isNetworkTypeExempt(int networkType) { |
| 504 | switch (networkType) { |
| 505 | case TYPE_MOBILE_MMS: |
| 506 | case TYPE_MOBILE_SUPL: |
| 507 | case TYPE_MOBILE_HIPRI: |
Wink Saville | 5e56bc5 | 2013-07-29 15:00:57 -0700 | [diff] [blame] | 508 | case TYPE_MOBILE_IA: |
Chad Brubaker | f336d72 | 2013-07-15 16:34:04 -0700 | [diff] [blame] | 509 | return true; |
| 510 | default: |
| 511 | return false; |
| 512 | } |
| 513 | } |
| 514 | |
| 515 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 516 | * Specifies the preferred network type. When the device has more |
| 517 | * than one type available the preferred network type will be used. |
| 518 | * Note that this made sense when we only had 2 network types, |
| 519 | * but with more and more default networks we need an array to list |
| 520 | * their ordering. This will be deprecated soon. |
| 521 | * |
| 522 | * @param preference the network type to prefer over all others. It is |
| 523 | * unspecified what happens to the old preferred network in the |
| 524 | * overall ordering. |
| 525 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 526 | public void setNetworkPreference(int preference) { |
| 527 | try { |
| 528 | mService.setNetworkPreference(preference); |
| 529 | } catch (RemoteException e) { |
| 530 | } |
| 531 | } |
| 532 | |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 533 | /** |
| 534 | * Retrieves the current preferred network type. |
| 535 | * Note that this made sense when we only had 2 network types, |
| 536 | * but with more and more default networks we need an array to list |
| 537 | * their ordering. This will be deprecated soon. |
| 538 | * |
| 539 | * @return an integer representing the preferred network type |
| 540 | * |
| 541 | * <p>This method requires the caller to hold the permission |
| 542 | * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. |
| 543 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 544 | public int getNetworkPreference() { |
| 545 | try { |
| 546 | return mService.getNetworkPreference(); |
| 547 | } catch (RemoteException e) { |
| 548 | return -1; |
| 549 | } |
| 550 | } |
| 551 | |
Scott Main | 671644c | 2011-10-06 19:02:28 -0700 | [diff] [blame] | 552 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 553 | * Returns details about the currently active default data network. When |
| 554 | * connected, this network is the default route for outgoing connections. |
| 555 | * You should always check {@link NetworkInfo#isConnected()} before initiating |
| 556 | * network traffic. This may return {@code null} when there is no default |
| 557 | * network. |
| 558 | * |
| 559 | * @return a {@link NetworkInfo} object for the current default network |
| 560 | * or {@code null} if no network default network is currently active |
| 561 | * |
| 562 | * <p>This method requires the call to hold the permission |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 563 | * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. |
Jeff Sharkey | 9f7cbf0 | 2012-04-12 18:34:54 -0700 | [diff] [blame] | 564 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 565 | public NetworkInfo getActiveNetworkInfo() { |
| 566 | try { |
| 567 | return mService.getActiveNetworkInfo(); |
| 568 | } catch (RemoteException e) { |
| 569 | return null; |
| 570 | } |
| 571 | } |
| 572 | |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 573 | /** |
| 574 | * Returns details about the currently active default data network |
| 575 | * for a given uid. This is for internal use only to avoid spying |
| 576 | * other apps. |
| 577 | * |
| 578 | * @return a {@link NetworkInfo} object for the current default network |
| 579 | * for the given uid or {@code null} if no default network is |
| 580 | * available for the specified uid. |
| 581 | * |
| 582 | * <p>This method requires the caller to hold the permission |
| 583 | * {@link android.Manifest.permission#CONNECTIVITY_INTERNAL} |
| 584 | * {@hide} |
| 585 | */ |
Jeff Sharkey | c006f1a | 2011-05-19 17:12:49 -0700 | [diff] [blame] | 586 | public NetworkInfo getActiveNetworkInfoForUid(int uid) { |
| 587 | try { |
| 588 | return mService.getActiveNetworkInfoForUid(uid); |
| 589 | } catch (RemoteException e) { |
| 590 | return null; |
| 591 | } |
| 592 | } |
| 593 | |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 594 | /** |
| 595 | * Returns connection status information about a particular |
| 596 | * network type. |
| 597 | * |
| 598 | * @param networkType integer specifying which networkType in |
| 599 | * which you're interested. |
| 600 | * @return a {@link NetworkInfo} object for the requested |
| 601 | * network type or {@code null} if the type is not |
| 602 | * supported by the device. |
| 603 | * |
| 604 | * <p>This method requires the call to hold the permission |
| 605 | * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. |
| 606 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 607 | public NetworkInfo getNetworkInfo(int networkType) { |
| 608 | try { |
| 609 | return mService.getNetworkInfo(networkType); |
| 610 | } catch (RemoteException e) { |
| 611 | return null; |
| 612 | } |
| 613 | } |
| 614 | |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 615 | /** |
| 616 | * Returns connection status information about all network |
| 617 | * types supported by the device. |
| 618 | * |
| 619 | * @return an array of {@link NetworkInfo} objects. Check each |
| 620 | * {@link NetworkInfo#getType} for which type each applies. |
| 621 | * |
| 622 | * <p>This method requires the call to hold the permission |
| 623 | * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. |
| 624 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 625 | public NetworkInfo[] getAllNetworkInfo() { |
| 626 | try { |
| 627 | return mService.getAllNetworkInfo(); |
| 628 | } catch (RemoteException e) { |
| 629 | return null; |
| 630 | } |
| 631 | } |
| 632 | |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 633 | /** |
Wink Saville | 948282b | 2013-08-29 08:55:16 -0700 | [diff] [blame] | 634 | * Returns details about the Provisioning or currently active default data network. When |
| 635 | * connected, this network is the default route for outgoing connections. |
| 636 | * You should always check {@link NetworkInfo#isConnected()} before initiating |
| 637 | * network traffic. This may return {@code null} when there is no default |
| 638 | * network. |
| 639 | * |
| 640 | * @return a {@link NetworkInfo} object for the current default network |
| 641 | * or {@code null} if no network default network is currently active |
| 642 | * |
| 643 | * <p>This method requires the call to hold the permission |
| 644 | * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. |
| 645 | * |
| 646 | * {@hide} |
| 647 | */ |
| 648 | public NetworkInfo getProvisioningOrActiveNetworkInfo() { |
| 649 | try { |
| 650 | return mService.getProvisioningOrActiveNetworkInfo(); |
| 651 | } catch (RemoteException e) { |
| 652 | return null; |
| 653 | } |
| 654 | } |
| 655 | |
| 656 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 657 | * Returns the IP information for the current default network. |
| 658 | * |
| 659 | * @return a {@link LinkProperties} object describing the IP info |
| 660 | * for the current default network, or {@code null} if there |
| 661 | * is no current default network. |
| 662 | * |
| 663 | * <p>This method requires the call to hold the permission |
| 664 | * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. |
| 665 | * {@hide} |
| 666 | */ |
Robert Greenwalt | d192dad | 2010-09-14 09:18:02 -0700 | [diff] [blame] | 667 | public LinkProperties getActiveLinkProperties() { |
| 668 | try { |
| 669 | return mService.getActiveLinkProperties(); |
| 670 | } catch (RemoteException e) { |
| 671 | return null; |
| 672 | } |
| 673 | } |
| 674 | |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 675 | /** |
| 676 | * Returns the IP information for a given network type. |
| 677 | * |
| 678 | * @param networkType the network type of interest. |
| 679 | * @return a {@link LinkProperties} object describing the IP info |
| 680 | * for the given networkType, or {@code null} if there is |
| 681 | * no current default network. |
| 682 | * |
| 683 | * <p>This method requires the call to hold the permission |
| 684 | * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. |
| 685 | * {@hide} |
| 686 | */ |
Robert Greenwalt | d192dad | 2010-09-14 09:18:02 -0700 | [diff] [blame] | 687 | public LinkProperties getLinkProperties(int networkType) { |
| 688 | try { |
| 689 | return mService.getLinkProperties(networkType); |
| 690 | } catch (RemoteException e) { |
| 691 | return null; |
| 692 | } |
| 693 | } |
| 694 | |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 695 | /** |
| 696 | * Tells each network type to set its radio power state as directed. |
| 697 | * |
| 698 | * @param turnOn a boolean, {@code true} to turn the radios on, |
| 699 | * {@code false} to turn them off. |
| 700 | * @return a boolean, {@code true} indicating success. All network types |
| 701 | * will be tried, even if some fail. |
| 702 | * |
| 703 | * <p>This method requires the call to hold the permission |
| 704 | * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}. |
| 705 | * {@hide} |
| 706 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 707 | public boolean setRadios(boolean turnOn) { |
| 708 | try { |
| 709 | return mService.setRadios(turnOn); |
| 710 | } catch (RemoteException e) { |
| 711 | return false; |
| 712 | } |
| 713 | } |
| 714 | |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 715 | /** |
| 716 | * Tells a given networkType to set its radio power state as directed. |
| 717 | * |
| 718 | * @param networkType the int networkType of interest. |
| 719 | * @param turnOn a boolean, {@code true} to turn the radio on, |
| 720 | * {@code} false to turn it off. |
| 721 | * @return a boolean, {@code true} indicating success. |
| 722 | * |
| 723 | * <p>This method requires the call to hold the permission |
| 724 | * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}. |
| 725 | * {@hide} |
| 726 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 727 | public boolean setRadio(int networkType, boolean turnOn) { |
| 728 | try { |
| 729 | return mService.setRadio(networkType, turnOn); |
| 730 | } catch (RemoteException e) { |
| 731 | return false; |
| 732 | } |
| 733 | } |
| 734 | |
| 735 | /** |
| 736 | * Tells the underlying networking system that the caller wants to |
| 737 | * begin using the named feature. The interpretation of {@code feature} |
| 738 | * is completely up to each networking implementation. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 739 | * <p>This method requires the caller to hold the permission |
| 740 | * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 741 | * @param networkType specifies which network the request pertains to |
| 742 | * @param feature the name of the feature to be used |
| 743 | * @return an integer value representing the outcome of the request. |
| 744 | * The interpretation of this value is specific to each networking |
| 745 | * implementation+feature combination, except that the value {@code -1} |
| 746 | * always indicates failure. |
| 747 | */ |
| 748 | public int startUsingNetworkFeature(int networkType, String feature) { |
| 749 | try { |
Robert Greenwalt | 42acef3 | 2009-08-12 16:08:25 -0700 | [diff] [blame] | 750 | return mService.startUsingNetworkFeature(networkType, feature, |
| 751 | new Binder()); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 752 | } catch (RemoteException e) { |
| 753 | return -1; |
| 754 | } |
| 755 | } |
| 756 | |
| 757 | /** |
| 758 | * Tells the underlying networking system that the caller is finished |
| 759 | * using the named feature. The interpretation of {@code feature} |
| 760 | * is completely up to each networking implementation. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 761 | * <p>This method requires the caller to hold the permission |
| 762 | * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 763 | * @param networkType specifies which network the request pertains to |
| 764 | * @param feature the name of the feature that is no longer needed |
| 765 | * @return an integer value representing the outcome of the request. |
| 766 | * The interpretation of this value is specific to each networking |
| 767 | * implementation+feature combination, except that the value {@code -1} |
| 768 | * always indicates failure. |
| 769 | */ |
| 770 | public int stopUsingNetworkFeature(int networkType, String feature) { |
| 771 | try { |
| 772 | return mService.stopUsingNetworkFeature(networkType, feature); |
| 773 | } catch (RemoteException e) { |
| 774 | return -1; |
| 775 | } |
| 776 | } |
| 777 | |
| 778 | /** |
| 779 | * Ensure that a network route exists to deliver traffic to the specified |
| 780 | * host via the specified network interface. An attempt to add a route that |
| 781 | * already exists is ignored, but treated as successful. |
Nicolas Falliere | 9530e3a | 2012-06-18 17:21:06 -0700 | [diff] [blame] | 782 | * <p>This method requires the caller to hold the permission |
| 783 | * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 784 | * @param networkType the type of the network over which traffic to the specified |
| 785 | * host is to be routed |
| 786 | * @param hostAddress the IP address of the host to which the route is desired |
| 787 | * @return {@code true} on success, {@code false} on failure |
| 788 | */ |
| 789 | public boolean requestRouteToHost(int networkType, int hostAddress) { |
Robert Greenwalt | 585ac0f | 2010-08-27 09:24:29 -0700 | [diff] [blame] | 790 | InetAddress inetAddress = NetworkUtils.intToInetAddress(hostAddress); |
| 791 | |
| 792 | if (inetAddress == null) { |
| 793 | return false; |
| 794 | } |
| 795 | |
| 796 | return requestRouteToHostAddress(networkType, inetAddress); |
| 797 | } |
| 798 | |
| 799 | /** |
| 800 | * Ensure that a network route exists to deliver traffic to the specified |
| 801 | * host via the specified network interface. An attempt to add a route that |
| 802 | * already exists is ignored, but treated as successful. |
Jake Hamby | 8f9b33e | 2014-01-15 13:08:03 -0800 | [diff] [blame] | 803 | * <p>This method requires the caller to hold the permission |
| 804 | * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}. |
Robert Greenwalt | 585ac0f | 2010-08-27 09:24:29 -0700 | [diff] [blame] | 805 | * @param networkType the type of the network over which traffic to the specified |
| 806 | * host is to be routed |
| 807 | * @param hostAddress the IP address of the host to which the route is desired |
| 808 | * @return {@code true} on success, {@code false} on failure |
| 809 | * @hide |
| 810 | */ |
| 811 | public boolean requestRouteToHostAddress(int networkType, InetAddress hostAddress) { |
| 812 | byte[] address = hostAddress.getAddress(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 813 | try { |
Robert Greenwalt | 585ac0f | 2010-08-27 09:24:29 -0700 | [diff] [blame] | 814 | return mService.requestRouteToHostAddress(networkType, address); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 815 | } catch (RemoteException e) { |
| 816 | return false; |
| 817 | } |
| 818 | } |
| 819 | |
| 820 | /** |
| 821 | * Returns the value of the setting for background data usage. If false, |
| 822 | * applications should not use the network if the application is not in the |
| 823 | * foreground. Developers should respect this setting, and check the value |
| 824 | * of this before performing any background data operations. |
| 825 | * <p> |
| 826 | * All applications that have background services that use the network |
| 827 | * should listen to {@link #ACTION_BACKGROUND_DATA_SETTING_CHANGED}. |
Jeff Sharkey | 3a844fc | 2011-08-16 14:37:57 -0700 | [diff] [blame] | 828 | * <p> |
Scott Main | 4cc5333 | 2011-10-06 18:32:43 -0700 | [diff] [blame] | 829 | * @deprecated As of {@link VERSION_CODES#ICE_CREAM_SANDWICH}, availability of |
Jeff Sharkey | 3a844fc | 2011-08-16 14:37:57 -0700 | [diff] [blame] | 830 | * background data depends on several combined factors, and this method will |
| 831 | * always return {@code true}. Instead, when background data is unavailable, |
| 832 | * {@link #getActiveNetworkInfo()} will now appear disconnected. |
Danica Chang | 6fdd0c6 | 2010-08-11 14:54:43 -0700 | [diff] [blame] | 833 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 834 | * @return Whether background data usage is allowed. |
| 835 | */ |
Jeff Sharkey | 3a844fc | 2011-08-16 14:37:57 -0700 | [diff] [blame] | 836 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 837 | public boolean getBackgroundDataSetting() { |
Jeff Sharkey | 3a844fc | 2011-08-16 14:37:57 -0700 | [diff] [blame] | 838 | // assume that background data is allowed; final authority is |
| 839 | // NetworkInfo which may be blocked. |
| 840 | return true; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 841 | } |
| 842 | |
| 843 | /** |
| 844 | * Sets the value of the setting for background data usage. |
Robert Greenwalt | c03fa50 | 2010-02-23 18:58:05 -0800 | [diff] [blame] | 845 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 846 | * @param allowBackgroundData Whether an application should use data while |
| 847 | * it is in the background. |
Robert Greenwalt | c03fa50 | 2010-02-23 18:58:05 -0800 | [diff] [blame] | 848 | * |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 849 | * @attr ref android.Manifest.permission#CHANGE_BACKGROUND_DATA_SETTING |
| 850 | * @see #getBackgroundDataSetting() |
| 851 | * @hide |
| 852 | */ |
Jeff Sharkey | 3a844fc | 2011-08-16 14:37:57 -0700 | [diff] [blame] | 853 | @Deprecated |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 854 | public void setBackgroundDataSetting(boolean allowBackgroundData) { |
Jeff Sharkey | 3a844fc | 2011-08-16 14:37:57 -0700 | [diff] [blame] | 855 | // ignored |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 856 | } |
Robert Greenwalt | c03fa50 | 2010-02-23 18:58:05 -0800 | [diff] [blame] | 857 | |
| 858 | /** |
Jeff Sharkey | f0ceede | 2011-08-02 17:22:34 -0700 | [diff] [blame] | 859 | * Return quota status for the current active network, or {@code null} if no |
| 860 | * network is active. Quota status can change rapidly, so these values |
| 861 | * shouldn't be cached. |
Jeff Sharkey | 44a3e0d | 2011-10-06 10:50:09 -0700 | [diff] [blame] | 862 | * |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 863 | * <p>This method requires the call to hold the permission |
| 864 | * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. |
| 865 | * |
Jeff Sharkey | 44a3e0d | 2011-10-06 10:50:09 -0700 | [diff] [blame] | 866 | * @hide |
Jeff Sharkey | f0ceede | 2011-08-02 17:22:34 -0700 | [diff] [blame] | 867 | */ |
| 868 | public NetworkQuotaInfo getActiveNetworkQuotaInfo() { |
| 869 | try { |
| 870 | return mService.getActiveNetworkQuotaInfo(); |
| 871 | } catch (RemoteException e) { |
| 872 | return null; |
| 873 | } |
| 874 | } |
| 875 | |
| 876 | /** |
Robert Greenwalt | c03fa50 | 2010-02-23 18:58:05 -0800 | [diff] [blame] | 877 | * Gets the value of the setting for enabling Mobile data. |
| 878 | * |
| 879 | * @return Whether mobile data is enabled. |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 880 | * |
| 881 | * <p>This method requires the call to hold the permission |
| 882 | * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. |
Robert Greenwalt | c03fa50 | 2010-02-23 18:58:05 -0800 | [diff] [blame] | 883 | * @hide |
| 884 | */ |
| 885 | public boolean getMobileDataEnabled() { |
| 886 | try { |
| 887 | return mService.getMobileDataEnabled(); |
| 888 | } catch (RemoteException e) { |
| 889 | return true; |
| 890 | } |
| 891 | } |
| 892 | |
| 893 | /** |
| 894 | * Sets the persisted value for enabling/disabling Mobile data. |
| 895 | * |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 896 | * @param enabled Whether the user wants the mobile data connection used |
| 897 | * or not. |
Robert Greenwalt | c03fa50 | 2010-02-23 18:58:05 -0800 | [diff] [blame] | 898 | * @hide |
| 899 | */ |
| 900 | public void setMobileDataEnabled(boolean enabled) { |
| 901 | try { |
| 902 | mService.setMobileDataEnabled(enabled); |
| 903 | } catch (RemoteException e) { |
| 904 | } |
| 905 | } |
| 906 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 907 | /** |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 908 | * {@hide} |
| 909 | */ |
| 910 | public ConnectivityManager(IConnectivityManager service) { |
Jeff Sharkey | f0ceede | 2011-08-02 17:22:34 -0700 | [diff] [blame] | 911 | mService = checkNotNull(service, "missing IConnectivityManager"); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 912 | } |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 913 | |
Jeff Sharkey | 8fc27e8 | 2012-04-04 20:40:58 -0700 | [diff] [blame] | 914 | /** {@hide} */ |
| 915 | public static ConnectivityManager from(Context context) { |
| 916 | return (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); |
| 917 | } |
| 918 | |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 919 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 920 | * Get the set of tetherable, available interfaces. This list is limited by |
| 921 | * device configuration and current interface existence. |
| 922 | * |
| 923 | * @return an array of 0 or more Strings of tetherable interface names. |
| 924 | * |
| 925 | * <p>This method requires the call to hold the permission |
| 926 | * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 927 | * {@hide} |
| 928 | */ |
| 929 | public String[] getTetherableIfaces() { |
| 930 | try { |
| 931 | return mService.getTetherableIfaces(); |
| 932 | } catch (RemoteException e) { |
| 933 | return new String[0]; |
| 934 | } |
| 935 | } |
| 936 | |
| 937 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 938 | * Get the set of tethered interfaces. |
| 939 | * |
| 940 | * @return an array of 0 or more String of currently tethered interface names. |
| 941 | * |
| 942 | * <p>This method requires the call to hold the permission |
| 943 | * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 944 | * {@hide} |
| 945 | */ |
| 946 | public String[] getTetheredIfaces() { |
| 947 | try { |
| 948 | return mService.getTetheredIfaces(); |
| 949 | } catch (RemoteException e) { |
| 950 | return new String[0]; |
| 951 | } |
| 952 | } |
| 953 | |
| 954 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 955 | * Get the set of interface names which attempted to tether but |
| 956 | * failed. Re-attempting to tether may cause them to reset to the Tethered |
| 957 | * state. Alternatively, causing the interface to be destroyed and recreated |
| 958 | * may cause them to reset to the available state. |
| 959 | * {@link ConnectivityManager#getLastTetherError} can be used to get more |
| 960 | * information on the cause of the errors. |
| 961 | * |
| 962 | * @return an array of 0 or more String indicating the interface names |
| 963 | * which failed to tether. |
| 964 | * |
| 965 | * <p>This method requires the call to hold the permission |
| 966 | * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 967 | * {@hide} |
| 968 | */ |
Robert Greenwalt | 5a73506 | 2010-03-02 17:25:02 -0800 | [diff] [blame] | 969 | public String[] getTetheringErroredIfaces() { |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 970 | try { |
Robert Greenwalt | 5a73506 | 2010-03-02 17:25:02 -0800 | [diff] [blame] | 971 | return mService.getTetheringErroredIfaces(); |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 972 | } catch (RemoteException e) { |
Robert Greenwalt | 5a73506 | 2010-03-02 17:25:02 -0800 | [diff] [blame] | 973 | return new String[0]; |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 974 | } |
| 975 | } |
| 976 | |
| 977 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 978 | * Attempt to tether the named interface. This will setup a dhcp server |
| 979 | * on the interface, forward and NAT IP packets and forward DNS requests |
| 980 | * to the best active upstream network interface. Note that if no upstream |
| 981 | * IP network interface is available, dhcp will still run and traffic will be |
| 982 | * allowed between the tethered devices and this device, though upstream net |
| 983 | * access will of course fail until an upstream network interface becomes |
| 984 | * active. |
| 985 | * |
| 986 | * @param iface the interface name to tether. |
| 987 | * @return error a {@code TETHER_ERROR} value indicating success or failure type |
| 988 | * |
| 989 | * <p>This method requires the call to hold the permission |
| 990 | * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}. |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 991 | * {@hide} |
| 992 | */ |
Robert Greenwalt | 5a73506 | 2010-03-02 17:25:02 -0800 | [diff] [blame] | 993 | public int tether(String iface) { |
| 994 | try { |
| 995 | return mService.tether(iface); |
| 996 | } catch (RemoteException e) { |
| 997 | return TETHER_ERROR_SERVICE_UNAVAIL; |
| 998 | } |
| 999 | } |
| 1000 | |
| 1001 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 1002 | * Stop tethering the named interface. |
| 1003 | * |
| 1004 | * @param iface the interface name to untether. |
| 1005 | * @return error a {@code TETHER_ERROR} value indicating success or failure type |
| 1006 | * |
| 1007 | * <p>This method requires the call to hold the permission |
| 1008 | * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}. |
Robert Greenwalt | 5a73506 | 2010-03-02 17:25:02 -0800 | [diff] [blame] | 1009 | * {@hide} |
| 1010 | */ |
| 1011 | public int untether(String iface) { |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 1012 | try { |
| 1013 | return mService.untether(iface); |
| 1014 | } catch (RemoteException e) { |
Robert Greenwalt | 5a73506 | 2010-03-02 17:25:02 -0800 | [diff] [blame] | 1015 | return TETHER_ERROR_SERVICE_UNAVAIL; |
Robert Greenwalt | d0e18ff | 2010-01-26 11:40:34 -0800 | [diff] [blame] | 1016 | } |
| 1017 | } |
Robert Greenwalt | 2a091d7 | 2010-02-11 18:18:40 -0800 | [diff] [blame] | 1018 | |
| 1019 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 1020 | * Check if the device allows for tethering. It may be disabled via |
| 1021 | * {@code ro.tether.denied} system property, {@link Settings#TETHER_SUPPORTED} or |
| 1022 | * due to device configuration. |
| 1023 | * |
| 1024 | * @return a boolean - {@code true} indicating Tethering is supported. |
| 1025 | * |
| 1026 | * <p>This method requires the call to hold the permission |
| 1027 | * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. |
Robert Greenwalt | 2a091d7 | 2010-02-11 18:18:40 -0800 | [diff] [blame] | 1028 | * {@hide} |
| 1029 | */ |
| 1030 | public boolean isTetheringSupported() { |
| 1031 | try { |
| 1032 | return mService.isTetheringSupported(); |
| 1033 | } catch (RemoteException e) { |
| 1034 | return false; |
| 1035 | } |
| 1036 | } |
| 1037 | |
| 1038 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 1039 | * Get the list of regular expressions that define any tetherable |
| 1040 | * USB network interfaces. If USB tethering is not supported by the |
| 1041 | * device, this list should be empty. |
| 1042 | * |
| 1043 | * @return an array of 0 or more regular expression Strings defining |
| 1044 | * what interfaces are considered tetherable usb interfaces. |
| 1045 | * |
| 1046 | * <p>This method requires the call to hold the permission |
| 1047 | * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. |
Robert Greenwalt | 2a091d7 | 2010-02-11 18:18:40 -0800 | [diff] [blame] | 1048 | * {@hide} |
| 1049 | */ |
| 1050 | public String[] getTetherableUsbRegexs() { |
| 1051 | try { |
| 1052 | return mService.getTetherableUsbRegexs(); |
| 1053 | } catch (RemoteException e) { |
| 1054 | return new String[0]; |
| 1055 | } |
| 1056 | } |
| 1057 | |
| 1058 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 1059 | * Get the list of regular expressions that define any tetherable |
| 1060 | * Wifi network interfaces. If Wifi tethering is not supported by the |
| 1061 | * device, this list should be empty. |
| 1062 | * |
| 1063 | * @return an array of 0 or more regular expression Strings defining |
| 1064 | * what interfaces are considered tetherable wifi interfaces. |
| 1065 | * |
| 1066 | * <p>This method requires the call to hold the permission |
| 1067 | * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. |
Robert Greenwalt | 2a091d7 | 2010-02-11 18:18:40 -0800 | [diff] [blame] | 1068 | * {@hide} |
| 1069 | */ |
| 1070 | public String[] getTetherableWifiRegexs() { |
| 1071 | try { |
| 1072 | return mService.getTetherableWifiRegexs(); |
| 1073 | } catch (RemoteException e) { |
| 1074 | return new String[0]; |
| 1075 | } |
| 1076 | } |
Robert Greenwalt | 5a73506 | 2010-03-02 17:25:02 -0800 | [diff] [blame] | 1077 | |
Danica Chang | 6fdd0c6 | 2010-08-11 14:54:43 -0700 | [diff] [blame] | 1078 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 1079 | * Get the list of regular expressions that define any tetherable |
| 1080 | * Bluetooth network interfaces. If Bluetooth tethering is not supported by the |
| 1081 | * device, this list should be empty. |
| 1082 | * |
| 1083 | * @return an array of 0 or more regular expression Strings defining |
| 1084 | * what interfaces are considered tetherable bluetooth interfaces. |
| 1085 | * |
| 1086 | * <p>This method requires the call to hold the permission |
| 1087 | * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. |
Danica Chang | 6fdd0c6 | 2010-08-11 14:54:43 -0700 | [diff] [blame] | 1088 | * {@hide} |
| 1089 | */ |
| 1090 | public String[] getTetherableBluetoothRegexs() { |
| 1091 | try { |
| 1092 | return mService.getTetherableBluetoothRegexs(); |
| 1093 | } catch (RemoteException e) { |
| 1094 | return new String[0]; |
| 1095 | } |
| 1096 | } |
| 1097 | |
Mike Lockwood | 6c2260b | 2011-07-19 13:04:47 -0700 | [diff] [blame] | 1098 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 1099 | * Attempt to both alter the mode of USB and Tethering of USB. A |
| 1100 | * utility method to deal with some of the complexity of USB - will |
| 1101 | * attempt to switch to Rndis and subsequently tether the resulting |
| 1102 | * interface on {@code true} or turn off tethering and switch off |
| 1103 | * Rndis on {@code false}. |
| 1104 | * |
| 1105 | * @param enable a boolean - {@code true} to enable tethering |
| 1106 | * @return error a {@code TETHER_ERROR} value indicating success or failure type |
| 1107 | * |
| 1108 | * <p>This method requires the call to hold the permission |
| 1109 | * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}. |
Mike Lockwood | 6c2260b | 2011-07-19 13:04:47 -0700 | [diff] [blame] | 1110 | * {@hide} |
| 1111 | */ |
| 1112 | public int setUsbTethering(boolean enable) { |
| 1113 | try { |
| 1114 | return mService.setUsbTethering(enable); |
| 1115 | } catch (RemoteException e) { |
| 1116 | return TETHER_ERROR_SERVICE_UNAVAIL; |
| 1117 | } |
| 1118 | } |
| 1119 | |
Robert Greenwalt | 5a73506 | 2010-03-02 17:25:02 -0800 | [diff] [blame] | 1120 | /** {@hide} */ |
| 1121 | public static final int TETHER_ERROR_NO_ERROR = 0; |
| 1122 | /** {@hide} */ |
| 1123 | public static final int TETHER_ERROR_UNKNOWN_IFACE = 1; |
| 1124 | /** {@hide} */ |
| 1125 | public static final int TETHER_ERROR_SERVICE_UNAVAIL = 2; |
| 1126 | /** {@hide} */ |
| 1127 | public static final int TETHER_ERROR_UNSUPPORTED = 3; |
| 1128 | /** {@hide} */ |
| 1129 | public static final int TETHER_ERROR_UNAVAIL_IFACE = 4; |
| 1130 | /** {@hide} */ |
| 1131 | public static final int TETHER_ERROR_MASTER_ERROR = 5; |
| 1132 | /** {@hide} */ |
| 1133 | public static final int TETHER_ERROR_TETHER_IFACE_ERROR = 6; |
| 1134 | /** {@hide} */ |
| 1135 | public static final int TETHER_ERROR_UNTETHER_IFACE_ERROR = 7; |
| 1136 | /** {@hide} */ |
| 1137 | public static final int TETHER_ERROR_ENABLE_NAT_ERROR = 8; |
| 1138 | /** {@hide} */ |
| 1139 | public static final int TETHER_ERROR_DISABLE_NAT_ERROR = 9; |
| 1140 | /** {@hide} */ |
| 1141 | public static final int TETHER_ERROR_IFACE_CFG_ERROR = 10; |
| 1142 | |
| 1143 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 1144 | * Get a more detailed error code after a Tethering or Untethering |
| 1145 | * request asynchronously failed. |
| 1146 | * |
| 1147 | * @param iface The name of the interface of interest |
Robert Greenwalt | 5a73506 | 2010-03-02 17:25:02 -0800 | [diff] [blame] | 1148 | * @return error The error code of the last error tethering or untethering the named |
| 1149 | * interface |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 1150 | * |
| 1151 | * <p>This method requires the call to hold the permission |
| 1152 | * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. |
Robert Greenwalt | 5a73506 | 2010-03-02 17:25:02 -0800 | [diff] [blame] | 1153 | * {@hide} |
| 1154 | */ |
| 1155 | public int getLastTetherError(String iface) { |
| 1156 | try { |
| 1157 | return mService.getLastTetherError(iface); |
| 1158 | } catch (RemoteException e) { |
| 1159 | return TETHER_ERROR_SERVICE_UNAVAIL; |
| 1160 | } |
Robert Greenwalt | 14f2ef4 | 2010-06-15 12:19:37 -0700 | [diff] [blame] | 1161 | } |
| 1162 | |
| 1163 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 1164 | * Try to ensure the device stays awake until we connect with the next network. |
| 1165 | * Actually just holds a wakelock for a number of seconds while we try to connect |
| 1166 | * to any default networks. This will expire if the timeout passes or if we connect |
| 1167 | * to a default after this is called. For internal use only. |
| 1168 | * |
| 1169 | * @param forWhom the name of the network going down for logging purposes |
Robert Greenwalt | 14f2ef4 | 2010-06-15 12:19:37 -0700 | [diff] [blame] | 1170 | * @return {@code true} on success, {@code false} on failure |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 1171 | * |
| 1172 | * <p>This method requires the call to hold the permission |
| 1173 | * {@link android.Manifest.permission#CONNECTIVITY_INTERNAL}. |
Robert Greenwalt | 14f2ef4 | 2010-06-15 12:19:37 -0700 | [diff] [blame] | 1174 | * {@hide} |
| 1175 | */ |
| 1176 | public boolean requestNetworkTransitionWakelock(String forWhom) { |
| 1177 | try { |
| 1178 | mService.requestNetworkTransitionWakelock(forWhom); |
| 1179 | return true; |
| 1180 | } catch (RemoteException e) { |
| 1181 | return false; |
| 1182 | } |
| 1183 | } |
Robert Greenwalt | ca4306c | 2010-09-09 13:15:32 -0700 | [diff] [blame] | 1184 | |
Robert Greenwalt | 67fd6c9 | 2010-09-09 14:22:59 -0700 | [diff] [blame] | 1185 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 1186 | * Report network connectivity status. This is currently used only |
| 1187 | * to alter status bar UI. |
| 1188 | * |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 1189 | * @param networkType The type of network you want to report on |
| 1190 | * @param percentage The quality of the connection 0 is bad, 100 is good |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 1191 | * |
| 1192 | * <p>This method requires the call to hold the permission |
| 1193 | * {@link android.Manifest.permission#STATUS_BAR}. |
Robert Greenwalt | d7085fc | 2010-09-08 15:24:47 -0700 | [diff] [blame] | 1194 | * {@hide} |
| 1195 | */ |
| 1196 | public void reportInetCondition(int networkType, int percentage) { |
| 1197 | try { |
| 1198 | mService.reportInetCondition(networkType, percentage); |
| 1199 | } catch (RemoteException e) { |
| 1200 | } |
| 1201 | } |
Robert Greenwalt | 434203a | 2010-10-11 16:00:27 -0700 | [diff] [blame] | 1202 | |
| 1203 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 1204 | * Set a network-independent global http proxy. This is not normally what you want |
| 1205 | * for typical HTTP proxies - they are general network dependent. However if you're |
| 1206 | * doing something unusual like general internal filtering this may be useful. On |
| 1207 | * a private network where the proxy is not accessible, you may break HTTP using this. |
| 1208 | * |
| 1209 | * @param proxyProperties The a {@link ProxyProperites} object defining the new global |
| 1210 | * HTTP proxy. A {@code null} value will clear the global HTTP proxy. |
| 1211 | * |
| 1212 | * <p>This method requires the call to hold the permission |
Robert Greenwalt | a9bebc2 | 2013-04-10 15:32:18 -0700 | [diff] [blame] | 1213 | * {@link android.Manifest.permission#CONNECTIVITY_INTERNAL}. |
Robert Greenwalt | 434203a | 2010-10-11 16:00:27 -0700 | [diff] [blame] | 1214 | * {@hide} |
| 1215 | */ |
| 1216 | public void setGlobalProxy(ProxyProperties p) { |
| 1217 | try { |
| 1218 | mService.setGlobalProxy(p); |
| 1219 | } catch (RemoteException e) { |
| 1220 | } |
| 1221 | } |
| 1222 | |
| 1223 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 1224 | * Retrieve any network-independent global HTTP proxy. |
| 1225 | * |
| 1226 | * @return {@link ProxyProperties} for the current global HTTP proxy or {@code null} |
| 1227 | * if no global HTTP proxy is set. |
| 1228 | * |
| 1229 | * <p>This method requires the call to hold the permission |
| 1230 | * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. |
Robert Greenwalt | 434203a | 2010-10-11 16:00:27 -0700 | [diff] [blame] | 1231 | * {@hide} |
| 1232 | */ |
| 1233 | public ProxyProperties getGlobalProxy() { |
| 1234 | try { |
| 1235 | return mService.getGlobalProxy(); |
| 1236 | } catch (RemoteException e) { |
| 1237 | return null; |
| 1238 | } |
| 1239 | } |
| 1240 | |
| 1241 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 1242 | * Get the HTTP proxy settings for the current default network. Note that |
| 1243 | * if a global proxy is set, it will override any per-network setting. |
| 1244 | * |
| 1245 | * @return the {@link ProxyProperties} for the current HTTP proxy, or {@code null} if no |
| 1246 | * HTTP proxy is active. |
| 1247 | * |
| 1248 | * <p>This method requires the call to hold the permission |
| 1249 | * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. |
Robert Greenwalt | 434203a | 2010-10-11 16:00:27 -0700 | [diff] [blame] | 1250 | * {@hide} |
| 1251 | */ |
| 1252 | public ProxyProperties getProxy() { |
| 1253 | try { |
| 1254 | return mService.getProxy(); |
| 1255 | } catch (RemoteException e) { |
| 1256 | return null; |
| 1257 | } |
| 1258 | } |
Robert Greenwalt | d55a6b4 | 2011-03-25 13:09:25 -0700 | [diff] [blame] | 1259 | |
| 1260 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 1261 | * Sets a secondary requirement bit for the given networkType. |
| 1262 | * This requirement bit is generally under the control of the carrier |
| 1263 | * or its agents and is not directly controlled by the user. |
| 1264 | * |
Robert Greenwalt | d55a6b4 | 2011-03-25 13:09:25 -0700 | [diff] [blame] | 1265 | * @param networkType The network who's dependence has changed |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 1266 | * @param met Boolean - true if network use is OK, false if not |
| 1267 | * |
| 1268 | * <p>This method requires the call to hold the permission |
| 1269 | * {@link android.Manifest.permission#CONNECTIVITY_INTERNAL}. |
Robert Greenwalt | d55a6b4 | 2011-03-25 13:09:25 -0700 | [diff] [blame] | 1270 | * {@hide} |
| 1271 | */ |
| 1272 | public void setDataDependency(int networkType, boolean met) { |
| 1273 | try { |
| 1274 | mService.setDataDependency(networkType, met); |
| 1275 | } catch (RemoteException e) { |
| 1276 | } |
| 1277 | } |
Robert Greenwalt | 9b2886e | 2011-08-31 11:46:42 -0700 | [diff] [blame] | 1278 | |
| 1279 | /** |
| 1280 | * Returns true if the hardware supports the given network type |
| 1281 | * else it returns false. This doesn't indicate we have coverage |
| 1282 | * or are authorized onto a network, just whether or not the |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 1283 | * hardware supports it. For example a GSM phone without a SIM |
| 1284 | * should still return {@code true} for mobile data, but a wifi only |
| 1285 | * tablet would return {@code false}. |
| 1286 | * |
| 1287 | * @param networkType The network type we'd like to check |
| 1288 | * @return {@code true} if supported, else {@code false} |
| 1289 | * |
| 1290 | * <p>This method requires the call to hold the permission |
| 1291 | * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. |
Robert Greenwalt | 9b2886e | 2011-08-31 11:46:42 -0700 | [diff] [blame] | 1292 | * @hide |
| 1293 | */ |
| 1294 | public boolean isNetworkSupported(int networkType) { |
| 1295 | try { |
| 1296 | return mService.isNetworkSupported(networkType); |
| 1297 | } catch (RemoteException e) {} |
| 1298 | return false; |
| 1299 | } |
Jeff Sharkey | 9f7cbf0 | 2012-04-12 18:34:54 -0700 | [diff] [blame] | 1300 | |
| 1301 | /** |
| 1302 | * Returns if the currently active data network is metered. A network is |
| 1303 | * classified as metered when the user is sensitive to heavy data usage on |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 1304 | * that connection due to monetary costs, data limitations or |
| 1305 | * battery/performance issues. You should check this before doing large |
| 1306 | * data transfers, and warn the user or delay the operation until another |
| 1307 | * network is available. |
| 1308 | * |
| 1309 | * @return {@code true} if large transfers should be avoided, otherwise |
| 1310 | * {@code false}. |
| 1311 | * |
| 1312 | * <p>This method requires the call to hold the permission |
| 1313 | * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}. |
Jeff Sharkey | 9f7cbf0 | 2012-04-12 18:34:54 -0700 | [diff] [blame] | 1314 | */ |
| 1315 | public boolean isActiveNetworkMetered() { |
| 1316 | try { |
| 1317 | return mService.isActiveNetworkMetered(); |
| 1318 | } catch (RemoteException e) { |
| 1319 | return false; |
| 1320 | } |
| 1321 | } |
Jeff Sharkey | 69ddab4 | 2012-08-25 00:05:46 -0700 | [diff] [blame] | 1322 | |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 1323 | /** |
| 1324 | * If the LockdownVpn mechanism is enabled, updates the vpn |
| 1325 | * with a reload of its profile. |
| 1326 | * |
| 1327 | * @return a boolean with {@code} indicating success |
| 1328 | * |
| 1329 | * <p>This method can only be called by the system UID |
| 1330 | * {@hide} |
| 1331 | */ |
Jeff Sharkey | 69ddab4 | 2012-08-25 00:05:46 -0700 | [diff] [blame] | 1332 | public boolean updateLockdownVpn() { |
| 1333 | try { |
| 1334 | return mService.updateLockdownVpn(); |
| 1335 | } catch (RemoteException e) { |
| 1336 | return false; |
| 1337 | } |
| 1338 | } |
Irfan Sheriff | da6da09 | 2012-08-16 12:49:23 -0700 | [diff] [blame] | 1339 | |
| 1340 | /** |
Robert Greenwalt | 5a6bdc4 | 2013-02-15 10:56:35 -0800 | [diff] [blame] | 1341 | * Signal that the captive portal check on the indicated network |
Wink Saville | d747cbc | 2013-08-07 16:22:47 -0700 | [diff] [blame] | 1342 | * is complete and whether its a captive portal or not. |
| 1343 | * |
| 1344 | * @param info the {@link NetworkInfo} object for the networkType |
| 1345 | * in question. |
| 1346 | * @param isCaptivePortal true/false. |
| 1347 | * |
| 1348 | * <p>This method requires the call to hold the permission |
| 1349 | * {@link android.Manifest.permission#CONNECTIVITY_INTERNAL}. |
| 1350 | * {@hide} |
| 1351 | */ |
| 1352 | public void captivePortalCheckCompleted(NetworkInfo info, boolean isCaptivePortal) { |
| 1353 | try { |
| 1354 | mService.captivePortalCheckCompleted(info, isCaptivePortal); |
| 1355 | } catch (RemoteException e) { |
| 1356 | } |
| 1357 | } |
| 1358 | |
| 1359 | /** |
Robert Greenwalt | 665e1ae | 2012-08-21 19:27:00 -0700 | [diff] [blame] | 1360 | * Supply the backend messenger for a network tracker |
| 1361 | * |
| 1362 | * @param type NetworkType to set |
| 1363 | * @param messenger {@link Messenger} |
| 1364 | * {@hide} |
| 1365 | */ |
| 1366 | public void supplyMessenger(int networkType, Messenger messenger) { |
| 1367 | try { |
| 1368 | mService.supplyMessenger(networkType, messenger); |
| 1369 | } catch (RemoteException e) { |
| 1370 | } |
| 1371 | } |
Wink Saville | ab9321d | 2013-06-29 21:10:57 -0700 | [diff] [blame] | 1372 | |
| 1373 | /** |
Wink Saville | 948282b | 2013-08-29 08:55:16 -0700 | [diff] [blame] | 1374 | * Check mobile provisioning. |
Wink Saville | ab9321d | 2013-06-29 21:10:57 -0700 | [diff] [blame] | 1375 | * |
Wink Saville | ab9321d | 2013-06-29 21:10:57 -0700 | [diff] [blame] | 1376 | * @param suggestedTimeOutMs, timeout in milliseconds |
Wink Saville | ab9321d | 2013-06-29 21:10:57 -0700 | [diff] [blame] | 1377 | * |
| 1378 | * @return time out that will be used, maybe less that suggestedTimeOutMs |
| 1379 | * -1 if an error. |
| 1380 | * |
| 1381 | * {@hide} |
| 1382 | */ |
Wink Saville | 948282b | 2013-08-29 08:55:16 -0700 | [diff] [blame] | 1383 | public int checkMobileProvisioning(int suggestedTimeOutMs) { |
Wink Saville | ab9321d | 2013-06-29 21:10:57 -0700 | [diff] [blame] | 1384 | int timeOutMs = -1; |
| 1385 | try { |
Wink Saville | 948282b | 2013-08-29 08:55:16 -0700 | [diff] [blame] | 1386 | timeOutMs = mService.checkMobileProvisioning(suggestedTimeOutMs); |
Wink Saville | ab9321d | 2013-06-29 21:10:57 -0700 | [diff] [blame] | 1387 | } catch (RemoteException e) { |
| 1388 | } |
| 1389 | return timeOutMs; |
| 1390 | } |
Robert Greenwalt | e182bfe | 2013-07-16 12:06:09 -0700 | [diff] [blame] | 1391 | |
| 1392 | /** |
Wink Saville | 42d4f08 | 2013-07-20 20:31:59 -0700 | [diff] [blame] | 1393 | * Get the mobile provisioning url. |
Robert Greenwalt | e182bfe | 2013-07-16 12:06:09 -0700 | [diff] [blame] | 1394 | * {@hide} |
| 1395 | */ |
| 1396 | public String getMobileProvisioningUrl() { |
| 1397 | try { |
| 1398 | return mService.getMobileProvisioningUrl(); |
| 1399 | } catch (RemoteException e) { |
| 1400 | } |
| 1401 | return null; |
| 1402 | } |
Wink Saville | 42d4f08 | 2013-07-20 20:31:59 -0700 | [diff] [blame] | 1403 | |
| 1404 | /** |
| 1405 | * Get the mobile redirected provisioning url. |
| 1406 | * {@hide} |
| 1407 | */ |
| 1408 | public String getMobileRedirectedProvisioningUrl() { |
| 1409 | try { |
| 1410 | return mService.getMobileRedirectedProvisioningUrl(); |
| 1411 | } catch (RemoteException e) { |
| 1412 | } |
| 1413 | return null; |
| 1414 | } |
Vinit Deshapnde | 1f12cb5 | 2013-08-21 13:09:01 -0700 | [diff] [blame] | 1415 | |
| 1416 | /** |
| 1417 | * get the information about a specific network link |
| 1418 | * @hide |
| 1419 | */ |
Vinit Deshapnde | 6a2d325 | 2013-09-04 14:11:24 -0700 | [diff] [blame] | 1420 | public LinkQualityInfo getLinkQualityInfo(int networkType) { |
Vinit Deshapnde | 1f12cb5 | 2013-08-21 13:09:01 -0700 | [diff] [blame] | 1421 | try { |
Vinit Deshapnde | 6a2d325 | 2013-09-04 14:11:24 -0700 | [diff] [blame] | 1422 | LinkQualityInfo li = mService.getLinkQualityInfo(networkType); |
Vinit Deshapnde | 1f12cb5 | 2013-08-21 13:09:01 -0700 | [diff] [blame] | 1423 | return li; |
| 1424 | } catch (RemoteException e) { |
| 1425 | return null; |
| 1426 | } |
| 1427 | } |
| 1428 | |
| 1429 | /** |
| 1430 | * get the information of currently active network link |
| 1431 | * @hide |
| 1432 | */ |
Vinit Deshapnde | 6a2d325 | 2013-09-04 14:11:24 -0700 | [diff] [blame] | 1433 | public LinkQualityInfo getActiveLinkQualityInfo() { |
Vinit Deshapnde | 1f12cb5 | 2013-08-21 13:09:01 -0700 | [diff] [blame] | 1434 | try { |
Vinit Deshapnde | 6a2d325 | 2013-09-04 14:11:24 -0700 | [diff] [blame] | 1435 | LinkQualityInfo li = mService.getActiveLinkQualityInfo(); |
Vinit Deshapnde | 1f12cb5 | 2013-08-21 13:09:01 -0700 | [diff] [blame] | 1436 | return li; |
| 1437 | } catch (RemoteException e) { |
| 1438 | return null; |
| 1439 | } |
| 1440 | } |
| 1441 | |
| 1442 | /** |
| 1443 | * get the information of all network links |
| 1444 | * @hide |
| 1445 | */ |
Vinit Deshapnde | 6a2d325 | 2013-09-04 14:11:24 -0700 | [diff] [blame] | 1446 | public LinkQualityInfo[] getAllLinkQualityInfo() { |
Vinit Deshapnde | 1f12cb5 | 2013-08-21 13:09:01 -0700 | [diff] [blame] | 1447 | try { |
Vinit Deshapnde | 6a2d325 | 2013-09-04 14:11:24 -0700 | [diff] [blame] | 1448 | LinkQualityInfo[] li = mService.getAllLinkQualityInfo(); |
Vinit Deshapnde | 1f12cb5 | 2013-08-21 13:09:01 -0700 | [diff] [blame] | 1449 | return li; |
| 1450 | } catch (RemoteException e) { |
| 1451 | return null; |
| 1452 | } |
| 1453 | } |
Wink Saville | 7788c61 | 2013-08-29 14:57:08 -0700 | [diff] [blame] | 1454 | |
| 1455 | /** |
Wink Saville | 948282b | 2013-08-29 08:55:16 -0700 | [diff] [blame] | 1456 | * Set sign in error notification to visible or in visible |
| 1457 | * |
| 1458 | * @param visible |
| 1459 | * @param networkType |
| 1460 | * |
| 1461 | * {@hide} |
| 1462 | */ |
| 1463 | public void setProvisioningNotificationVisible(boolean visible, int networkType, |
| 1464 | String extraInfo, String url) { |
| 1465 | try { |
| 1466 | mService.setProvisioningNotificationVisible(visible, networkType, extraInfo, url); |
| 1467 | } catch (RemoteException e) { |
| 1468 | } |
| 1469 | } |
Yuhao Zheng | 5cd1a0e | 2013-09-09 17:00:04 -0700 | [diff] [blame] | 1470 | |
| 1471 | /** |
| 1472 | * Set the value for enabling/disabling airplane mode |
| 1473 | * |
| 1474 | * @param enable whether to enable airplane mode or not |
| 1475 | * |
| 1476 | * <p>This method requires the call to hold the permission |
| 1477 | * {@link android.Manifest.permission#CONNECTIVITY_INTERNAL}. |
| 1478 | * @hide |
| 1479 | */ |
| 1480 | public void setAirplaneMode(boolean enable) { |
| 1481 | try { |
| 1482 | mService.setAirplaneMode(enable); |
| 1483 | } catch (RemoteException e) { |
| 1484 | } |
| 1485 | } |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1486 | } |