blob: 3a35cb9537a84db408e6351f60fd4fd5b0553325 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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
17package android.net;
18
Jeff Sharkeyf0ceede2011-08-02 17:22:34 -070019import static com.android.internal.util.Preconditions.checkNotNull;
20
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080021import android.annotation.SdkConstant;
22import android.annotation.SdkConstant.SdkConstantType;
Jeff Sharkey8fc27e82012-04-04 20:40:58 -070023import android.content.Context;
Robert Greenwalt42acef32009-08-12 16:08:25 -070024import android.os.Binder;
Jeff Sharkey3a844fc2011-08-16 14:37:57 -070025import android.os.Build.VERSION_CODES;
Robert Greenwalt665e1ae2012-08-21 19:27:00 -070026import android.os.Messenger;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080027import android.os.RemoteException;
Jeff Sharkey961e3042011-08-29 16:02:57 -070028import android.provider.Settings;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080029
Robert Greenwalt585ac0f2010-08-27 09:24:29 -070030import java.net.InetAddress;
Robert Greenwalt585ac0f2010-08-27 09:24:29 -070031
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080032/**
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 Sharkeyc006f1a2011-05-19 17:12:49 -070048public class ConnectivityManager {
49 private static final String TAG = "ConnectivityManager";
50
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080051 /**
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 Greenwalt5a6bdc42013-02-15 10:56:35 -080066 * receiver should expect another broadcast soon, indicating either that
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080067 * 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 Sharkey4fa63b22013-02-20 18:21:19 -080074 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080075 public static final String CONNECTIVITY_ACTION = "android.net.conn.CONNECTIVITY_CHANGE";
Jeff Sharkeyf0ceede2011-08-02 17:22:34 -070076
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080077 /**
Jeff Sharkey961e3042011-08-29 16:02:57 -070078 * Identical to {@link #CONNECTIVITY_ACTION} broadcast, but sent without any
79 * applicable {@link Settings.Secure#CONNECTIVITY_CHANGE_DELAY}.
80 *
81 * @hide
82 */
Jeff Sharkey4fa63b22013-02-20 18:21:19 -080083 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey961e3042011-08-29 16:02:57 -070084 public static final String CONNECTIVITY_ACTION_IMMEDIATE =
85 "android.net.conn.CONNECTIVITY_CHANGE_IMMEDIATE";
86
87 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080088 * The lookup key for a {@link NetworkInfo} object. Retrieve with
89 * {@link android.content.Intent#getParcelableExtra(String)}.
Jeff Sharkeyf0ceede2011-08-02 17:22:34 -070090 *
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 Sharkey75fbb4b2012-08-06 11:41:50 -070095 * @see #EXTRA_NETWORK_TYPE
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080096 */
Jeff Sharkeyf0ceede2011-08-02 17:22:34 -070097 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080098 public static final String EXTRA_NETWORK_INFO = "networkInfo";
Jeff Sharkeyf0ceede2011-08-02 17:22:34 -070099
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800100 /**
Jeff Sharkey75fbb4b2012-08-06 11:41:50 -0700101 * 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 Project9066cfe2009-03-03 19:31:44 -0800110 * 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 Greenwaltd7085fc2010-09-08 15:24:47 -0700143 /**
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 Sharkeyc006f1a2011-05-19 17:12:49 -0700147 * {@link android.content.Intent#getIntExtra(String, int)}.
Robert Greenwaltd7085fc2010-09-08 15:24:47 -0700148 * {@hide}
149 */
150 public static final String EXTRA_INET_CONDITION = "inetCondition";
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800151
152 /**
Haoyu Baidb3c8672012-06-20 14:29:57 -0700153 * Broadcast action to indicate the change of data activity status
154 * (idle or active) on a network in a recent period.
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800155 * The network becomes active when data transmission is started, or
156 * idle if there is no data transmission for a period of time.
Haoyu Baidb3c8672012-06-20 14:29:57 -0700157 * {@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 Project9066cfe2009-03-03 19:31:44 -0800175 * 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 Sharkeyc006f1a2011-05-19 17:12:49 -0700180 * {@code false}.
Jeff Sharkey54ee2ad2012-01-30 16:29:24 -0800181 * <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 Project9066cfe2009-03-03 19:31:44 -0800191 */
192 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Jeff Sharkey54ee2ad2012-01-30 16:29:24 -0800193 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800194 public static final String ACTION_BACKGROUND_DATA_SETTING_CHANGED =
195 "android.net.conn.BACKGROUND_DATA_SETTING_CHANGED";
196
Robert Greenwalt1e9aac22010-09-15 17:36:33 -0700197 /**
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 Sharkey4fa63b22013-02-20 18:21:19 -0800204 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Robert Greenwalt1e9aac22010-09-15 17:36:33 -0700205 public static final String INET_CONDITION_ACTION =
206 "android.net.conn.INET_CONDITION_ACTION";
207
Robert Greenwalt42acef32009-08-12 16:08:25 -0700208 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800209 * 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 Greenwaltd0e18ff2010-01-26 11:40:34 -0800215 * @hide
216 */
Jeff Sharkey4fa63b22013-02-20 18:21:19 -0800217 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Robert Greenwaltd0e18ff2010-01-26 11:40:34 -0800218 public static final String ACTION_TETHER_STATE_CHANGED =
219 "android.net.conn.TETHER_STATE_CHANGED";
220
221 /**
222 * @hide
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800223 * gives a String[] listing all the interfaces configured for
224 * tethering and currently available for tethering.
Robert Greenwaltd0e18ff2010-01-26 11:40:34 -0800225 */
Robert Greenwalt2a091d72010-02-11 18:18:40 -0800226 public static final String EXTRA_AVAILABLE_TETHER = "availableArray";
Robert Greenwaltd0e18ff2010-01-26 11:40:34 -0800227
228 /**
229 * @hide
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800230 * gives a String[] listing all the interfaces currently tethered
231 * (ie, has dhcp support and packets potentially forwarded/NATed)
Robert Greenwaltd0e18ff2010-01-26 11:40:34 -0800232 */
Robert Greenwalt2a091d72010-02-11 18:18:40 -0800233 public static final String EXTRA_ACTIVE_TETHER = "activeArray";
234
235 /**
236 * @hide
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800237 * 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 Greenwalt2a091d72010-02-11 18:18:40 -0800240 */
241 public static final String EXTRA_ERRORED_TETHER = "erroredArray";
Robert Greenwaltd0e18ff2010-01-26 11:40:34 -0800242
243 /**
Russell Brenner108da0c2013-02-12 10:03:14 -0800244 * 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 Sharkey4fa63b22013-02-20 18:21:19 -0800249 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
Russell Brenner108da0c2013-02-12 10:03:14 -0800250 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 Greenwalt5a6bdc42013-02-15 10:56:35 -0800260 * The absence of a connection type.
Robert Greenwaltccf83af12011-06-02 17:30:47 -0700261 * @hide
262 */
263 public static final int TYPE_NONE = -1;
264
265 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800266 * 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 Greenwalt42acef32009-08-12 16:08:25 -0700269 */
270 public static final int TYPE_MOBILE = 0;
271 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800272 * 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 Greenwalt42acef32009-08-12 16:08:25 -0700275 */
276 public static final int TYPE_WIFI = 1;
277 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800278 * 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 Greenwalt42acef32009-08-12 16:08:25 -0700282 */
283 public static final int TYPE_MOBILE_MMS = 2;
284 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800285 * 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 Greenwalt42acef32009-08-12 16:08:25 -0700289 */
290 public static final int TYPE_MOBILE_SUPL = 3;
291 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800292 * 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 Greenwalt42acef32009-08-12 16:08:25 -0700296 */
297 public static final int TYPE_MOBILE_DUN = 4;
298 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800299 * 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 Greenwalt42acef32009-08-12 16:08:25 -0700304 */
305 public static final int TYPE_MOBILE_HIPRI = 5;
jsh8214deb2010-03-11 15:04:43 -0800306 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800307 * 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).
jsh8214deb2010-03-11 15:04:43 -0800310 */
311 public static final int TYPE_WIMAX = 6;
Robert Greenwaltda3d5e62010-12-06 13:56:24 -0800312
Jaikumar Ganesh15c74392010-12-21 22:31:44 -0800313 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800314 * 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 Ganesh15c74392010-12-21 22:31:44 -0800317 */
318 public static final int TYPE_BLUETOOTH = 7;
319
Robert Greenwalt60810842011-04-22 15:28:18 -0700320 /**
321 * Dummy data connection. This should not be used on shipping devices.
322 */
Jaikumar Ganesh15c74392010-12-21 22:31:44 -0800323 public static final int TYPE_DUMMY = 8;
Wink Saville9d7d6282011-03-12 14:52:01 -0800324
Robert Greenwalt60810842011-04-22 15:28:18 -0700325 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800326 * 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 Greenwalt60810842011-04-22 15:28:18 -0700329 */
Robert Greenwalte12aec92011-01-28 14:48:37 -0800330 public static final int TYPE_ETHERNET = 9;
Robert Greenwalt60810842011-04-22 15:28:18 -0700331
Wink Saville9d7d6282011-03-12 14:52:01 -0800332 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800333 * Over the air Administration.
Wink Saville9d7d6282011-03-12 14:52:01 -0800334 * {@hide}
335 */
336 public static final int TYPE_MOBILE_FOTA = 10;
337
338 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800339 * IP Multimedia Subsystem.
Wink Saville9d7d6282011-03-12 14:52:01 -0800340 * {@hide}
341 */
342 public static final int TYPE_MOBILE_IMS = 11;
343
344 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800345 * Carrier Branded Services.
Wink Saville9d7d6282011-03-12 14:52:01 -0800346 * {@hide}
347 */
348 public static final int TYPE_MOBILE_CBS = 12;
349
repo syncaea743a2011-07-29 23:55:49 -0700350 /**
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 Saville9d7d6282011-03-12 14:52:01 -0800356
Wink Saville5e56bc52013-07-29 15:00:57 -0700357 /**
358 * The network to use for initially attaching to the network
359 * {@hide}
360 */
361 public static final int TYPE_MOBILE_IA = 14;
repo syncaea743a2011-07-29 23:55:49 -0700362
Hui Lu1c5624a2014-01-15 11:05:36 -0500363 /**
364 * The network that uses proxy to achieve connectivity.
365 * {@hide}
366 */
367 public static final int TYPE_PROXY = 16;
Wink Saville5e56bc52013-07-29 15:00:57 -0700368
369 /** {@hide} */
Hui Lu1c5624a2014-01-15 11:05:36 -0500370 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 Project9066cfe2009-03-03 19:31:44 -0800374
Jianzheng Zhoudcf03f32012-11-16 13:45:20 +0800375 /**
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 Greenwalt5a6bdc42013-02-15 10:56:35 -0800381 * the hierarchy. Instead, the default is defined by the
Jianzheng Zhoudcf03f32012-11-16 13:45:20 +0800382 * networkAttributes in config.xml. You can determine
Robert Greenwalt4c8b7482012-12-07 09:56:50 -0800383 * the current value by calling {@link #getNetworkPreference()}
Jianzheng Zhoudcf03f32012-11-16 13:45:20 +0800384 * from an App.
385 */
386 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800387 public static final int DEFAULT_NETWORK_PREFERENCE = TYPE_WIFI;
388
Jeff Sharkey625239a2012-09-26 22:03:49 -0700389 /**
390 * Default value for {@link Settings.Global#CONNECTIVITY_CHANGE_DELAY} in
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800391 * 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 Sharkey625239a2012-09-26 22:03:49 -0700396 *
397 * @hide
398 */
399 public static final int CONNECTIVITY_CHANGE_DELAY_DEFAULT = 3000;
400
Jeff Sharkeyc006f1a2011-05-19 17:12:49 -0700401 private final IConnectivityManager mService;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800402
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800403 /**
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 Sharkeyd2a45872011-05-28 20:56:34 -0700408 public static boolean isNetworkTypeValid(int networkType) {
Robert Greenwalt42acef32009-08-12 16:08:25 -0700409 return networkType >= 0 && networkType <= MAX_NETWORK_TYPE;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800410 }
411
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800412 /**
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 Sharkeyd2a45872011-05-28 20:56:34 -0700420 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 syncaea743a2011-07-29 23:55:49 -0700448 case TYPE_WIFI_P2P:
449 return "WIFI_P2P";
Wink Saville5e56bc52013-07-29 15:00:57 -0700450 case TYPE_MOBILE_IA:
451 return "MOBILE_IA";
Hui Lu1c5624a2014-01-15 11:05:36 -0500452 case TYPE_PROXY:
453 return "PROXY";
Jeff Sharkeyd2a45872011-05-28 20:56:34 -0700454 default:
455 return Integer.toString(type);
456 }
457 }
458
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800459 /**
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 Sharkeyd2a45872011-05-28 20:56:34 -0700466 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 Saville5e56bc52013-07-29 15:00:57 -0700476 case TYPE_MOBILE_IA:
Jeff Sharkeyd2a45872011-05-28 20:56:34 -0700477 return true;
478 default:
479 return false;
480 }
481 }
482
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800483 /**
Jeff Sharkey7a1c3fc2013-06-04 12:29:00 -0700484 * 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 Brubakerf336d722013-07-15 16:34:04 -0700499 * 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 Saville5e56bc52013-07-29 15:00:57 -0700508 case TYPE_MOBILE_IA:
Chad Brubakerf336d722013-07-15 16:34:04 -0700509 return true;
510 default:
511 return false;
512 }
513 }
514
515 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800516 * 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 Project9066cfe2009-03-03 19:31:44 -0800526 public void setNetworkPreference(int preference) {
527 try {
528 mService.setNetworkPreference(preference);
529 } catch (RemoteException e) {
530 }
531 }
532
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800533 /**
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 Project9066cfe2009-03-03 19:31:44 -0800544 public int getNetworkPreference() {
545 try {
546 return mService.getNetworkPreference();
547 } catch (RemoteException e) {
548 return -1;
549 }
550 }
551
Scott Main671644c2011-10-06 19:02:28 -0700552 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800553 * 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 Falliere9530e3a2012-06-18 17:21:06 -0700563 * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
Jeff Sharkey9f7cbf02012-04-12 18:34:54 -0700564 */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800565 public NetworkInfo getActiveNetworkInfo() {
566 try {
567 return mService.getActiveNetworkInfo();
568 } catch (RemoteException e) {
569 return null;
570 }
571 }
572
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800573 /**
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 Sharkeyc006f1a2011-05-19 17:12:49 -0700586 public NetworkInfo getActiveNetworkInfoForUid(int uid) {
587 try {
588 return mService.getActiveNetworkInfoForUid(uid);
589 } catch (RemoteException e) {
590 return null;
591 }
592 }
593
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800594 /**
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 Project9066cfe2009-03-03 19:31:44 -0800607 public NetworkInfo getNetworkInfo(int networkType) {
608 try {
609 return mService.getNetworkInfo(networkType);
610 } catch (RemoteException e) {
611 return null;
612 }
613 }
614
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800615 /**
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 Project9066cfe2009-03-03 19:31:44 -0800625 public NetworkInfo[] getAllNetworkInfo() {
626 try {
627 return mService.getAllNetworkInfo();
628 } catch (RemoteException e) {
629 return null;
630 }
631 }
632
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800633 /**
Wink Saville948282b2013-08-29 08:55:16 -0700634 * 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 Greenwalt5a6bdc42013-02-15 10:56:35 -0800657 * 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 Greenwaltd192dad2010-09-14 09:18:02 -0700667 public LinkProperties getActiveLinkProperties() {
668 try {
669 return mService.getActiveLinkProperties();
670 } catch (RemoteException e) {
671 return null;
672 }
673 }
674
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800675 /**
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 Greenwaltd192dad2010-09-14 09:18:02 -0700687 public LinkProperties getLinkProperties(int networkType) {
688 try {
689 return mService.getLinkProperties(networkType);
690 } catch (RemoteException e) {
691 return null;
692 }
693 }
694
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800695 /**
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 Project9066cfe2009-03-03 19:31:44 -0800707 public boolean setRadios(boolean turnOn) {
708 try {
709 return mService.setRadios(turnOn);
710 } catch (RemoteException e) {
711 return false;
712 }
713 }
714
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800715 /**
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 Project9066cfe2009-03-03 19:31:44 -0800727 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 Falliere9530e3a2012-06-18 17:21:06 -0700739 * <p>This method requires the caller to hold the permission
740 * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800741 * @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 Greenwalt42acef32009-08-12 16:08:25 -0700750 return mService.startUsingNetworkFeature(networkType, feature,
751 new Binder());
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800752 } 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 Falliere9530e3a2012-06-18 17:21:06 -0700761 * <p>This method requires the caller to hold the permission
762 * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800763 * @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 Falliere9530e3a2012-06-18 17:21:06 -0700782 * <p>This method requires the caller to hold the permission
783 * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800784 * @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 Greenwalt585ac0f2010-08-27 09:24:29 -0700790 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 Hamby8f9b33e2014-01-15 13:08:03 -0800803 * <p>This method requires the caller to hold the permission
804 * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
Robert Greenwalt585ac0f2010-08-27 09:24:29 -0700805 * @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 Project9066cfe2009-03-03 19:31:44 -0800813 try {
Robert Greenwalt585ac0f2010-08-27 09:24:29 -0700814 return mService.requestRouteToHostAddress(networkType, address);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800815 } 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 Sharkey3a844fc2011-08-16 14:37:57 -0700828 * <p>
Scott Main4cc53332011-10-06 18:32:43 -0700829 * @deprecated As of {@link VERSION_CODES#ICE_CREAM_SANDWICH}, availability of
Jeff Sharkey3a844fc2011-08-16 14:37:57 -0700830 * 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 Chang6fdd0c62010-08-11 14:54:43 -0700833 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800834 * @return Whether background data usage is allowed.
835 */
Jeff Sharkey3a844fc2011-08-16 14:37:57 -0700836 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800837 public boolean getBackgroundDataSetting() {
Jeff Sharkey3a844fc2011-08-16 14:37:57 -0700838 // assume that background data is allowed; final authority is
839 // NetworkInfo which may be blocked.
840 return true;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800841 }
842
843 /**
844 * Sets the value of the setting for background data usage.
Robert Greenwaltc03fa502010-02-23 18:58:05 -0800845 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800846 * @param allowBackgroundData Whether an application should use data while
847 * it is in the background.
Robert Greenwaltc03fa502010-02-23 18:58:05 -0800848 *
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800849 * @attr ref android.Manifest.permission#CHANGE_BACKGROUND_DATA_SETTING
850 * @see #getBackgroundDataSetting()
851 * @hide
852 */
Jeff Sharkey3a844fc2011-08-16 14:37:57 -0700853 @Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800854 public void setBackgroundDataSetting(boolean allowBackgroundData) {
Jeff Sharkey3a844fc2011-08-16 14:37:57 -0700855 // ignored
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800856 }
Robert Greenwaltc03fa502010-02-23 18:58:05 -0800857
858 /**
Jeff Sharkeyf0ceede2011-08-02 17:22:34 -0700859 * 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 Sharkey44a3e0d2011-10-06 10:50:09 -0700862 *
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800863 * <p>This method requires the call to hold the permission
864 * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
865 *
Jeff Sharkey44a3e0d2011-10-06 10:50:09 -0700866 * @hide
Jeff Sharkeyf0ceede2011-08-02 17:22:34 -0700867 */
868 public NetworkQuotaInfo getActiveNetworkQuotaInfo() {
869 try {
870 return mService.getActiveNetworkQuotaInfo();
871 } catch (RemoteException e) {
872 return null;
873 }
874 }
875
876 /**
Robert Greenwaltc03fa502010-02-23 18:58:05 -0800877 * Gets the value of the setting for enabling Mobile data.
878 *
879 * @return Whether mobile data is enabled.
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800880 *
881 * <p>This method requires the call to hold the permission
882 * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
Robert Greenwaltc03fa502010-02-23 18:58:05 -0800883 * @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 Greenwalt5a6bdc42013-02-15 10:56:35 -0800896 * @param enabled Whether the user wants the mobile data connection used
897 * or not.
Robert Greenwaltc03fa502010-02-23 18:58:05 -0800898 * @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 Project9066cfe2009-03-03 19:31:44 -0800907 /**
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800908 * {@hide}
909 */
910 public ConnectivityManager(IConnectivityManager service) {
Jeff Sharkeyf0ceede2011-08-02 17:22:34 -0700911 mService = checkNotNull(service, "missing IConnectivityManager");
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800912 }
Robert Greenwaltd0e18ff2010-01-26 11:40:34 -0800913
Jeff Sharkey8fc27e82012-04-04 20:40:58 -0700914 /** {@hide} */
915 public static ConnectivityManager from(Context context) {
916 return (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
917 }
918
Robert Greenwaltd0e18ff2010-01-26 11:40:34 -0800919 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800920 * 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 Greenwaltd0e18ff2010-01-26 11:40:34 -0800927 * {@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 Greenwalt5a6bdc42013-02-15 10:56:35 -0800938 * 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 Greenwaltd0e18ff2010-01-26 11:40:34 -0800944 * {@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 Greenwalt5a6bdc42013-02-15 10:56:35 -0800955 * 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 Greenwaltd0e18ff2010-01-26 11:40:34 -0800967 * {@hide}
968 */
Robert Greenwalt5a735062010-03-02 17:25:02 -0800969 public String[] getTetheringErroredIfaces() {
Robert Greenwaltd0e18ff2010-01-26 11:40:34 -0800970 try {
Robert Greenwalt5a735062010-03-02 17:25:02 -0800971 return mService.getTetheringErroredIfaces();
Robert Greenwaltd0e18ff2010-01-26 11:40:34 -0800972 } catch (RemoteException e) {
Robert Greenwalt5a735062010-03-02 17:25:02 -0800973 return new String[0];
Robert Greenwaltd0e18ff2010-01-26 11:40:34 -0800974 }
975 }
976
977 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -0800978 * 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 Greenwaltd0e18ff2010-01-26 11:40:34 -0800991 * {@hide}
992 */
Robert Greenwalt5a735062010-03-02 17:25:02 -0800993 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 Greenwalt5a6bdc42013-02-15 10:56:35 -08001002 * 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 Greenwalt5a735062010-03-02 17:25:02 -08001009 * {@hide}
1010 */
1011 public int untether(String iface) {
Robert Greenwaltd0e18ff2010-01-26 11:40:34 -08001012 try {
1013 return mService.untether(iface);
1014 } catch (RemoteException e) {
Robert Greenwalt5a735062010-03-02 17:25:02 -08001015 return TETHER_ERROR_SERVICE_UNAVAIL;
Robert Greenwaltd0e18ff2010-01-26 11:40:34 -08001016 }
1017 }
Robert Greenwalt2a091d72010-02-11 18:18:40 -08001018
1019 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -08001020 * 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 Greenwalt2a091d72010-02-11 18:18:40 -08001028 * {@hide}
1029 */
1030 public boolean isTetheringSupported() {
1031 try {
1032 return mService.isTetheringSupported();
1033 } catch (RemoteException e) {
1034 return false;
1035 }
1036 }
1037
1038 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -08001039 * 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 Greenwalt2a091d72010-02-11 18:18:40 -08001048 * {@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 Greenwalt5a6bdc42013-02-15 10:56:35 -08001059 * 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 Greenwalt2a091d72010-02-11 18:18:40 -08001068 * {@hide}
1069 */
1070 public String[] getTetherableWifiRegexs() {
1071 try {
1072 return mService.getTetherableWifiRegexs();
1073 } catch (RemoteException e) {
1074 return new String[0];
1075 }
1076 }
Robert Greenwalt5a735062010-03-02 17:25:02 -08001077
Danica Chang6fdd0c62010-08-11 14:54:43 -07001078 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -08001079 * 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 Chang6fdd0c62010-08-11 14:54:43 -07001088 * {@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 Lockwood6c2260b2011-07-19 13:04:47 -07001098 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -08001099 * 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 Lockwood6c2260b2011-07-19 13:04:47 -07001110 * {@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 Greenwalt5a735062010-03-02 17:25:02 -08001120 /** {@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 Greenwalt5a6bdc42013-02-15 10:56:35 -08001144 * 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 Greenwalt5a735062010-03-02 17:25:02 -08001148 * @return error The error code of the last error tethering or untethering the named
1149 * interface
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -08001150 *
1151 * <p>This method requires the call to hold the permission
1152 * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
Robert Greenwalt5a735062010-03-02 17:25:02 -08001153 * {@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 Greenwalt14f2ef42010-06-15 12:19:37 -07001161 }
1162
1163 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -08001164 * 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 Greenwalt14f2ef42010-06-15 12:19:37 -07001170 * @return {@code true} on success, {@code false} on failure
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -08001171 *
1172 * <p>This method requires the call to hold the permission
1173 * {@link android.Manifest.permission#CONNECTIVITY_INTERNAL}.
Robert Greenwalt14f2ef42010-06-15 12:19:37 -07001174 * {@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 Greenwaltca4306c2010-09-09 13:15:32 -07001184
Robert Greenwalt67fd6c92010-09-09 14:22:59 -07001185 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -08001186 * Report network connectivity status. This is currently used only
1187 * to alter status bar UI.
1188 *
Robert Greenwaltd7085fc2010-09-08 15:24:47 -07001189 * @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 Greenwalt5a6bdc42013-02-15 10:56:35 -08001191 *
1192 * <p>This method requires the call to hold the permission
1193 * {@link android.Manifest.permission#STATUS_BAR}.
Robert Greenwaltd7085fc2010-09-08 15:24:47 -07001194 * {@hide}
1195 */
1196 public void reportInetCondition(int networkType, int percentage) {
1197 try {
1198 mService.reportInetCondition(networkType, percentage);
1199 } catch (RemoteException e) {
1200 }
1201 }
Robert Greenwalt434203a2010-10-11 16:00:27 -07001202
1203 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -08001204 * 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 Greenwalta9bebc22013-04-10 15:32:18 -07001213 * {@link android.Manifest.permission#CONNECTIVITY_INTERNAL}.
Robert Greenwalt434203a2010-10-11 16:00:27 -07001214 * {@hide}
1215 */
1216 public void setGlobalProxy(ProxyProperties p) {
1217 try {
1218 mService.setGlobalProxy(p);
1219 } catch (RemoteException e) {
1220 }
1221 }
1222
1223 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -08001224 * 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 Greenwalt434203a2010-10-11 16:00:27 -07001231 * {@hide}
1232 */
1233 public ProxyProperties getGlobalProxy() {
1234 try {
1235 return mService.getGlobalProxy();
1236 } catch (RemoteException e) {
1237 return null;
1238 }
1239 }
1240
1241 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -08001242 * 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 Greenwalt434203a2010-10-11 16:00:27 -07001250 * {@hide}
1251 */
1252 public ProxyProperties getProxy() {
1253 try {
1254 return mService.getProxy();
1255 } catch (RemoteException e) {
1256 return null;
1257 }
1258 }
Robert Greenwaltd55a6b42011-03-25 13:09:25 -07001259
1260 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -08001261 * 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 Greenwaltd55a6b42011-03-25 13:09:25 -07001265 * @param networkType The network who's dependence has changed
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -08001266 * @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 Greenwaltd55a6b42011-03-25 13:09:25 -07001270 * {@hide}
1271 */
1272 public void setDataDependency(int networkType, boolean met) {
1273 try {
1274 mService.setDataDependency(networkType, met);
1275 } catch (RemoteException e) {
1276 }
1277 }
Robert Greenwalt9b2886e2011-08-31 11:46:42 -07001278
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 Greenwalt5a6bdc42013-02-15 10:56:35 -08001283 * 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 Greenwalt9b2886e2011-08-31 11:46:42 -07001292 * @hide
1293 */
1294 public boolean isNetworkSupported(int networkType) {
1295 try {
1296 return mService.isNetworkSupported(networkType);
1297 } catch (RemoteException e) {}
1298 return false;
1299 }
Jeff Sharkey9f7cbf02012-04-12 18:34:54 -07001300
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 Greenwalt5a6bdc42013-02-15 10:56:35 -08001304 * 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 Sharkey9f7cbf02012-04-12 18:34:54 -07001314 */
1315 public boolean isActiveNetworkMetered() {
1316 try {
1317 return mService.isActiveNetworkMetered();
1318 } catch (RemoteException e) {
1319 return false;
1320 }
1321 }
Jeff Sharkey69ddab42012-08-25 00:05:46 -07001322
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -08001323 /**
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 Sharkey69ddab42012-08-25 00:05:46 -07001332 public boolean updateLockdownVpn() {
1333 try {
1334 return mService.updateLockdownVpn();
1335 } catch (RemoteException e) {
1336 return false;
1337 }
1338 }
Irfan Sheriffda6da092012-08-16 12:49:23 -07001339
1340 /**
Robert Greenwalt5a6bdc42013-02-15 10:56:35 -08001341 * Signal that the captive portal check on the indicated network
Wink Savilled747cbc2013-08-07 16:22:47 -07001342 * 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 Greenwalt665e1ae2012-08-21 19:27:00 -07001360 * 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 Savilleab9321d2013-06-29 21:10:57 -07001372
1373 /**
Wink Saville948282b2013-08-29 08:55:16 -07001374 * Check mobile provisioning.
Wink Savilleab9321d2013-06-29 21:10:57 -07001375 *
Wink Savilleab9321d2013-06-29 21:10:57 -07001376 * @param suggestedTimeOutMs, timeout in milliseconds
Wink Savilleab9321d2013-06-29 21:10:57 -07001377 *
1378 * @return time out that will be used, maybe less that suggestedTimeOutMs
1379 * -1 if an error.
1380 *
1381 * {@hide}
1382 */
Wink Saville948282b2013-08-29 08:55:16 -07001383 public int checkMobileProvisioning(int suggestedTimeOutMs) {
Wink Savilleab9321d2013-06-29 21:10:57 -07001384 int timeOutMs = -1;
1385 try {
Wink Saville948282b2013-08-29 08:55:16 -07001386 timeOutMs = mService.checkMobileProvisioning(suggestedTimeOutMs);
Wink Savilleab9321d2013-06-29 21:10:57 -07001387 } catch (RemoteException e) {
1388 }
1389 return timeOutMs;
1390 }
Robert Greenwalte182bfe2013-07-16 12:06:09 -07001391
1392 /**
Wink Saville42d4f082013-07-20 20:31:59 -07001393 * Get the mobile provisioning url.
Robert Greenwalte182bfe2013-07-16 12:06:09 -07001394 * {@hide}
1395 */
1396 public String getMobileProvisioningUrl() {
1397 try {
1398 return mService.getMobileProvisioningUrl();
1399 } catch (RemoteException e) {
1400 }
1401 return null;
1402 }
Wink Saville42d4f082013-07-20 20:31:59 -07001403
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 Deshapnde1f12cb52013-08-21 13:09:01 -07001415
1416 /**
1417 * get the information about a specific network link
1418 * @hide
1419 */
Vinit Deshapnde6a2d3252013-09-04 14:11:24 -07001420 public LinkQualityInfo getLinkQualityInfo(int networkType) {
Vinit Deshapnde1f12cb52013-08-21 13:09:01 -07001421 try {
Vinit Deshapnde6a2d3252013-09-04 14:11:24 -07001422 LinkQualityInfo li = mService.getLinkQualityInfo(networkType);
Vinit Deshapnde1f12cb52013-08-21 13:09:01 -07001423 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 Deshapnde6a2d3252013-09-04 14:11:24 -07001433 public LinkQualityInfo getActiveLinkQualityInfo() {
Vinit Deshapnde1f12cb52013-08-21 13:09:01 -07001434 try {
Vinit Deshapnde6a2d3252013-09-04 14:11:24 -07001435 LinkQualityInfo li = mService.getActiveLinkQualityInfo();
Vinit Deshapnde1f12cb52013-08-21 13:09:01 -07001436 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 Deshapnde6a2d3252013-09-04 14:11:24 -07001446 public LinkQualityInfo[] getAllLinkQualityInfo() {
Vinit Deshapnde1f12cb52013-08-21 13:09:01 -07001447 try {
Vinit Deshapnde6a2d3252013-09-04 14:11:24 -07001448 LinkQualityInfo[] li = mService.getAllLinkQualityInfo();
Vinit Deshapnde1f12cb52013-08-21 13:09:01 -07001449 return li;
1450 } catch (RemoteException e) {
1451 return null;
1452 }
1453 }
Wink Saville7788c612013-08-29 14:57:08 -07001454
1455 /**
Wink Saville948282b2013-08-29 08:55:16 -07001456 * 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 Zheng5cd1a0e2013-09-09 17:00:04 -07001470
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 Project9066cfe2009-03-03 19:31:44 -08001486}