ConnectivityManager.java revision 961e30458319cfd50e1892ba7dd14a1d0ebe4cc7
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     * 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    public NetworkQuotaInfo getActiveNetworkQuotaInfo() {
553        try {
554            return mService.getActiveNetworkQuotaInfo();
555        } catch (RemoteException e) {
556            return null;
557        }
558    }
559
560    /**
561     * Gets the value of the setting for enabling Mobile data.
562     *
563     * @return Whether mobile data is enabled.
564     * @hide
565     */
566    public boolean getMobileDataEnabled() {
567        try {
568            return mService.getMobileDataEnabled();
569        } catch (RemoteException e) {
570            return true;
571        }
572    }
573
574    /**
575     * Sets the persisted value for enabling/disabling Mobile data.
576     *
577     * @param enabled Whether the mobile data connection should be
578     *            used or not.
579     * @hide
580     */
581    public void setMobileDataEnabled(boolean enabled) {
582        try {
583            mService.setMobileDataEnabled(enabled);
584        } catch (RemoteException e) {
585        }
586    }
587
588    /**
589     * {@hide}
590     */
591    public ConnectivityManager(IConnectivityManager service) {
592        mService = checkNotNull(service, "missing IConnectivityManager");
593    }
594
595    /**
596     * {@hide}
597     */
598    public String[] getTetherableIfaces() {
599        try {
600            return mService.getTetherableIfaces();
601        } catch (RemoteException e) {
602            return new String[0];
603        }
604    }
605
606    /**
607     * {@hide}
608     */
609    public String[] getTetheredIfaces() {
610        try {
611            return mService.getTetheredIfaces();
612        } catch (RemoteException e) {
613            return new String[0];
614        }
615    }
616
617    /**
618     * {@hide}
619     */
620    public String[] getTetheringErroredIfaces() {
621        try {
622            return mService.getTetheringErroredIfaces();
623        } catch (RemoteException e) {
624            return new String[0];
625        }
626    }
627
628    /**
629     * @return error A TETHER_ERROR value indicating success or failure type
630     * {@hide}
631     */
632    public int tether(String iface) {
633        try {
634            return mService.tether(iface);
635        } catch (RemoteException e) {
636            return TETHER_ERROR_SERVICE_UNAVAIL;
637        }
638    }
639
640    /**
641     * @return error A TETHER_ERROR value indicating success or failure type
642     * {@hide}
643     */
644    public int untether(String iface) {
645        try {
646            return mService.untether(iface);
647        } catch (RemoteException e) {
648            return TETHER_ERROR_SERVICE_UNAVAIL;
649        }
650    }
651
652    /**
653     * {@hide}
654     */
655    public boolean isTetheringSupported() {
656        try {
657            return mService.isTetheringSupported();
658        } catch (RemoteException e) {
659            return false;
660        }
661    }
662
663    /**
664     * {@hide}
665     */
666    public String[] getTetherableUsbRegexs() {
667        try {
668            return mService.getTetherableUsbRegexs();
669        } catch (RemoteException e) {
670            return new String[0];
671        }
672    }
673
674    /**
675     * {@hide}
676     */
677    public String[] getTetherableWifiRegexs() {
678        try {
679            return mService.getTetherableWifiRegexs();
680        } catch (RemoteException e) {
681            return new String[0];
682        }
683    }
684
685    /**
686     * {@hide}
687     */
688    public String[] getTetherableBluetoothRegexs() {
689        try {
690            return mService.getTetherableBluetoothRegexs();
691        } catch (RemoteException e) {
692            return new String[0];
693        }
694    }
695
696    /**
697     * {@hide}
698     */
699    public int setUsbTethering(boolean enable) {
700        try {
701            return mService.setUsbTethering(enable);
702        } catch (RemoteException e) {
703            return TETHER_ERROR_SERVICE_UNAVAIL;
704        }
705    }
706
707    /** {@hide} */
708    public static final int TETHER_ERROR_NO_ERROR           = 0;
709    /** {@hide} */
710    public static final int TETHER_ERROR_UNKNOWN_IFACE      = 1;
711    /** {@hide} */
712    public static final int TETHER_ERROR_SERVICE_UNAVAIL    = 2;
713    /** {@hide} */
714    public static final int TETHER_ERROR_UNSUPPORTED        = 3;
715    /** {@hide} */
716    public static final int TETHER_ERROR_UNAVAIL_IFACE      = 4;
717    /** {@hide} */
718    public static final int TETHER_ERROR_MASTER_ERROR       = 5;
719    /** {@hide} */
720    public static final int TETHER_ERROR_TETHER_IFACE_ERROR = 6;
721    /** {@hide} */
722    public static final int TETHER_ERROR_UNTETHER_IFACE_ERROR = 7;
723    /** {@hide} */
724    public static final int TETHER_ERROR_ENABLE_NAT_ERROR     = 8;
725    /** {@hide} */
726    public static final int TETHER_ERROR_DISABLE_NAT_ERROR    = 9;
727    /** {@hide} */
728    public static final int TETHER_ERROR_IFACE_CFG_ERROR      = 10;
729
730    /**
731     * @param iface The name of the interface we're interested in
732     * @return error The error code of the last error tethering or untethering the named
733     *               interface
734     * {@hide}
735     */
736    public int getLastTetherError(String iface) {
737        try {
738            return mService.getLastTetherError(iface);
739        } catch (RemoteException e) {
740            return TETHER_ERROR_SERVICE_UNAVAIL;
741        }
742    }
743
744    /**
745     * Ensure the device stays awake until we connect with the next network
746     * @param forWhome The name of the network going down for logging purposes
747     * @return {@code true} on success, {@code false} on failure
748     * {@hide}
749     */
750    public boolean requestNetworkTransitionWakelock(String forWhom) {
751        try {
752            mService.requestNetworkTransitionWakelock(forWhom);
753            return true;
754        } catch (RemoteException e) {
755            return false;
756        }
757    }
758
759    /**
760     * @param networkType The type of network you want to report on
761     * @param percentage The quality of the connection 0 is bad, 100 is good
762     * {@hide}
763     */
764    public void reportInetCondition(int networkType, int percentage) {
765        try {
766            mService.reportInetCondition(networkType, percentage);
767        } catch (RemoteException e) {
768        }
769    }
770
771    /**
772     * @param proxyProperties The definition for the new global http proxy
773     * {@hide}
774     */
775    public void setGlobalProxy(ProxyProperties p) {
776        try {
777            mService.setGlobalProxy(p);
778        } catch (RemoteException e) {
779        }
780    }
781
782    /**
783     * @return proxyProperties for the current global proxy
784     * {@hide}
785     */
786    public ProxyProperties getGlobalProxy() {
787        try {
788            return mService.getGlobalProxy();
789        } catch (RemoteException e) {
790            return null;
791        }
792    }
793
794    /**
795     * @return proxyProperties for the current proxy (global if set, network specific if not)
796     * {@hide}
797     */
798    public ProxyProperties getProxy() {
799        try {
800            return mService.getProxy();
801        } catch (RemoteException e) {
802            return null;
803        }
804    }
805
806    /**
807     * @param networkType The network who's dependence has changed
808     * @param met Boolean - true if network use is ok, false if not
809     * {@hide}
810     */
811    public void setDataDependency(int networkType, boolean met) {
812        try {
813            mService.setDataDependency(networkType, met);
814        } catch (RemoteException e) {
815        }
816    }
817}
818