ConnectivityManager.java revision f81daa986e3a2d75c6f2398a59b965790484e0a2
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
17package android.net;
18
19import static com.android.internal.util.Preconditions.checkNotNull;
20
21import android.annotation.SdkConstant;
22import android.annotation.SdkConstant.SdkConstantType;
23import android.content.Context;
24import android.os.Binder;
25import android.os.Build.VERSION_CODES;
26import android.os.Messenger;
27import android.os.RemoteException;
28import android.provider.Settings;
29
30import java.net.InetAddress;
31
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 */
48public class ConnectivityManager {
49    private static final String TAG = "ConnectivityManager";
50
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
66     * receiver should expect another broadcast soon, indicating either that
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     */
74    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
75    public static final String CONNECTIVITY_ACTION = "android.net.conn.CONNECTIVITY_CHANGE";
76
77    /**
78     * Identical to {@link #CONNECTIVITY_ACTION} broadcast, but sent without any
79     * applicable {@link Settings.Secure#CONNECTIVITY_CHANGE_DELAY}.
80     *
81     * @hide
82     */
83    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
84    public static final String CONNECTIVITY_ACTION_IMMEDIATE =
85            "android.net.conn.CONNECTIVITY_CHANGE_IMMEDIATE";
86
87    /**
88     * The lookup key for a {@link NetworkInfo} object. Retrieve with
89     * {@link android.content.Intent#getParcelableExtra(String)}.
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()}.
95     * @see #EXTRA_NETWORK_TYPE
96     */
97    @Deprecated
98    public static final String EXTRA_NETWORK_INFO = "networkInfo";
99
100    /**
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    /**
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";
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
147     * {@link android.content.Intent#getIntExtra(String, int)}.
148     * {@hide}
149     */
150    public static final String EXTRA_INET_CONDITION = "inetCondition";
151
152    /**
153     * Broadcast action to indicate the change of data activity status
154     * (idle or active) on a network in a recent period.
155     * The network becomes active when data transmission is started, or
156     * idle if there is no data transmission for a period of time.
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    /**
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
180     * {@code false}.
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.
191     */
192    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
193    @Deprecated
194    public static final String ACTION_BACKGROUND_DATA_SETTING_CHANGED =
195            "android.net.conn.BACKGROUND_DATA_SETTING_CHANGED";
196
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     */
204    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
205    public static final String INET_CONDITION_ACTION =
206            "android.net.conn.INET_CONDITION_ACTION";
207
208    /**
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).
215     * @hide
216     */
217    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
218    public static final String ACTION_TETHER_STATE_CHANGED =
219            "android.net.conn.TETHER_STATE_CHANGED";
220
221    /**
222     * @hide
223     * gives a String[] listing all the interfaces configured for
224     * tethering and currently available for tethering.
225     */
226    public static final String EXTRA_AVAILABLE_TETHER = "availableArray";
227
228    /**
229     * @hide
230     * gives a String[] listing all the interfaces currently tethered
231     * (ie, has dhcp support and packets potentially forwarded/NATed)
232     */
233    public static final String EXTRA_ACTIVE_TETHER = "activeArray";
234
235    /**
236     * @hide
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.
240     */
241    public static final String EXTRA_ERRORED_TETHER = "erroredArray";
242
243    /**
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     */
249    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
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    /**
260     * The absence of a connection type.
261     * @hide
262     */
263    public static final int TYPE_NONE        = -1;
264
265    /**
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)
269     */
270    public static final int TYPE_MOBILE      = 0;
271    /**
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).
275     */
276    public static final int TYPE_WIFI        = 1;
277    /**
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.
282     */
283    public static final int TYPE_MOBILE_MMS  = 2;
284    /**
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.
289     */
290    public static final int TYPE_MOBILE_SUPL = 3;
291    /**
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.
296     */
297    public static final int TYPE_MOBILE_DUN  = 4;
298    /**
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.
304     */
305    public static final int TYPE_MOBILE_HIPRI = 5;
306    /**
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).
310     */
311    public static final int TYPE_WIMAX       = 6;
312
313    /**
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).
317     */
318    public static final int TYPE_BLUETOOTH   = 7;
319
320    /**
321     * Dummy data connection.  This should not be used on shipping devices.
322     */
323    public static final int TYPE_DUMMY       = 8;
324
325    /**
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).
329     */
330    public static final int TYPE_ETHERNET    = 9;
331
332    /**
333     * Over the air Administration.
334     * {@hide}
335     */
336    public static final int TYPE_MOBILE_FOTA = 10;
337
338    /**
339     * IP Multimedia Subsystem.
340     * {@hide}
341     */
342    public static final int TYPE_MOBILE_IMS  = 11;
343
344    /**
345     * Carrier Branded Services.
346     * {@hide}
347     */
348    public static final int TYPE_MOBILE_CBS  = 12;
349
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;
356
357    /**
358     * The network to use for initially attaching to the network
359     * {@hide}
360     */
361    public static final int TYPE_MOBILE_IA = 14;
362
363    /**
364     * The network that uses proxy to achieve connectivity.
365     * {@hide}
366     */
367    public static final int TYPE_PROXY = 16;
368
369    /** {@hide} */
370    public static final int MAX_RADIO_TYPE   = TYPE_PROXY;
371
372    /** {@hide} */
373    public static final int MAX_NETWORK_TYPE = TYPE_PROXY;
374
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
381     *             the hierarchy.  Instead, the default is defined by the
382     *             networkAttributes in config.xml.  You can determine
383     *             the current value by calling {@link #getNetworkPreference()}
384     *             from an App.
385     */
386    @Deprecated
387    public static final int DEFAULT_NETWORK_PREFERENCE = TYPE_WIFI;
388
389    /**
390     * Default value for {@link Settings.Global#CONNECTIVITY_CHANGE_DELAY} in
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.
396     *
397     * @hide
398     */
399    public static final int CONNECTIVITY_CHANGE_DELAY_DEFAULT = 3000;
400
401    private final IConnectivityManager mService;
402
403    private final String mPackageName;
404
405    /**
406     * Tests if a given integer represents a valid network type.
407     * @param networkType the type to be tested
408     * @return a boolean.  {@code true} if the type is valid, else {@code false}
409     */
410    public static boolean isNetworkTypeValid(int networkType) {
411        return networkType >= 0 && networkType <= MAX_NETWORK_TYPE;
412    }
413
414    /**
415     * Returns a non-localized string representing a given network type.
416     * ONLY used for debugging output.
417     * @param type the type needing naming
418     * @return a String for the given type, or a string version of the type ("87")
419     * if no name is known.
420     * {@hide}
421     */
422    public static String getNetworkTypeName(int type) {
423        switch (type) {
424            case TYPE_MOBILE:
425                return "MOBILE";
426            case TYPE_WIFI:
427                return "WIFI";
428            case TYPE_MOBILE_MMS:
429                return "MOBILE_MMS";
430            case TYPE_MOBILE_SUPL:
431                return "MOBILE_SUPL";
432            case TYPE_MOBILE_DUN:
433                return "MOBILE_DUN";
434            case TYPE_MOBILE_HIPRI:
435                return "MOBILE_HIPRI";
436            case TYPE_WIMAX:
437                return "WIMAX";
438            case TYPE_BLUETOOTH:
439                return "BLUETOOTH";
440            case TYPE_DUMMY:
441                return "DUMMY";
442            case TYPE_ETHERNET:
443                return "ETHERNET";
444            case TYPE_MOBILE_FOTA:
445                return "MOBILE_FOTA";
446            case TYPE_MOBILE_IMS:
447                return "MOBILE_IMS";
448            case TYPE_MOBILE_CBS:
449                return "MOBILE_CBS";
450            case TYPE_WIFI_P2P:
451                return "WIFI_P2P";
452            case TYPE_MOBILE_IA:
453                return "MOBILE_IA";
454            case TYPE_PROXY:
455                return "PROXY";
456            default:
457                return Integer.toString(type);
458        }
459    }
460
461    /**
462     * Checks if a given type uses the cellular data connection.
463     * This should be replaced in the future by a network property.
464     * @param networkType the type to check
465     * @return a boolean - {@code true} if uses cellular network, else {@code false}
466     * {@hide}
467     */
468    public static boolean isNetworkTypeMobile(int networkType) {
469        switch (networkType) {
470            case TYPE_MOBILE:
471            case TYPE_MOBILE_MMS:
472            case TYPE_MOBILE_SUPL:
473            case TYPE_MOBILE_DUN:
474            case TYPE_MOBILE_HIPRI:
475            case TYPE_MOBILE_FOTA:
476            case TYPE_MOBILE_IMS:
477            case TYPE_MOBILE_CBS:
478            case TYPE_MOBILE_IA:
479                return true;
480            default:
481                return false;
482        }
483    }
484
485    /**
486     * Checks if the given network type is backed by a Wi-Fi radio.
487     *
488     * @hide
489     */
490    public static boolean isNetworkTypeWifi(int networkType) {
491        switch (networkType) {
492            case TYPE_WIFI:
493            case TYPE_WIFI_P2P:
494                return true;
495            default:
496                return false;
497        }
498    }
499
500    /**
501     * Checks if the given network type should be exempt from VPN routing rules
502     *
503     * @hide
504     */
505    public static boolean isNetworkTypeExempt(int networkType) {
506        switch (networkType) {
507            case TYPE_MOBILE_MMS:
508            case TYPE_MOBILE_SUPL:
509            case TYPE_MOBILE_HIPRI:
510            case TYPE_MOBILE_IA:
511                return true;
512            default:
513                return false;
514        }
515    }
516
517    /**
518     * Specifies the preferred network type.  When the device has more
519     * than one type available the preferred network type will be used.
520     * Note that this made sense when we only had 2 network types,
521     * but with more and more default networks we need an array to list
522     * their ordering.  This will be deprecated soon.
523     *
524     * @param preference the network type to prefer over all others.  It is
525     *         unspecified what happens to the old preferred network in the
526     *         overall ordering.
527     */
528    public void setNetworkPreference(int preference) {
529        try {
530            mService.setNetworkPreference(preference);
531        } catch (RemoteException e) {
532        }
533    }
534
535    /**
536     * Retrieves the current preferred network type.
537     * Note that this made sense when we only had 2 network types,
538     * but with more and more default networks we need an array to list
539     * their ordering.  This will be deprecated soon.
540     *
541     * @return an integer representing the preferred network type
542     *
543     * <p>This method requires the caller to hold the permission
544     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
545     */
546    public int getNetworkPreference() {
547        try {
548            return mService.getNetworkPreference();
549        } catch (RemoteException e) {
550            return -1;
551        }
552    }
553
554    /**
555     * Returns details about the currently active default data network. When
556     * connected, this network is the default route for outgoing connections.
557     * You should always check {@link NetworkInfo#isConnected()} before initiating
558     * network traffic. This may return {@code null} when there is no default
559     * network.
560     *
561     * @return a {@link NetworkInfo} object for the current default network
562     *        or {@code null} if no network default network is currently active
563     *
564     * <p>This method requires the call to hold the permission
565     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
566     */
567    public NetworkInfo getActiveNetworkInfo() {
568        try {
569            return mService.getActiveNetworkInfo();
570        } catch (RemoteException e) {
571            return null;
572        }
573    }
574
575    /**
576     * Returns details about the currently active default data network
577     * for a given uid.  This is for internal use only to avoid spying
578     * other apps.
579     *
580     * @return a {@link NetworkInfo} object for the current default network
581     *        for the given uid or {@code null} if no default network is
582     *        available for the specified uid.
583     *
584     * <p>This method requires the caller to hold the permission
585     * {@link android.Manifest.permission#CONNECTIVITY_INTERNAL}
586     * {@hide}
587     */
588    public NetworkInfo getActiveNetworkInfoForUid(int uid) {
589        try {
590            return mService.getActiveNetworkInfoForUid(uid);
591        } catch (RemoteException e) {
592            return null;
593        }
594    }
595
596    /**
597     * Returns connection status information about a particular
598     * network type.
599     *
600     * @param networkType integer specifying which networkType in
601     *        which you're interested.
602     * @return a {@link NetworkInfo} object for the requested
603     *        network type or {@code null} if the type is not
604     *        supported by the device.
605     *
606     * <p>This method requires the call to hold the permission
607     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
608     */
609    public NetworkInfo getNetworkInfo(int networkType) {
610        try {
611            return mService.getNetworkInfo(networkType);
612        } catch (RemoteException e) {
613            return null;
614        }
615    }
616
617    /**
618     * Returns connection status information about all network
619     * types supported by the device.
620     *
621     * @return an array of {@link NetworkInfo} objects.  Check each
622     * {@link NetworkInfo#getType} for which type each applies.
623     *
624     * <p>This method requires the call to hold the permission
625     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
626     */
627    public NetworkInfo[] getAllNetworkInfo() {
628        try {
629            return mService.getAllNetworkInfo();
630        } catch (RemoteException e) {
631            return null;
632        }
633    }
634
635    /**
636     * Returns details about the Provisioning or currently active default data network. When
637     * connected, this network is the default route for outgoing connections.
638     * You should always check {@link NetworkInfo#isConnected()} before initiating
639     * network traffic. This may return {@code null} when there is no default
640     * network.
641     *
642     * @return a {@link NetworkInfo} object for the current default network
643     *        or {@code null} if no network default network is currently active
644     *
645     * <p>This method requires the call to hold the permission
646     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
647     *
648     * {@hide}
649     */
650    public NetworkInfo getProvisioningOrActiveNetworkInfo() {
651        try {
652            return mService.getProvisioningOrActiveNetworkInfo();
653        } catch (RemoteException e) {
654            return null;
655        }
656    }
657
658    /**
659     * Returns the IP information for the current default network.
660     *
661     * @return a {@link LinkProperties} object describing the IP info
662     *        for the current default network, or {@code null} if there
663     *        is no current default network.
664     *
665     * <p>This method requires the call to hold the permission
666     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
667     * {@hide}
668     */
669    public LinkProperties getActiveLinkProperties() {
670        try {
671            return mService.getActiveLinkProperties();
672        } catch (RemoteException e) {
673            return null;
674        }
675    }
676
677    /**
678     * Returns the IP information for a given network type.
679     *
680     * @param networkType the network type of interest.
681     * @return a {@link LinkProperties} object describing the IP info
682     *        for the given networkType, or {@code null} if there is
683     *        no current default network.
684     *
685     * <p>This method requires the call to hold the permission
686     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
687     * {@hide}
688     */
689    public LinkProperties getLinkProperties(int networkType) {
690        try {
691            return mService.getLinkProperties(networkType);
692        } catch (RemoteException e) {
693            return null;
694        }
695    }
696
697    /**
698     * Tells each network type to set its radio power state as directed.
699     *
700     * @param turnOn a boolean, {@code true} to turn the radios on,
701     *        {@code false} to turn them off.
702     * @return a boolean, {@code true} indicating success.  All network types
703     *        will be tried, even if some fail.
704     *
705     * <p>This method requires the call to hold the permission
706     * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
707     * {@hide}
708     */
709    public boolean setRadios(boolean turnOn) {
710        try {
711            return mService.setRadios(turnOn);
712        } catch (RemoteException e) {
713            return false;
714        }
715    }
716
717    /**
718     * Tells a given networkType to set its radio power state as directed.
719     *
720     * @param networkType the int networkType of interest.
721     * @param turnOn a boolean, {@code true} to turn the radio on,
722     *        {@code} false to turn it off.
723     * @return a boolean, {@code true} indicating success.
724     *
725     * <p>This method requires the call to hold the permission
726     * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
727     * {@hide}
728     */
729    public boolean setRadio(int networkType, boolean turnOn) {
730        try {
731            return mService.setRadio(networkType, turnOn);
732        } catch (RemoteException e) {
733            return false;
734        }
735    }
736
737    /**
738     * Tells the underlying networking system that the caller wants to
739     * begin using the named feature. The interpretation of {@code feature}
740     * is completely up to each networking implementation.
741     * <p>This method requires the caller to hold the permission
742     * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
743     * @param networkType specifies which network the request pertains to
744     * @param feature the name of the feature to be used
745     * @return an integer value representing the outcome of the request.
746     * The interpretation of this value is specific to each networking
747     * implementation+feature combination, except that the value {@code -1}
748     * always indicates failure.
749     */
750    public int startUsingNetworkFeature(int networkType, String feature) {
751        try {
752            return mService.startUsingNetworkFeature(networkType, feature,
753                    new Binder());
754        } catch (RemoteException e) {
755            return -1;
756        }
757    }
758
759    /**
760     * Tells the underlying networking system that the caller is finished
761     * using the named feature. The interpretation of {@code feature}
762     * is completely up to each networking implementation.
763     * <p>This method requires the caller to hold the permission
764     * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
765     * @param networkType specifies which network the request pertains to
766     * @param feature the name of the feature that is no longer needed
767     * @return an integer value representing the outcome of the request.
768     * The interpretation of this value is specific to each networking
769     * implementation+feature combination, except that the value {@code -1}
770     * always indicates failure.
771     */
772    public int stopUsingNetworkFeature(int networkType, String feature) {
773        try {
774            return mService.stopUsingNetworkFeature(networkType, feature);
775        } catch (RemoteException e) {
776            return -1;
777        }
778    }
779
780    /**
781     * Ensure that a network route exists to deliver traffic to the specified
782     * host via the specified network interface. An attempt to add a route that
783     * already exists is ignored, but treated as successful.
784     * <p>This method requires the caller to hold the permission
785     * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
786     * @param networkType the type of the network over which traffic to the specified
787     * host is to be routed
788     * @param hostAddress the IP address of the host to which the route is desired
789     * @return {@code true} on success, {@code false} on failure
790     */
791    public boolean requestRouteToHost(int networkType, int hostAddress) {
792        InetAddress inetAddress = NetworkUtils.intToInetAddress(hostAddress);
793
794        if (inetAddress == null) {
795            return false;
796        }
797
798        return requestRouteToHostAddress(networkType, inetAddress);
799    }
800
801    /**
802     * Ensure that a network route exists to deliver traffic to the specified
803     * host via the specified network interface. An attempt to add a route that
804     * already exists is ignored, but treated as successful.
805     * <p>This method requires the caller to hold the permission
806     * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
807     * @param networkType the type of the network over which traffic to the specified
808     * host is to be routed
809     * @param hostAddress the IP address of the host to which the route is desired
810     * @return {@code true} on success, {@code false} on failure
811     * @hide
812     */
813    public boolean requestRouteToHostAddress(int networkType, InetAddress hostAddress) {
814        byte[] address = hostAddress.getAddress();
815        try {
816            return mService.requestRouteToHostAddress(networkType, address, mPackageName);
817        } catch (RemoteException e) {
818            return false;
819        }
820    }
821
822    /**
823     * Returns the value of the setting for background data usage. If false,
824     * applications should not use the network if the application is not in the
825     * foreground. Developers should respect this setting, and check the value
826     * of this before performing any background data operations.
827     * <p>
828     * All applications that have background services that use the network
829     * should listen to {@link #ACTION_BACKGROUND_DATA_SETTING_CHANGED}.
830     * <p>
831     * @deprecated As of {@link VERSION_CODES#ICE_CREAM_SANDWICH}, availability of
832     * background data depends on several combined factors, and this method will
833     * always return {@code true}. Instead, when background data is unavailable,
834     * {@link #getActiveNetworkInfo()} will now appear disconnected.
835     *
836     * @return Whether background data usage is allowed.
837     */
838    @Deprecated
839    public boolean getBackgroundDataSetting() {
840        // assume that background data is allowed; final authority is
841        // NetworkInfo which may be blocked.
842        return true;
843    }
844
845    /**
846     * Sets the value of the setting for background data usage.
847     *
848     * @param allowBackgroundData Whether an application should use data while
849     *            it is in the background.
850     *
851     * @attr ref android.Manifest.permission#CHANGE_BACKGROUND_DATA_SETTING
852     * @see #getBackgroundDataSetting()
853     * @hide
854     */
855    @Deprecated
856    public void setBackgroundDataSetting(boolean allowBackgroundData) {
857        // ignored
858    }
859
860    /**
861     * Return quota status for the current active network, or {@code null} if no
862     * network is active. Quota status can change rapidly, so these values
863     * shouldn't be cached.
864     *
865     * <p>This method requires the call to hold the permission
866     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
867     *
868     * @hide
869     */
870    public NetworkQuotaInfo getActiveNetworkQuotaInfo() {
871        try {
872            return mService.getActiveNetworkQuotaInfo();
873        } catch (RemoteException e) {
874            return null;
875        }
876    }
877
878    /**
879     * Gets the value of the setting for enabling Mobile data.
880     *
881     * @return Whether mobile data is enabled.
882     *
883     * <p>This method requires the call to hold the permission
884     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
885     * @hide
886     */
887    public boolean getMobileDataEnabled() {
888        try {
889            return mService.getMobileDataEnabled();
890        } catch (RemoteException e) {
891            return true;
892        }
893    }
894
895    /**
896     * Sets the persisted value for enabling/disabling Mobile data.
897     *
898     * @param enabled Whether the user wants the mobile data connection used
899     *            or not.
900     * @hide
901     */
902    public void setMobileDataEnabled(boolean enabled) {
903        try {
904            mService.setMobileDataEnabled(enabled);
905        } catch (RemoteException e) {
906        }
907    }
908
909    /**
910     * {@hide}
911     */
912    public ConnectivityManager(IConnectivityManager service, String packageName) {
913        mService = checkNotNull(service, "missing IConnectivityManager");
914        mPackageName = checkNotNull(packageName, "missing package name");
915    }
916
917    /** {@hide} */
918    public static ConnectivityManager from(Context context) {
919        return (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
920    }
921
922    /**
923     * Get the set of tetherable, available interfaces.  This list is limited by
924     * device configuration and current interface existence.
925     *
926     * @return an array of 0 or more Strings of tetherable interface names.
927     *
928     * <p>This method requires the call to hold the permission
929     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
930     * {@hide}
931     */
932    public String[] getTetherableIfaces() {
933        try {
934            return mService.getTetherableIfaces();
935        } catch (RemoteException e) {
936            return new String[0];
937        }
938    }
939
940    /**
941     * Get the set of tethered interfaces.
942     *
943     * @return an array of 0 or more String of currently tethered interface names.
944     *
945     * <p>This method requires the call to hold the permission
946     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
947     * {@hide}
948     */
949    public String[] getTetheredIfaces() {
950        try {
951            return mService.getTetheredIfaces();
952        } catch (RemoteException e) {
953            return new String[0];
954        }
955    }
956
957    /**
958     * Get the set of interface names which attempted to tether but
959     * failed.  Re-attempting to tether may cause them to reset to the Tethered
960     * state.  Alternatively, causing the interface to be destroyed and recreated
961     * may cause them to reset to the available state.
962     * {@link ConnectivityManager#getLastTetherError} can be used to get more
963     * information on the cause of the errors.
964     *
965     * @return an array of 0 or more String indicating the interface names
966     *        which failed to tether.
967     *
968     * <p>This method requires the call to hold the permission
969     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
970     * {@hide}
971     */
972    public String[] getTetheringErroredIfaces() {
973        try {
974            return mService.getTetheringErroredIfaces();
975        } catch (RemoteException e) {
976            return new String[0];
977        }
978    }
979
980    /**
981     * Attempt to tether the named interface.  This will setup a dhcp server
982     * on the interface, forward and NAT IP packets and forward DNS requests
983     * to the best active upstream network interface.  Note that if no upstream
984     * IP network interface is available, dhcp will still run and traffic will be
985     * allowed between the tethered devices and this device, though upstream net
986     * access will of course fail until an upstream network interface becomes
987     * active.
988     *
989     * @param iface the interface name to tether.
990     * @return error a {@code TETHER_ERROR} value indicating success or failure type
991     *
992     * <p>This method requires the call to hold the permission
993     * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
994     * {@hide}
995     */
996    public int tether(String iface) {
997        try {
998            return mService.tether(iface);
999        } catch (RemoteException e) {
1000            return TETHER_ERROR_SERVICE_UNAVAIL;
1001        }
1002    }
1003
1004    /**
1005     * Stop tethering the named interface.
1006     *
1007     * @param iface the interface name to untether.
1008     * @return error a {@code TETHER_ERROR} value indicating success or failure type
1009     *
1010     * <p>This method requires the call to hold the permission
1011     * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
1012     * {@hide}
1013     */
1014    public int untether(String iface) {
1015        try {
1016            return mService.untether(iface);
1017        } catch (RemoteException e) {
1018            return TETHER_ERROR_SERVICE_UNAVAIL;
1019        }
1020    }
1021
1022    /**
1023     * Check if the device allows for tethering.  It may be disabled via
1024     * {@code ro.tether.denied} system property, {@link Settings#TETHER_SUPPORTED} or
1025     * due to device configuration.
1026     *
1027     * @return a boolean - {@code true} indicating Tethering is supported.
1028     *
1029     * <p>This method requires the call to hold the permission
1030     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
1031     * {@hide}
1032     */
1033    public boolean isTetheringSupported() {
1034        try {
1035            return mService.isTetheringSupported();
1036        } catch (RemoteException e) {
1037            return false;
1038        }
1039    }
1040
1041    /**
1042     * Get the list of regular expressions that define any tetherable
1043     * USB network interfaces.  If USB tethering is not supported by the
1044     * device, this list should be empty.
1045     *
1046     * @return an array of 0 or more regular expression Strings defining
1047     *        what interfaces are considered tetherable usb interfaces.
1048     *
1049     * <p>This method requires the call to hold the permission
1050     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
1051     * {@hide}
1052     */
1053    public String[] getTetherableUsbRegexs() {
1054        try {
1055            return mService.getTetherableUsbRegexs();
1056        } catch (RemoteException e) {
1057            return new String[0];
1058        }
1059    }
1060
1061    /**
1062     * Get the list of regular expressions that define any tetherable
1063     * Wifi network interfaces.  If Wifi tethering is not supported by the
1064     * device, this list should be empty.
1065     *
1066     * @return an array of 0 or more regular expression Strings defining
1067     *        what interfaces are considered tetherable wifi interfaces.
1068     *
1069     * <p>This method requires the call to hold the permission
1070     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
1071     * {@hide}
1072     */
1073    public String[] getTetherableWifiRegexs() {
1074        try {
1075            return mService.getTetherableWifiRegexs();
1076        } catch (RemoteException e) {
1077            return new String[0];
1078        }
1079    }
1080
1081    /**
1082     * Get the list of regular expressions that define any tetherable
1083     * Bluetooth network interfaces.  If Bluetooth tethering is not supported by the
1084     * device, this list should be empty.
1085     *
1086     * @return an array of 0 or more regular expression Strings defining
1087     *        what interfaces are considered tetherable bluetooth interfaces.
1088     *
1089     * <p>This method requires the call to hold the permission
1090     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
1091     * {@hide}
1092     */
1093    public String[] getTetherableBluetoothRegexs() {
1094        try {
1095            return mService.getTetherableBluetoothRegexs();
1096        } catch (RemoteException e) {
1097            return new String[0];
1098        }
1099    }
1100
1101    /**
1102     * Attempt to both alter the mode of USB and Tethering of USB.  A
1103     * utility method to deal with some of the complexity of USB - will
1104     * attempt to switch to Rndis and subsequently tether the resulting
1105     * interface on {@code true} or turn off tethering and switch off
1106     * Rndis on {@code false}.
1107     *
1108     * @param enable a boolean - {@code true} to enable tethering
1109     * @return error a {@code TETHER_ERROR} value indicating success or failure type
1110     *
1111     * <p>This method requires the call to hold the permission
1112     * {@link android.Manifest.permission#CHANGE_NETWORK_STATE}.
1113     * {@hide}
1114     */
1115    public int setUsbTethering(boolean enable) {
1116        try {
1117            return mService.setUsbTethering(enable);
1118        } catch (RemoteException e) {
1119            return TETHER_ERROR_SERVICE_UNAVAIL;
1120        }
1121    }
1122
1123    /** {@hide} */
1124    public static final int TETHER_ERROR_NO_ERROR           = 0;
1125    /** {@hide} */
1126    public static final int TETHER_ERROR_UNKNOWN_IFACE      = 1;
1127    /** {@hide} */
1128    public static final int TETHER_ERROR_SERVICE_UNAVAIL    = 2;
1129    /** {@hide} */
1130    public static final int TETHER_ERROR_UNSUPPORTED        = 3;
1131    /** {@hide} */
1132    public static final int TETHER_ERROR_UNAVAIL_IFACE      = 4;
1133    /** {@hide} */
1134    public static final int TETHER_ERROR_MASTER_ERROR       = 5;
1135    /** {@hide} */
1136    public static final int TETHER_ERROR_TETHER_IFACE_ERROR = 6;
1137    /** {@hide} */
1138    public static final int TETHER_ERROR_UNTETHER_IFACE_ERROR = 7;
1139    /** {@hide} */
1140    public static final int TETHER_ERROR_ENABLE_NAT_ERROR     = 8;
1141    /** {@hide} */
1142    public static final int TETHER_ERROR_DISABLE_NAT_ERROR    = 9;
1143    /** {@hide} */
1144    public static final int TETHER_ERROR_IFACE_CFG_ERROR      = 10;
1145
1146    /**
1147     * Get a more detailed error code after a Tethering or Untethering
1148     * request asynchronously failed.
1149     *
1150     * @param iface The name of the interface of interest
1151     * @return error The error code of the last error tethering or untethering the named
1152     *               interface
1153     *
1154     * <p>This method requires the call to hold the permission
1155     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
1156     * {@hide}
1157     */
1158    public int getLastTetherError(String iface) {
1159        try {
1160            return mService.getLastTetherError(iface);
1161        } catch (RemoteException e) {
1162            return TETHER_ERROR_SERVICE_UNAVAIL;
1163        }
1164    }
1165
1166    /**
1167     * Try to ensure the device stays awake until we connect with the next network.
1168     * Actually just holds a wakelock for a number of seconds while we try to connect
1169     * to any default networks.  This will expire if the timeout passes or if we connect
1170     * to a default after this is called.  For internal use only.
1171     *
1172     * @param forWhom the name of the network going down for logging purposes
1173     * @return {@code true} on success, {@code false} on failure
1174     *
1175     * <p>This method requires the call to hold the permission
1176     * {@link android.Manifest.permission#CONNECTIVITY_INTERNAL}.
1177     * {@hide}
1178     */
1179    public boolean requestNetworkTransitionWakelock(String forWhom) {
1180        try {
1181            mService.requestNetworkTransitionWakelock(forWhom);
1182            return true;
1183        } catch (RemoteException e) {
1184            return false;
1185        }
1186    }
1187
1188    /**
1189     * Report network connectivity status.  This is currently used only
1190     * to alter status bar UI.
1191     *
1192     * @param networkType The type of network you want to report on
1193     * @param percentage The quality of the connection 0 is bad, 100 is good
1194     *
1195     * <p>This method requires the call to hold the permission
1196     * {@link android.Manifest.permission#STATUS_BAR}.
1197     * {@hide}
1198     */
1199    public void reportInetCondition(int networkType, int percentage) {
1200        try {
1201            mService.reportInetCondition(networkType, percentage);
1202        } catch (RemoteException e) {
1203        }
1204    }
1205
1206    /**
1207     * Set a network-independent global http proxy.  This is not normally what you want
1208     * for typical HTTP proxies - they are general network dependent.  However if you're
1209     * doing something unusual like general internal filtering this may be useful.  On
1210     * a private network where the proxy is not accessible, you may break HTTP using this.
1211     *
1212     * @param proxyProperties The a {@link ProxyProperites} object defining the new global
1213     *        HTTP proxy.  A {@code null} value will clear the global HTTP proxy.
1214     *
1215     * <p>This method requires the call to hold the permission
1216     * {@link android.Manifest.permission#CONNECTIVITY_INTERNAL}.
1217     * {@hide}
1218     */
1219    public void setGlobalProxy(ProxyProperties p) {
1220        try {
1221            mService.setGlobalProxy(p);
1222        } catch (RemoteException e) {
1223        }
1224    }
1225
1226    /**
1227     * Retrieve any network-independent global HTTP proxy.
1228     *
1229     * @return {@link ProxyProperties} for the current global HTTP proxy or {@code null}
1230     *        if no global HTTP proxy is set.
1231     *
1232     * <p>This method requires the call to hold the permission
1233     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
1234     * {@hide}
1235     */
1236    public ProxyProperties getGlobalProxy() {
1237        try {
1238            return mService.getGlobalProxy();
1239        } catch (RemoteException e) {
1240            return null;
1241        }
1242    }
1243
1244    /**
1245     * Get the HTTP proxy settings for the current default network.  Note that
1246     * if a global proxy is set, it will override any per-network setting.
1247     *
1248     * @return the {@link ProxyProperties} for the current HTTP proxy, or {@code null} if no
1249     *        HTTP proxy is active.
1250     *
1251     * <p>This method requires the call to hold the permission
1252     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
1253     * {@hide}
1254     */
1255    public ProxyProperties getProxy() {
1256        try {
1257            return mService.getProxy();
1258        } catch (RemoteException e) {
1259            return null;
1260        }
1261    }
1262
1263    /**
1264     * Sets a secondary requirement bit for the given networkType.
1265     * This requirement bit is generally under the control of the carrier
1266     * or its agents and is not directly controlled by the user.
1267     *
1268     * @param networkType The network who's dependence has changed
1269     * @param met Boolean - true if network use is OK, false if not
1270     *
1271     * <p>This method requires the call to hold the permission
1272     * {@link android.Manifest.permission#CONNECTIVITY_INTERNAL}.
1273     * {@hide}
1274     */
1275    public void setDataDependency(int networkType, boolean met) {
1276        try {
1277            mService.setDataDependency(networkType, met);
1278        } catch (RemoteException e) {
1279        }
1280    }
1281
1282    /**
1283     * Returns true if the hardware supports the given network type
1284     * else it returns false.  This doesn't indicate we have coverage
1285     * or are authorized onto a network, just whether or not the
1286     * hardware supports it.  For example a GSM phone without a SIM
1287     * should still return {@code true} for mobile data, but a wifi only
1288     * tablet would return {@code false}.
1289     *
1290     * @param networkType The network type we'd like to check
1291     * @return {@code true} if supported, else {@code false}
1292     *
1293     * <p>This method requires the call to hold the permission
1294     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
1295     * @hide
1296     */
1297    public boolean isNetworkSupported(int networkType) {
1298        try {
1299            return mService.isNetworkSupported(networkType);
1300        } catch (RemoteException e) {}
1301        return false;
1302    }
1303
1304    /**
1305     * Returns if the currently active data network is metered. A network is
1306     * classified as metered when the user is sensitive to heavy data usage on
1307     * that connection due to monetary costs, data limitations or
1308     * battery/performance issues. You should check this before doing large
1309     * data transfers, and warn the user or delay the operation until another
1310     * network is available.
1311     *
1312     * @return {@code true} if large transfers should be avoided, otherwise
1313     *        {@code false}.
1314     *
1315     * <p>This method requires the call to hold the permission
1316     * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
1317     */
1318    public boolean isActiveNetworkMetered() {
1319        try {
1320            return mService.isActiveNetworkMetered();
1321        } catch (RemoteException e) {
1322            return false;
1323        }
1324    }
1325
1326    /**
1327     * If the LockdownVpn mechanism is enabled, updates the vpn
1328     * with a reload of its profile.
1329     *
1330     * @return a boolean with {@code} indicating success
1331     *
1332     * <p>This method can only be called by the system UID
1333     * {@hide}
1334     */
1335    public boolean updateLockdownVpn() {
1336        try {
1337            return mService.updateLockdownVpn();
1338        } catch (RemoteException e) {
1339            return false;
1340        }
1341    }
1342
1343    /**
1344     * Signal that the captive portal check on the indicated network
1345     * is complete and whether its a captive portal or not.
1346     *
1347     * @param info the {@link NetworkInfo} object for the networkType
1348     *        in question.
1349     * @param isCaptivePortal true/false.
1350     *
1351     * <p>This method requires the call to hold the permission
1352     * {@link android.Manifest.permission#CONNECTIVITY_INTERNAL}.
1353     * {@hide}
1354     */
1355    public void captivePortalCheckCompleted(NetworkInfo info, boolean isCaptivePortal) {
1356        try {
1357            mService.captivePortalCheckCompleted(info, isCaptivePortal);
1358        } catch (RemoteException e) {
1359        }
1360    }
1361
1362    /**
1363     * Supply the backend messenger for a network tracker
1364     *
1365     * @param type NetworkType to set
1366     * @param messenger {@link Messenger}
1367     * {@hide}
1368     */
1369    public void supplyMessenger(int networkType, Messenger messenger) {
1370        try {
1371            mService.supplyMessenger(networkType, messenger);
1372        } catch (RemoteException e) {
1373        }
1374    }
1375
1376    /**
1377     * Check mobile provisioning.
1378     *
1379     * @param suggestedTimeOutMs, timeout in milliseconds
1380     *
1381     * @return time out that will be used, maybe less that suggestedTimeOutMs
1382     * -1 if an error.
1383     *
1384     * {@hide}
1385     */
1386    public int checkMobileProvisioning(int suggestedTimeOutMs) {
1387        int timeOutMs = -1;
1388        try {
1389            timeOutMs = mService.checkMobileProvisioning(suggestedTimeOutMs);
1390        } catch (RemoteException e) {
1391        }
1392        return timeOutMs;
1393    }
1394
1395    /**
1396     * Get the mobile provisioning url.
1397     * {@hide}
1398     */
1399    public String getMobileProvisioningUrl() {
1400        try {
1401            return mService.getMobileProvisioningUrl();
1402        } catch (RemoteException e) {
1403        }
1404        return null;
1405    }
1406
1407    /**
1408     * Get the mobile redirected provisioning url.
1409     * {@hide}
1410     */
1411    public String getMobileRedirectedProvisioningUrl() {
1412        try {
1413            return mService.getMobileRedirectedProvisioningUrl();
1414        } catch (RemoteException e) {
1415        }
1416        return null;
1417    }
1418
1419    /**
1420     * get the information about a specific network link
1421     * @hide
1422     */
1423    public LinkQualityInfo getLinkQualityInfo(int networkType) {
1424        try {
1425            LinkQualityInfo li = mService.getLinkQualityInfo(networkType);
1426            return li;
1427        } catch (RemoteException e) {
1428            return null;
1429        }
1430    }
1431
1432    /**
1433     * get the information of currently active network link
1434     * @hide
1435     */
1436    public LinkQualityInfo getActiveLinkQualityInfo() {
1437        try {
1438            LinkQualityInfo li = mService.getActiveLinkQualityInfo();
1439            return li;
1440        } catch (RemoteException e) {
1441            return null;
1442        }
1443    }
1444
1445    /**
1446     * get the information of all network links
1447     * @hide
1448     */
1449    public LinkQualityInfo[] getAllLinkQualityInfo() {
1450        try {
1451            LinkQualityInfo[] li = mService.getAllLinkQualityInfo();
1452            return li;
1453        } catch (RemoteException e) {
1454            return null;
1455        }
1456    }
1457
1458    /**
1459     * Set sign in error notification to visible or in visible
1460     *
1461     * @param visible
1462     * @param networkType
1463     *
1464     * {@hide}
1465     */
1466    public void setProvisioningNotificationVisible(boolean visible, int networkType,
1467            String extraInfo, String url) {
1468        try {
1469            mService.setProvisioningNotificationVisible(visible, networkType, extraInfo, url);
1470        } catch (RemoteException e) {
1471        }
1472    }
1473
1474    /**
1475     * Set the value for enabling/disabling airplane mode
1476     *
1477     * @param enable whether to enable airplane mode or not
1478     *
1479     * <p>This method requires the call to hold the permission
1480     * {@link android.Manifest.permission#CONNECTIVITY_INTERNAL}.
1481     * @hide
1482     */
1483    public void setAirplaneMode(boolean enable) {
1484        try {
1485            mService.setAirplaneMode(enable);
1486        } catch (RemoteException e) {
1487        }
1488    }
1489}
1490