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