ConnectivityManager.java revision 97ab2d4f86ee9c2b661a00688e934fc7030df22e
19066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project/*
29066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Copyright (C) 2008 The Android Open Source Project
39066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
49066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License");
59066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * you may not use this file except in compliance with the License.
69066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * You may obtain a copy of the License at
79066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
89066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *      http://www.apache.org/licenses/LICENSE-2.0
99066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project *
109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Unless required by applicable law or agreed to in writing, software
119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS,
129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * See the License for the specific language governing permissions and
149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * limitations under the License.
159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */
169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectpackage android.net;
189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.annotation.SdkConstant;
209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.annotation.SdkConstant.SdkConstantType;
2142acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwaltimport android.os.Binder;
229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.os.RemoteException;
239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
24585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwaltimport java.net.InetAddress;
25585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwaltimport java.net.UnknownHostException;
26585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt
279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project/**
289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Class that answers queries about the state of network connectivity. It also
299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * notifies applications when network connectivity changes. Get an instance
309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * of this class by calling
319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.content.Context#getSystemService(String) Context.getSystemService(Context.CONNECTIVITY_SERVICE)}.
329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p>
339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * The primary responsibilities of this class are to:
349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <ol>
359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Monitor network connections (Wi-Fi, GPRS, UMTS, etc.)</li>
369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Send broadcast intents when network connectivity changes</li>
379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Attempt to "fail over" to another network when connectivity to a network
389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * is lost</li>
399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Provide an API that allows applications to query the coarse-grained or fine-grained
409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * state of the available networks</li>
419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </ol>
429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */
439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectpublic class ConnectivityManager
449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project{
459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * A change in network connectivity has occurred. A connection has either
479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * been established or lost. The NetworkInfo for the affected network is
489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * sent as an extra; it should be consulted to see what kind of
499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * connectivity event occurred.
509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * <p/>
519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * If this is a connection that was the result of failing over from a
529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * disconnected network, then the FAILOVER_CONNECTION boolean extra is
539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * set to true.
549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * <p/>
559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * For a loss of connectivity, if the connectivity manager is attempting
569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * to connect (or has already connected) to another network, the
579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * NetworkInfo for the new network is also passed as an extra. This lets
589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * any receivers of the broadcast know that they should not necessarily
599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * tell the user that no data traffic will be possible. Instead, the
609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * reciever should expect another broadcast soon, indicating either that
619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * the failover attempt succeeded (and so there is still overall data
629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * connectivity), or that the failover attempt failed, meaning that all
639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * connectivity has been lost.
649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * <p/>
659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * For a disconnect event, the boolean extra EXTRA_NO_CONNECTIVITY
669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * is set to {@code true} if there are no connected networks at all.
679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final String CONNECTIVITY_ACTION = "android.net.conn.CONNECTIVITY_CHANGE";
699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * The lookup key for a {@link NetworkInfo} object. Retrieve with
719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * {@link android.content.Intent#getParcelableExtra(String)}.
729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final String EXTRA_NETWORK_INFO = "networkInfo";
749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * The lookup key for a boolean that indicates whether a connect event
769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * is for a network to which the connectivity manager was failing over
779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * following a disconnect on another network.
789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Retrieve it with {@link android.content.Intent#getBooleanExtra(String,boolean)}.
799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final String EXTRA_IS_FAILOVER = "isFailover";
819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * The lookup key for a {@link NetworkInfo} object. This is supplied when
839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * there is another network that it may be possible to connect to. Retrieve with
849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * {@link android.content.Intent#getParcelableExtra(String)}.
859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final String EXTRA_OTHER_NETWORK_INFO = "otherNetwork";
879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * The lookup key for a boolean that indicates whether there is a
899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * complete lack of connectivity, i.e., no network is available.
909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Retrieve it with {@link android.content.Intent#getBooleanExtra(String,boolean)}.
919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final String EXTRA_NO_CONNECTIVITY = "noConnectivity";
939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * The lookup key for a string that indicates why an attempt to connect
959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * to a network failed. The string has no particular structure. It is
969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * intended to be used in notifications presented to users. Retrieve
979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * it with {@link android.content.Intent#getStringExtra(String)}.
989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final String EXTRA_REASON = "reason";
1009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
1019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * The lookup key for a string that provides optionally supplied
1029066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * extra information about the network state. The information
1039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * may be passed up from the lower networking layers, and its
1049066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * meaning may be specific to a particular network type. Retrieve
1059066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * it with {@link android.content.Intent#getStringExtra(String)}.
1069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
1079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final String EXTRA_EXTRA_INFO = "extraInfo";
108d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt    /**
109d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt     * The lookup key for an int that provides information about
110d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt     * our connection to the internet at large.  0 indicates no connection,
111d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt     * 100 indicates a great connection.  Retrieve it with
112d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt     * {@link android.content.Intent@getIntExtra(String)}.
113d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt     * {@hide}
114d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt     */
115d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt    public static final String EXTRA_INET_CONDITION = "inetCondition";
1169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
1179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
1189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Broadcast Action: The setting for background data usage has changed
1199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * values. Use {@link #getBackgroundDataSetting()} to get the current value.
1209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * <p>
1219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * If an application uses the network in the background, it should listen
1229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * for this broadcast and stop using the background data if the value is
1239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * false.
1249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
1259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
1269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final String ACTION_BACKGROUND_DATA_SETTING_CHANGED =
1279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            "android.net.conn.BACKGROUND_DATA_SETTING_CHANGED";
1289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
1291e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt
1301e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt    /**
1311e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt     * Broadcast Action: The network connection may not be good
1321e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt     * uses {@code ConnectivityManager.EXTRA_INET_CONDITION} and
1331e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt     * {@code ConnectivityManager.EXTRA_NETWORK_INFO} to specify
1341e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt     * the network and it's condition.
1351e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt     * @hide
1361e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt     */
1371e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt    public static final String INET_CONDITION_ACTION =
1381e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt            "android.net.conn.INET_CONDITION_ACTION";
1391e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt
14042acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt    /**
141d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt     * Broadcast Action: A tetherable connection has come or gone
142d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt     * TODO - finish the doc
143d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt     * @hide
144d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt     */
145d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt    public static final String ACTION_TETHER_STATE_CHANGED =
146d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt            "android.net.conn.TETHER_STATE_CHANGED";
147d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt
148d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt    /**
149d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt     * @hide
1502a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt     * gives a String[]
151d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt     */
1522a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt    public static final String EXTRA_AVAILABLE_TETHER = "availableArray";
153d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt
154d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt    /**
155d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt     * @hide
1562a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt     * gives a String[]
157d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt     */
1582a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt    public static final String EXTRA_ACTIVE_TETHER = "activeArray";
1592a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt
1602a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt    /**
1612a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt     * @hide
1622a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt     * gives a String[]
1632a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt     */
1642a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt    public static final String EXTRA_ERRORED_TETHER = "erroredArray";
165d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt
166d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt    /**
16742acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt     * The Default Mobile data connection.  When active, all data traffic
16897ab2d4f86ee9c2b661a00688e934fc7030df22eRobert Greenwalt     * will use this connection by default.
16942acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt     */
17042acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt    public static final int TYPE_MOBILE      = 0;
17142acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt    /**
17242acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt     * The Default WIFI data connection.  When active, all data traffic
17397ab2d4f86ee9c2b661a00688e934fc7030df22eRobert Greenwalt     * will use this connection by default.
17442acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt     */
17542acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt    public static final int TYPE_WIFI        = 1;
17642acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt    /**
17742acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt     * An MMS-specific Mobile data connection.  This connection may be the
1781bc3c3775b7b2cbaec50cd377db437f284478de0Robert Greenwalt     * same as {@link #TYPE_MOBILE} but it may be different.  This is used
17942acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt     * by applications needing to talk to the carrier's Multimedia Messaging
18042acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt     * Service servers.  It may coexist with default data connections.
18142acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt     */
18242acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt    public static final int TYPE_MOBILE_MMS  = 2;
18342acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt    /**
18442acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt     * A SUPL-specific Mobile data connection.  This connection may be the
1851bc3c3775b7b2cbaec50cd377db437f284478de0Robert Greenwalt     * same as {@link #TYPE_MOBILE} but it may be different.  This is used
18642acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt     * by applications needing to talk to the carrier's Secure User Plane
18742acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt     * Location servers for help locating the device.  It may coexist with
18842acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt     * default data connections.
18942acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt     */
19042acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt    public static final int TYPE_MOBILE_SUPL = 3;
19142acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt    /**
19242acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt     * A DUN-specific Mobile data connection.  This connection may be the
1931bc3c3775b7b2cbaec50cd377db437f284478de0Robert Greenwalt     * same as {@link #TYPE_MOBILE} but it may be different.  This is used
19442acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt     * by applicaitons performing a Dial Up Networking bridge so that
19542acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt     * the carrier is aware of DUN traffic.  It may coexist with default data
19642acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt     * connections.
19742acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt     */
19842acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt    public static final int TYPE_MOBILE_DUN  = 4;
19942acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt    /**
20042acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt     * A High Priority Mobile data connection.  This connection is typically
2011bc3c3775b7b2cbaec50cd377db437f284478de0Robert Greenwalt     * the same as {@link #TYPE_MOBILE} but the routing setup is different.
20242acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt     * Only requesting processes will have access to the Mobile DNS servers
20342acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt     * and only IP's explicitly requested via {@link #requestRouteToHost}
204c849cdf5cfde007ce591838c4e2b777fb4843c8dRobert Greenwalt     * will route over this interface if a default route exists.
20542acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt     */
20642acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt    public static final int TYPE_MOBILE_HIPRI = 5;
2078214deb542392f48b6c3fdc377fdf976c0b17a32jsh    /**
2088214deb542392f48b6c3fdc377fdf976c0b17a32jsh     * The Default WiMAX data connection.  When active, all data traffic
20997ab2d4f86ee9c2b661a00688e934fc7030df22eRobert Greenwalt     * will use this connection by default.
2108214deb542392f48b6c3fdc377fdf976c0b17a32jsh     */
2118214deb542392f48b6c3fdc377fdf976c0b17a32jsh    public static final int TYPE_WIMAX       = 6;
212da3d5e6587c1476d489495ac93e84ebf223024c9Robert Greenwalt
21315c7439acb22ab079dd2ebe42bdf0d2ffd525c5dJaikumar Ganesh    /**
21497ab2d4f86ee9c2b661a00688e934fc7030df22eRobert Greenwalt     * The Default Bluetooth data connection. When active, all data traffic
21597ab2d4f86ee9c2b661a00688e934fc7030df22eRobert Greenwalt     * will use this connection by default.
21615c7439acb22ab079dd2ebe42bdf0d2ffd525c5dJaikumar Ganesh     */
21715c7439acb22ab079dd2ebe42bdf0d2ffd525c5dJaikumar Ganesh    public static final int TYPE_BLUETOOTH   = 7;
21815c7439acb22ab079dd2ebe42bdf0d2ffd525c5dJaikumar Ganesh
219da3d5e6587c1476d489495ac93e84ebf223024c9Robert Greenwalt    /** {@hide} */
22015c7439acb22ab079dd2ebe42bdf0d2ffd525c5dJaikumar Ganesh    public static final int TYPE_DUMMY       = 8;
22197ab2d4f86ee9c2b661a00688e934fc7030df22eRobert Greenwalt    /**
22297ab2d4f86ee9c2b661a00688e934fc7030df22eRobert Greenwalt     * The Default Ethernet data connection.  When active, all data traffic
22397ab2d4f86ee9c2b661a00688e934fc7030df22eRobert Greenwalt     * will use this connection by default.
22497ab2d4f86ee9c2b661a00688e934fc7030df22eRobert Greenwalt     */
225e12aec941dfc93b76b5efb9bc9f30d2ba3469434Robert Greenwalt    public static final int TYPE_ETHERNET    = 9;
226eca208fae6d1b6ae9c8c0e42eee092e86dbddbb7Wink Saville    /** {@hide} TODO: Need to adjust this for WiMAX. */
22708c39c6a11f728e113811a6a85c109cfc80ce28eBenoit Goby    public static final int MAX_RADIO_TYPE   = TYPE_ETHERNET;
228eca208fae6d1b6ae9c8c0e42eee092e86dbddbb7Wink Saville    /** {@hide} TODO: Need to adjust this for WiMAX. */
22908c39c6a11f728e113811a6a85c109cfc80ce28eBenoit Goby    public static final int MAX_NETWORK_TYPE = TYPE_ETHERNET;
2309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
2319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public static final int DEFAULT_NETWORK_PREFERENCE = TYPE_WIFI;
2329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
2339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    private IConnectivityManager mService;
2349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
2359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    static public boolean isNetworkTypeValid(int networkType) {
23642acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt        return networkType >= 0 && networkType <= MAX_NETWORK_TYPE;
2379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
2389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
2399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void setNetworkPreference(int preference) {
2409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        try {
2419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            mService.setNetworkPreference(preference);
2429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        } catch (RemoteException e) {
2439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
2449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
2459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
2469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public int getNetworkPreference() {
2479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        try {
2489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            return mService.getNetworkPreference();
2499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        } catch (RemoteException e) {
2509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            return -1;
2519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
2529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
2539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
2549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public NetworkInfo getActiveNetworkInfo() {
2559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        try {
2569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            return mService.getActiveNetworkInfo();
2579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        } catch (RemoteException e) {
2589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            return null;
2599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
2609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
2619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
2629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public NetworkInfo getNetworkInfo(int networkType) {
2639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        try {
2649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            return mService.getNetworkInfo(networkType);
2659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        } catch (RemoteException e) {
2669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            return null;
2679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
2689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
2699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
2709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public NetworkInfo[] getAllNetworkInfo() {
2719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        try {
2729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            return mService.getAllNetworkInfo();
2739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        } catch (RemoteException e) {
2749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            return null;
2759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
2769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
2779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
278d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt    /** @hide */
279d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt    public LinkProperties getActiveLinkProperties() {
280d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt        try {
281d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt            return mService.getActiveLinkProperties();
282d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt        } catch (RemoteException e) {
283d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt            return null;
284d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt        }
285d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt    }
286d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt
287d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt    /** @hide */
288d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt    public LinkProperties getLinkProperties(int networkType) {
289d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt        try {
290d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt            return mService.getLinkProperties(networkType);
291d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt        } catch (RemoteException e) {
292d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt            return null;
293d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt        }
294d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt    }
295d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt
2969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /** {@hide} */
2979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public boolean setRadios(boolean turnOn) {
2989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        try {
2999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            return mService.setRadios(turnOn);
3009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        } catch (RemoteException e) {
3019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            return false;
3029066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
3039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
3049066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
3059066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /** {@hide} */
3069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public boolean setRadio(int networkType, boolean turnOn) {
3079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        try {
3089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            return mService.setRadio(networkType, turnOn);
3099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        } catch (RemoteException e) {
3109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            return false;
3119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
3129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
3139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
3149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
3159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Tells the underlying networking system that the caller wants to
3169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * begin using the named feature. The interpretation of {@code feature}
3179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * is completely up to each networking implementation.
3189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param networkType specifies which network the request pertains to
3199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param feature the name of the feature to be used
3209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @return an integer value representing the outcome of the request.
3219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * The interpretation of this value is specific to each networking
3229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * implementation+feature combination, except that the value {@code -1}
3239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * always indicates failure.
3249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
3259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public int startUsingNetworkFeature(int networkType, String feature) {
3269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        try {
32742acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt            return mService.startUsingNetworkFeature(networkType, feature,
32842acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt                    new Binder());
3299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        } catch (RemoteException e) {
3309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            return -1;
3319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
3329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
3339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
3349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
3359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Tells the underlying networking system that the caller is finished
3369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * using the named feature. The interpretation of {@code feature}
3379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * is completely up to each networking implementation.
3389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param networkType specifies which network the request pertains to
3399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param feature the name of the feature that is no longer needed
3409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @return an integer value representing the outcome of the request.
3419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * The interpretation of this value is specific to each networking
3429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * implementation+feature combination, except that the value {@code -1}
3439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * always indicates failure.
3449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
3459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public int stopUsingNetworkFeature(int networkType, String feature) {
3469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        try {
3479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            return mService.stopUsingNetworkFeature(networkType, feature);
3489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        } catch (RemoteException e) {
3499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            return -1;
3509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
3519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
3529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
3539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
3549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Ensure that a network route exists to deliver traffic to the specified
3559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * host via the specified network interface. An attempt to add a route that
3569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * already exists is ignored, but treated as successful.
3579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param networkType the type of the network over which traffic to the specified
3589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * host is to be routed
3599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param hostAddress the IP address of the host to which the route is desired
3609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @return {@code true} on success, {@code false} on failure
3619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
3629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public boolean requestRouteToHost(int networkType, int hostAddress) {
363585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt        InetAddress inetAddress = NetworkUtils.intToInetAddress(hostAddress);
364585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt
365585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt        if (inetAddress == null) {
366585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt            return false;
367585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt        }
368585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt
369585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt        return requestRouteToHostAddress(networkType, inetAddress);
370585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt    }
371585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt
372585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt    /**
373585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt     * Ensure that a network route exists to deliver traffic to the specified
374585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt     * host via the specified network interface. An attempt to add a route that
375585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt     * already exists is ignored, but treated as successful.
376585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt     * @param networkType the type of the network over which traffic to the specified
377585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt     * host is to be routed
378585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt     * @param hostAddress the IP address of the host to which the route is desired
379585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt     * @return {@code true} on success, {@code false} on failure
380585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt     * @hide
381585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt     */
382585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt    public boolean requestRouteToHostAddress(int networkType, InetAddress hostAddress) {
383585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt        byte[] address = hostAddress.getAddress();
3849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        try {
385585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt            return mService.requestRouteToHostAddress(networkType, address);
3869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        } catch (RemoteException e) {
3879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            return false;
3889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
3899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
3909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
3919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
3929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Returns the value of the setting for background data usage. If false,
3939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * applications should not use the network if the application is not in the
3949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * foreground. Developers should respect this setting, and check the value
3959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * of this before performing any background data operations.
3969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * <p>
3979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * All applications that have background services that use the network
3989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * should listen to {@link #ACTION_BACKGROUND_DATA_SETTING_CHANGED}.
3996fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang     *
4009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @return Whether background data usage is allowed.
4019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
4029066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public boolean getBackgroundDataSetting() {
4039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        try {
4049066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            return mService.getBackgroundDataSetting();
4059066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        } catch (RemoteException e) {
4066fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang            // Err on the side of safety
4079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            return false;
4089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
4099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
4109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
4119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
4129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Sets the value of the setting for background data usage.
413c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt     *
4149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @param allowBackgroundData Whether an application should use data while
4159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     *            it is in the background.
416c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt     *
4179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @attr ref android.Manifest.permission#CHANGE_BACKGROUND_DATA_SETTING
4189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @see #getBackgroundDataSetting()
4199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * @hide
4209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
4219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public void setBackgroundDataSetting(boolean allowBackgroundData) {
4229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        try {
4239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            mService.setBackgroundDataSetting(allowBackgroundData);
4249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        } catch (RemoteException e) {
4259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
4269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
427c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt
428c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt    /**
429c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt     * Gets the value of the setting for enabling Mobile data.
430c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt     *
431c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt     * @return Whether mobile data is enabled.
432c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt     * @hide
433c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt     */
434c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt    public boolean getMobileDataEnabled() {
435c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt        try {
436c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt            return mService.getMobileDataEnabled();
437c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt        } catch (RemoteException e) {
438c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt            return true;
439c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt        }
440c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt    }
441c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt
442c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt    /**
443c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt     * Sets the persisted value for enabling/disabling Mobile data.
444c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt     *
4455a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt     * @param enabled Whether the mobile data connection should be
446c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt     *            used or not.
447c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt     * @hide
448c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt     */
449c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt    public void setMobileDataEnabled(boolean enabled) {
450c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt        try {
451c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt            mService.setMobileDataEnabled(enabled);
452c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt        } catch (RemoteException e) {
453c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt        }
454c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt    }
455c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt
4569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
4579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * Don't allow use of default constructor.
4589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
4599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    @SuppressWarnings({"UnusedDeclaration"})
4609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    private ConnectivityManager() {
4619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
4629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project
4639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    /**
4649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     * {@hide}
4659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project     */
4669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    public ConnectivityManager(IConnectivityManager service) {
4679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        if (service == null) {
4689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project            throw new IllegalArgumentException(
4699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project                "ConnectivityManager() cannot be constructed with null service");
4709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        }
4719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project        mService = service;
4729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project    }
473d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt
474d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt    /**
475d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt     * {@hide}
476d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt     */
477d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt    public String[] getTetherableIfaces() {
478d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt        try {
479d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt            return mService.getTetherableIfaces();
480d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt        } catch (RemoteException e) {
481d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt            return new String[0];
482d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt        }
483d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt    }
484d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt
485d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt    /**
486d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt     * {@hide}
487d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt     */
488d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt    public String[] getTetheredIfaces() {
489d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt        try {
490d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt            return mService.getTetheredIfaces();
491d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt        } catch (RemoteException e) {
492d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt            return new String[0];
493d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt        }
494d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt    }
495d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt
496d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt    /**
497d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt     * {@hide}
498d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt     */
4995a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    public String[] getTetheringErroredIfaces() {
5005a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt        try {
5015a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt            return mService.getTetheringErroredIfaces();
5025a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt        } catch (RemoteException e) {
5035a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt            return new String[0];
5045a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt        }
5055a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    }
5065a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt
5075a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    /**
5085a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt     * @return error A TETHER_ERROR value indicating success or failure type
5095a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt     * {@hide}
5105a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt     */
5115a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    public int tether(String iface) {
512d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt        try {
513d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt            return mService.tether(iface);
514d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt        } catch (RemoteException e) {
5155a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt            return TETHER_ERROR_SERVICE_UNAVAIL;
516d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt        }
517d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt    }
518d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt
519d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt    /**
5205a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt     * @return error A TETHER_ERROR value indicating success or failure type
521d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt     * {@hide}
522d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt     */
5235a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    public int untether(String iface) {
524d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt        try {
525d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt            return mService.untether(iface);
526d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt        } catch (RemoteException e) {
5275a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt            return TETHER_ERROR_SERVICE_UNAVAIL;
528d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt        }
529d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt    }
5302a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt
5312a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt    /**
5322a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt     * {@hide}
5332a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt     */
5342a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt    public boolean isTetheringSupported() {
5352a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt        try {
5362a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt            return mService.isTetheringSupported();
5372a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt        } catch (RemoteException e) {
5382a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt            return false;
5392a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt        }
5402a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt    }
5412a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt
5422a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt    /**
5432a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt     * {@hide}
5442a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt     */
5452a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt    public String[] getTetherableUsbRegexs() {
5462a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt        try {
5472a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt            return mService.getTetherableUsbRegexs();
5482a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt        } catch (RemoteException e) {
5492a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt            return new String[0];
5502a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt        }
5512a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt    }
5522a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt
5532a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt    /**
5542a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt     * {@hide}
5552a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt     */
5562a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt    public String[] getTetherableWifiRegexs() {
5572a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt        try {
5582a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt            return mService.getTetherableWifiRegexs();
5592a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt        } catch (RemoteException e) {
5602a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt            return new String[0];
5612a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt        }
5622a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt    }
5635a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt
5646fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang    /**
5656fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang     * {@hide}
5666fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang     */
5676fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang    public String[] getTetherableBluetoothRegexs() {
5686fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang        try {
5696fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang            return mService.getTetherableBluetoothRegexs();
5706fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang        } catch (RemoteException e) {
5716fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang            return new String[0];
5726fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang        }
5736fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang    }
5746fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang
5755a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    /** {@hide} */
5765a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    public static final int TETHER_ERROR_NO_ERROR           = 0;
5775a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    /** {@hide} */
5785a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    public static final int TETHER_ERROR_UNKNOWN_IFACE      = 1;
5795a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    /** {@hide} */
5805a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    public static final int TETHER_ERROR_SERVICE_UNAVAIL    = 2;
5815a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    /** {@hide} */
5825a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    public static final int TETHER_ERROR_UNSUPPORTED        = 3;
5835a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    /** {@hide} */
5845a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    public static final int TETHER_ERROR_UNAVAIL_IFACE      = 4;
5855a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    /** {@hide} */
5865a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    public static final int TETHER_ERROR_MASTER_ERROR       = 5;
5875a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    /** {@hide} */
5885a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    public static final int TETHER_ERROR_TETHER_IFACE_ERROR = 6;
5895a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    /** {@hide} */
5905a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    public static final int TETHER_ERROR_UNTETHER_IFACE_ERROR = 7;
5915a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    /** {@hide} */
5925a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    public static final int TETHER_ERROR_ENABLE_NAT_ERROR     = 8;
5935a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    /** {@hide} */
5945a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    public static final int TETHER_ERROR_DISABLE_NAT_ERROR    = 9;
5955a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    /** {@hide} */
5965a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    public static final int TETHER_ERROR_IFACE_CFG_ERROR      = 10;
5975a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt
5985a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    /**
5995a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt     * @param iface The name of the interface we're interested in
6005a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt     * @return error The error code of the last error tethering or untethering the named
6015a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt     *               interface
6025a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt     * {@hide}
6035a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt     */
6045a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt    public int getLastTetherError(String iface) {
6055a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt        try {
6065a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt            return mService.getLastTetherError(iface);
6075a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt        } catch (RemoteException e) {
6085a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt            return TETHER_ERROR_SERVICE_UNAVAIL;
6095a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt        }
61014f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt    }
61114f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt
61214f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt    /**
61314f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt     * Ensure the device stays awake until we connect with the next network
61414f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt     * @param forWhome The name of the network going down for logging purposes
61514f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt     * @return {@code true} on success, {@code false} on failure
61614f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt     * {@hide}
61714f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt     */
61814f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt    public boolean requestNetworkTransitionWakelock(String forWhom) {
61914f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt        try {
62014f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt            mService.requestNetworkTransitionWakelock(forWhom);
62114f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt            return true;
62214f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt        } catch (RemoteException e) {
62314f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt            return false;
62414f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt        }
62514f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt    }
626ca4306c976d393c3cd04270bc2de0af2f4f30fa5Robert Greenwalt
62767fd6c92922a94f46c7b6793a808f473a43eddd3Robert Greenwalt    /**
628d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt     * @param networkType The type of network you want to report on
629d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt     * @param percentage The quality of the connection 0 is bad, 100 is good
630d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt     * {@hide}
631d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt     */
632d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt    public void reportInetCondition(int networkType, int percentage) {
633d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt        try {
634d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt            mService.reportInetCondition(networkType, percentage);
635d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt        } catch (RemoteException e) {
636d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt        }
637d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt    }
638434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt
639434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt    /**
640434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt     * @param proxyProperties The definition for the new global http proxy
641434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt     * {@hide}
642434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt     */
643434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt    public void setGlobalProxy(ProxyProperties p) {
644434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt        try {
645434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt            mService.setGlobalProxy(p);
646434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt        } catch (RemoteException e) {
647434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt        }
648434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt    }
649434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt
650434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt    /**
651434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt     * @return proxyProperties for the current global proxy
652434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt     * {@hide}
653434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt     */
654434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt    public ProxyProperties getGlobalProxy() {
655434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt        try {
656434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt            return mService.getGlobalProxy();
657434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt        } catch (RemoteException e) {
658434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt            return null;
659434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt        }
660434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt    }
661434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt
662434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt    /**
663434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt     * @return proxyProperties for the current proxy (global if set, network specific if not)
664434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt     * {@hide}
665434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt     */
666434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt    public ProxyProperties getProxy() {
667434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt        try {
668434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt            return mService.getProxy();
669434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt        } catch (RemoteException e) {
670434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt            return null;
671434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt        }
672434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt    }
6739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project}
674