ConnectivityManager.java revision d2a458750e5a3d490af09cecb5c28370baf0a913
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 Greenwalt 269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project/** 279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Class that answers queries about the state of network connectivity. It also 289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * notifies applications when network connectivity changes. Get an instance 299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * of this class by calling 309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.content.Context#getSystemService(String) Context.getSystemService(Context.CONNECTIVITY_SERVICE)}. 319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p> 329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * The primary responsibilities of this class are to: 339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <ol> 349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Monitor network connections (Wi-Fi, GPRS, UMTS, etc.)</li> 359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Send broadcast intents when network connectivity changes</li> 369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Attempt to "fail over" to another network when connectivity to a network 379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * is lost</li> 389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Provide an API that allows applications to query the coarse-grained or fine-grained 399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * state of the available networks</li> 409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </ol> 419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 42c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkeypublic class ConnectivityManager { 43c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey private static final String TAG = "ConnectivityManager"; 44c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey 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 112c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey * {@link android.content.Intent#getIntExtra(String, int)}. 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 123c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey * {@code 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 * Broadcast Action: The network connection may not be good 1311e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt * uses {@code ConnectivityManager.EXTRA_INET_CONDITION} and 1321e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt * {@code ConnectivityManager.EXTRA_NETWORK_INFO} to specify 1331e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt * the network and it's condition. 1341e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt * @hide 1351e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt */ 1361e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt public static final String INET_CONDITION_ACTION = 1371e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt "android.net.conn.INET_CONDITION_ACTION"; 1381e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt 13942acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt /** 140d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt * Broadcast Action: A tetherable connection has come or gone 141d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt * TODO - finish the doc 142d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt * @hide 143d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt */ 144d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt public static final String ACTION_TETHER_STATE_CHANGED = 145d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt "android.net.conn.TETHER_STATE_CHANGED"; 146d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt 147d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt /** 148d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt * @hide 1492a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt * gives a String[] 150d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt */ 1512a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt public static final String EXTRA_AVAILABLE_TETHER = "availableArray"; 152d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt 153d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt /** 154d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt * @hide 1552a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt * gives a String[] 156d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt */ 1572a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt public static final String EXTRA_ACTIVE_TETHER = "activeArray"; 1582a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt 1592a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt /** 1602a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt * @hide 1612a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt * gives a String[] 1622a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt */ 1632a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt public static final String EXTRA_ERRORED_TETHER = "erroredArray"; 164d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt 165d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt /** 16642acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * The Default Mobile data connection. When active, all data traffic 16742acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * will use this connection by default. Should not coexist with other 16842acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * default connections. 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 17342acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * will use this connection by default. Should not coexist with other 17442acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * default connections. 17542acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt */ 17642acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt public static final int TYPE_WIFI = 1; 17742acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt /** 17842acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * An MMS-specific Mobile data connection. This connection may be the 1791bc3c3775b7b2cbaec50cd377db437f284478de0Robert Greenwalt * same as {@link #TYPE_MOBILE} but it may be different. This is used 18042acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * by applications needing to talk to the carrier's Multimedia Messaging 18142acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * Service servers. It may coexist with default data connections. 18242acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt */ 18342acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt public static final int TYPE_MOBILE_MMS = 2; 18442acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt /** 18542acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * A SUPL-specific Mobile data connection. This connection may be the 1861bc3c3775b7b2cbaec50cd377db437f284478de0Robert Greenwalt * same as {@link #TYPE_MOBILE} but it may be different. This is used 18742acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * by applications needing to talk to the carrier's Secure User Plane 18842acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * Location servers for help locating the device. It may coexist with 18942acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * default data connections. 19042acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt */ 19142acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt public static final int TYPE_MOBILE_SUPL = 3; 19242acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt /** 19342acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * A DUN-specific Mobile data connection. This connection may be the 1941bc3c3775b7b2cbaec50cd377db437f284478de0Robert Greenwalt * same as {@link #TYPE_MOBILE} but it may be different. This is used 19542acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * by applicaitons performing a Dial Up Networking bridge so that 19642acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * the carrier is aware of DUN traffic. It may coexist with default data 19742acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * connections. 19842acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt */ 19942acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt public static final int TYPE_MOBILE_DUN = 4; 20042acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt /** 20142acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * A High Priority Mobile data connection. This connection is typically 2021bc3c3775b7b2cbaec50cd377db437f284478de0Robert Greenwalt * the same as {@link #TYPE_MOBILE} but the routing setup is different. 20342acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * Only requesting processes will have access to the Mobile DNS servers 20442acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * and only IP's explicitly requested via {@link #requestRouteToHost} 205c849cdf5cfde007ce591838c4e2b777fb4843c8dRobert Greenwalt * will route over this interface if a default route exists. 20642acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt */ 20742acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt public static final int TYPE_MOBILE_HIPRI = 5; 2088214deb542392f48b6c3fdc377fdf976c0b17a32jsh /** 2098214deb542392f48b6c3fdc377fdf976c0b17a32jsh * The Default WiMAX data connection. When active, all data traffic 2108214deb542392f48b6c3fdc377fdf976c0b17a32jsh * will use this connection by default. Should not coexist with other 2118214deb542392f48b6c3fdc377fdf976c0b17a32jsh * default connections. 2128214deb542392f48b6c3fdc377fdf976c0b17a32jsh */ 2138214deb542392f48b6c3fdc377fdf976c0b17a32jsh public static final int TYPE_WIMAX = 6; 214da3d5e6587c1476d489495ac93e84ebf223024c9Robert Greenwalt 21515c7439acb22ab079dd2ebe42bdf0d2ffd525c5dJaikumar Ganesh /** 21615c7439acb22ab079dd2ebe42bdf0d2ffd525c5dJaikumar Ganesh * Bluetooth data connection. This is used for Bluetooth reverse tethering. 21715c7439acb22ab079dd2ebe42bdf0d2ffd525c5dJaikumar Ganesh */ 21815c7439acb22ab079dd2ebe42bdf0d2ffd525c5dJaikumar Ganesh public static final int TYPE_BLUETOOTH = 7; 21915c7439acb22ab079dd2ebe42bdf0d2ffd525c5dJaikumar Ganesh 2206081084e8831d12d2dd5a9a340ee7d35a54edb8aRobert Greenwalt /** 2216081084e8831d12d2dd5a9a340ee7d35a54edb8aRobert Greenwalt * Dummy data connection. This should not be used on shipping devices. 2226081084e8831d12d2dd5a9a340ee7d35a54edb8aRobert Greenwalt */ 22315c7439acb22ab079dd2ebe42bdf0d2ffd525c5dJaikumar Ganesh public static final int TYPE_DUMMY = 8; 2249d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville 2256081084e8831d12d2dd5a9a340ee7d35a54edb8aRobert Greenwalt /** 2266081084e8831d12d2dd5a9a340ee7d35a54edb8aRobert Greenwalt * Ethernet data connection. This may be via USB dongle or more 2276081084e8831d12d2dd5a9a340ee7d35a54edb8aRobert Greenwalt * traditional means. 2286081084e8831d12d2dd5a9a340ee7d35a54edb8aRobert Greenwalt */ 229e12aec941dfc93b76b5efb9bc9f30d2ba3469434Robert Greenwalt public static final int TYPE_ETHERNET = 9; 2306081084e8831d12d2dd5a9a340ee7d35a54edb8aRobert Greenwalt 2319d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville /** 2329d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville * Over the air Adminstration. 2339d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville * {@hide} 2349d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville */ 2359d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville public static final int TYPE_MOBILE_FOTA = 10; 2369d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville 2379d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville /** 2389d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville * IP Multimedia Subsystem 2399d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville * {@hide} 2409d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville */ 2419d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville public static final int TYPE_MOBILE_IMS = 11; 2429d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville 2439d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville /** 2449d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville * Carrier Branded Services 2459d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville * {@hide} 2469d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville */ 2479d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville public static final int TYPE_MOBILE_CBS = 12; 2489d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville 2499d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville /** {@hide} */ 2509d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville public static final int MAX_RADIO_TYPE = TYPE_MOBILE_CBS; 2519d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville 2529d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville /** {@hide} */ 2539d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville public static final int MAX_NETWORK_TYPE = TYPE_MOBILE_CBS; 2549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 2559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public static final int DEFAULT_NETWORK_PREFERENCE = TYPE_WIFI; 2569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 257c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey private final IConnectivityManager mService; 2589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 259d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey public static boolean isNetworkTypeValid(int networkType) { 26042acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt return networkType >= 0 && networkType <= MAX_NETWORK_TYPE; 2619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 2629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 263d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey /** {@hide} */ 264d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey public static String getNetworkTypeName(int type) { 265d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey switch (type) { 266d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE: 267d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return "MOBILE"; 268d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_WIFI: 269d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return "WIFI"; 270d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_MMS: 271d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return "MOBILE_MMS"; 272d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_SUPL: 273d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return "MOBILE_SUPL"; 274d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_DUN: 275d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return "MOBILE_DUN"; 276d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_HIPRI: 277d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return "MOBILE_HIPRI"; 278d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_WIMAX: 279d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return "WIMAX"; 280d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_BLUETOOTH: 281d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return "BLUETOOTH"; 282d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_DUMMY: 283d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return "DUMMY"; 284d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_ETHERNET: 285d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return "ETHERNET"; 286d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_FOTA: 287d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return "MOBILE_FOTA"; 288d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_IMS: 289d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return "MOBILE_IMS"; 290d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_CBS: 291d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return "MOBILE_CBS"; 292d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey default: 293d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return Integer.toString(type); 294d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey } 295d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey } 296d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey 297d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey /** {@hide} */ 298d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey public static boolean isNetworkTypeMobile(int networkType) { 299d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey switch (networkType) { 300d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE: 301d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_MMS: 302d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_SUPL: 303d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_DUN: 304d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_HIPRI: 305d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_FOTA: 306d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_IMS: 307d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_CBS: 308d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return true; 309d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey default: 310d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return false; 311d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey } 312d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey } 313d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey 3149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public void setNetworkPreference(int preference) { 3159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project try { 3169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project mService.setNetworkPreference(preference); 3179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } catch (RemoteException e) { 3189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 3199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 3209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 3219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public int getNetworkPreference() { 3229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project try { 3239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return mService.getNetworkPreference(); 3249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } catch (RemoteException e) { 3259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return -1; 3269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 3279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 3289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 3299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public NetworkInfo getActiveNetworkInfo() { 3309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project try { 3319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return mService.getActiveNetworkInfo(); 3329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } catch (RemoteException e) { 3339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return null; 3349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 3359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 3369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 337c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey /** {@hide} */ 338c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey public NetworkInfo getActiveNetworkInfoForUid(int uid) { 339c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey try { 340c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey return mService.getActiveNetworkInfoForUid(uid); 341c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey } catch (RemoteException e) { 342c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey return null; 343c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey } 344c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey } 345c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey 3469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public NetworkInfo getNetworkInfo(int networkType) { 3479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project try { 3489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return mService.getNetworkInfo(networkType); 3499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } catch (RemoteException e) { 3509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return null; 3519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 3529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 3539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 3549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public NetworkInfo[] getAllNetworkInfo() { 3559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project try { 3569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return mService.getAllNetworkInfo(); 3579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } catch (RemoteException e) { 3589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return null; 3599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 3609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 3619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 362c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey /** {@hide} */ 363d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt public LinkProperties getActiveLinkProperties() { 364d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt try { 365d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt return mService.getActiveLinkProperties(); 366d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt } catch (RemoteException e) { 367d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt return null; 368d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt } 369d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt } 370d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt 371c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey /** {@hide} */ 372d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt public LinkProperties getLinkProperties(int networkType) { 373d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt try { 374d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt return mService.getLinkProperties(networkType); 375d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt } catch (RemoteException e) { 376d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt return null; 377d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt } 378d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt } 379d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt 3809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** {@hide} */ 3819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public boolean setRadios(boolean turnOn) { 3829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project try { 3839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return mService.setRadios(turnOn); 3849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } catch (RemoteException e) { 3859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return false; 3869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 3879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 3889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 3899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** {@hide} */ 3909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public boolean setRadio(int networkType, boolean turnOn) { 3919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project try { 3929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return mService.setRadio(networkType, turnOn); 3939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } catch (RemoteException e) { 3949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return false; 3959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 3969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 3979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 3989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 3999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Tells the underlying networking system that the caller wants to 4009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * begin using the named feature. The interpretation of {@code feature} 4019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * is completely up to each networking implementation. 4029066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param networkType specifies which network the request pertains to 4039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param feature the name of the feature to be used 4049066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @return an integer value representing the outcome of the request. 4059066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * The interpretation of this value is specific to each networking 4069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * implementation+feature combination, except that the value {@code -1} 4079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * always indicates failure. 4089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 4099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public int startUsingNetworkFeature(int networkType, String feature) { 4109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project try { 41142acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt return mService.startUsingNetworkFeature(networkType, feature, 41242acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt new Binder()); 4139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } catch (RemoteException e) { 4149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return -1; 4159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 4169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 4179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 4189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 4199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Tells the underlying networking system that the caller is finished 4209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * using the named feature. The interpretation of {@code feature} 4219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * is completely up to each networking implementation. 4229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param networkType specifies which network the request pertains to 4239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param feature the name of the feature that is no longer needed 4249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @return an integer value representing the outcome of the request. 4259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * The interpretation of this value is specific to each networking 4269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * implementation+feature combination, except that the value {@code -1} 4279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * always indicates failure. 4289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 4299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public int stopUsingNetworkFeature(int networkType, String feature) { 4309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project try { 4319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return mService.stopUsingNetworkFeature(networkType, feature); 4329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } catch (RemoteException e) { 4339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return -1; 4349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 4359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 4369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 4379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 4389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Ensure that a network route exists to deliver traffic to the specified 4399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * host via the specified network interface. An attempt to add a route that 4409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * already exists is ignored, but treated as successful. 4419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param networkType the type of the network over which traffic to the specified 4429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * host is to be routed 4439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param hostAddress the IP address of the host to which the route is desired 4449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @return {@code true} on success, {@code false} on failure 4459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 4469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public boolean requestRouteToHost(int networkType, int hostAddress) { 447585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt InetAddress inetAddress = NetworkUtils.intToInetAddress(hostAddress); 448585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt 449585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt if (inetAddress == null) { 450585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt return false; 451585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt } 452585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt 453585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt return requestRouteToHostAddress(networkType, inetAddress); 454585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt } 455585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt 456585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt /** 457585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt * Ensure that a network route exists to deliver traffic to the specified 458585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt * host via the specified network interface. An attempt to add a route that 459585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt * already exists is ignored, but treated as successful. 460585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt * @param networkType the type of the network over which traffic to the specified 461585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt * host is to be routed 462585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt * @param hostAddress the IP address of the host to which the route is desired 463585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt * @return {@code true} on success, {@code false} on failure 464585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt * @hide 465585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt */ 466585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt public boolean requestRouteToHostAddress(int networkType, InetAddress hostAddress) { 467585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt byte[] address = hostAddress.getAddress(); 4689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project try { 469585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt return mService.requestRouteToHostAddress(networkType, address); 4709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } catch (RemoteException e) { 4719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return false; 4729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 4739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 4749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 4759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 4769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Returns the value of the setting for background data usage. If false, 4779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * applications should not use the network if the application is not in the 4789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * foreground. Developers should respect this setting, and check the value 4799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * of this before performing any background data operations. 4809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p> 4819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * All applications that have background services that use the network 4829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * should listen to {@link #ACTION_BACKGROUND_DATA_SETTING_CHANGED}. 4836fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang * 4849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @return Whether background data usage is allowed. 4859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 4869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public boolean getBackgroundDataSetting() { 4879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project try { 4889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return mService.getBackgroundDataSetting(); 4899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } catch (RemoteException e) { 4906fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang // Err on the side of safety 4919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return false; 4929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 4939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 4949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 4959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 4969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Sets the value of the setting for background data usage. 497c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt * 4989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param allowBackgroundData Whether an application should use data while 4999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * it is in the background. 500c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt * 5019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @attr ref android.Manifest.permission#CHANGE_BACKGROUND_DATA_SETTING 5029066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @see #getBackgroundDataSetting() 5039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @hide 5049066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 5059066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public void setBackgroundDataSetting(boolean allowBackgroundData) { 5069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project try { 5079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project mService.setBackgroundDataSetting(allowBackgroundData); 5089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } catch (RemoteException e) { 5099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 5109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 511c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt 512c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt /** 513c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt * Gets the value of the setting for enabling Mobile data. 514c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt * 515c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt * @return Whether mobile data is enabled. 516c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt * @hide 517c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt */ 518c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt public boolean getMobileDataEnabled() { 519c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt try { 520c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt return mService.getMobileDataEnabled(); 521c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt } catch (RemoteException e) { 522c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt return true; 523c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt } 524c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt } 525c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt 526c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt /** 527c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt * Sets the persisted value for enabling/disabling Mobile data. 528c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt * 5295a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt * @param enabled Whether the mobile data connection should be 530c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt * used or not. 531c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt * @hide 532c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt */ 533c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt public void setMobileDataEnabled(boolean enabled) { 534c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt try { 535c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt mService.setMobileDataEnabled(enabled); 536c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt } catch (RemoteException e) { 537c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt } 538c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt } 539c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt 5409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 5419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@hide} 5429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 5439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public ConnectivityManager(IConnectivityManager service) { 5449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project if (service == null) { 545c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey throw new IllegalArgumentException("missing IConnectivityManager"); 5469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 5479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project mService = service; 5489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 549d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt 550d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt /** 551d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt * {@hide} 552d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt */ 553d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt public String[] getTetherableIfaces() { 554d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt try { 555d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt return mService.getTetherableIfaces(); 556d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt } catch (RemoteException e) { 557d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt return new String[0]; 558d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt } 559d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt } 560d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt 561d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt /** 562d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt * {@hide} 563d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt */ 564d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt public String[] getTetheredIfaces() { 565d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt try { 566d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt return mService.getTetheredIfaces(); 567d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt } catch (RemoteException e) { 568d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt return new String[0]; 569d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt } 570d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt } 571d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt 572d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt /** 573d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt * {@hide} 574d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt */ 5755a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public String[] getTetheringErroredIfaces() { 5765a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt try { 5775a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt return mService.getTetheringErroredIfaces(); 5785a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt } catch (RemoteException e) { 5795a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt return new String[0]; 5805a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt } 5815a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt } 5825a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt 5835a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt /** 5845a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt * @return error A TETHER_ERROR value indicating success or failure type 5855a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt * {@hide} 5865a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt */ 5875a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public int tether(String iface) { 588d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt try { 589d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt return mService.tether(iface); 590d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt } catch (RemoteException e) { 5915a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt return TETHER_ERROR_SERVICE_UNAVAIL; 592d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt } 593d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt } 594d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt 595d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt /** 5965a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt * @return error A TETHER_ERROR value indicating success or failure type 597d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt * {@hide} 598d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt */ 5995a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public int untether(String iface) { 600d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt try { 601d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt return mService.untether(iface); 602d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt } catch (RemoteException e) { 6035a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt return TETHER_ERROR_SERVICE_UNAVAIL; 604d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt } 605d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt } 6062a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt 6072a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt /** 6082a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt * {@hide} 6092a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt */ 6102a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt public boolean isTetheringSupported() { 6112a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt try { 6122a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt return mService.isTetheringSupported(); 6132a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt } catch (RemoteException e) { 6142a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt return false; 6152a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt } 6162a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt } 6172a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt 6182a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt /** 6192a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt * {@hide} 6202a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt */ 6212a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt public String[] getTetherableUsbRegexs() { 6222a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt try { 6232a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt return mService.getTetherableUsbRegexs(); 6242a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt } catch (RemoteException e) { 6252a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt return new String[0]; 6262a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt } 6272a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt } 6282a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt 6292a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt /** 6302a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt * {@hide} 6312a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt */ 6322a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt public String[] getTetherableWifiRegexs() { 6332a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt try { 6342a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt return mService.getTetherableWifiRegexs(); 6352a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt } catch (RemoteException e) { 6362a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt return new String[0]; 6372a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt } 6382a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt } 6395a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt 6406fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang /** 6416fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang * {@hide} 6426fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang */ 6436fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang public String[] getTetherableBluetoothRegexs() { 6446fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang try { 6456fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang return mService.getTetherableBluetoothRegexs(); 6466fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang } catch (RemoteException e) { 6476fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang return new String[0]; 6486fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang } 6496fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang } 6506fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang 6515a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt /** {@hide} */ 6525a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public static final int TETHER_ERROR_NO_ERROR = 0; 6535a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt /** {@hide} */ 6545a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public static final int TETHER_ERROR_UNKNOWN_IFACE = 1; 6555a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt /** {@hide} */ 6565a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public static final int TETHER_ERROR_SERVICE_UNAVAIL = 2; 6575a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt /** {@hide} */ 6585a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public static final int TETHER_ERROR_UNSUPPORTED = 3; 6595a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt /** {@hide} */ 6605a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public static final int TETHER_ERROR_UNAVAIL_IFACE = 4; 6615a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt /** {@hide} */ 6625a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public static final int TETHER_ERROR_MASTER_ERROR = 5; 6635a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt /** {@hide} */ 6645a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public static final int TETHER_ERROR_TETHER_IFACE_ERROR = 6; 6655a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt /** {@hide} */ 6665a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public static final int TETHER_ERROR_UNTETHER_IFACE_ERROR = 7; 6675a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt /** {@hide} */ 6685a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public static final int TETHER_ERROR_ENABLE_NAT_ERROR = 8; 6695a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt /** {@hide} */ 6705a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public static final int TETHER_ERROR_DISABLE_NAT_ERROR = 9; 6715a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt /** {@hide} */ 6725a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public static final int TETHER_ERROR_IFACE_CFG_ERROR = 10; 6735a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt 6745a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt /** 6755a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt * @param iface The name of the interface we're interested in 6765a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt * @return error The error code of the last error tethering or untethering the named 6775a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt * interface 6785a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt * {@hide} 6795a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt */ 6805a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public int getLastTetherError(String iface) { 6815a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt try { 6825a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt return mService.getLastTetherError(iface); 6835a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt } catch (RemoteException e) { 6845a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt return TETHER_ERROR_SERVICE_UNAVAIL; 6855a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt } 68614f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt } 68714f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt 68814f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt /** 68914f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt * Ensure the device stays awake until we connect with the next network 69014f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt * @param forWhome The name of the network going down for logging purposes 69114f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt * @return {@code true} on success, {@code false} on failure 69214f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt * {@hide} 69314f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt */ 69414f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt public boolean requestNetworkTransitionWakelock(String forWhom) { 69514f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt try { 69614f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt mService.requestNetworkTransitionWakelock(forWhom); 69714f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt return true; 69814f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt } catch (RemoteException e) { 69914f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt return false; 70014f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt } 70114f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt } 702ca4306c976d393c3cd04270bc2de0af2f4f30fa5Robert Greenwalt 70367fd6c92922a94f46c7b6793a808f473a43eddd3Robert Greenwalt /** 704d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt * @param networkType The type of network you want to report on 705d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt * @param percentage The quality of the connection 0 is bad, 100 is good 706d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt * {@hide} 707d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt */ 708d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt public void reportInetCondition(int networkType, int percentage) { 709d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt try { 710d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt mService.reportInetCondition(networkType, percentage); 711d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt } catch (RemoteException e) { 712d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt } 713d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt } 714434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt 715434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt /** 716434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt * @param proxyProperties The definition for the new global http proxy 717434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt * {@hide} 718434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt */ 719434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt public void setGlobalProxy(ProxyProperties p) { 720434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt try { 721434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt mService.setGlobalProxy(p); 722434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt } catch (RemoteException e) { 723434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt } 724434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt } 725434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt 726434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt /** 727434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt * @return proxyProperties for the current global proxy 728434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt * {@hide} 729434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt */ 730434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt public ProxyProperties getGlobalProxy() { 731434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt try { 732434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt return mService.getGlobalProxy(); 733434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt } catch (RemoteException e) { 734434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt return null; 735434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt } 736434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt } 737434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt 738434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt /** 739434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt * @return proxyProperties for the current proxy (global if set, network specific if not) 740434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt * {@hide} 741434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt */ 742434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt public ProxyProperties getProxy() { 743434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt try { 744434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt return mService.getProxy(); 745434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt } catch (RemoteException e) { 746434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt return null; 747434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt } 748434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt } 749d55a6b498d66d8fc415908ecf63e50f46cce67e8Robert Greenwalt 750d55a6b498d66d8fc415908ecf63e50f46cce67e8Robert Greenwalt /** 751d55a6b498d66d8fc415908ecf63e50f46cce67e8Robert Greenwalt * @param networkType The network who's dependence has changed 752d55a6b498d66d8fc415908ecf63e50f46cce67e8Robert Greenwalt * @param met Boolean - true if network use is ok, false if not 753d55a6b498d66d8fc415908ecf63e50f46cce67e8Robert Greenwalt * {@hide} 754d55a6b498d66d8fc415908ecf63e50f46cce67e8Robert Greenwalt */ 755d55a6b498d66d8fc415908ecf63e50f46cce67e8Robert Greenwalt public void setDataDependency(int networkType, boolean met) { 756d55a6b498d66d8fc415908ecf63e50f46cce67e8Robert Greenwalt try { 757d55a6b498d66d8fc415908ecf63e50f46cce67e8Robert Greenwalt mService.setDataDependency(networkType, met); 758d55a6b498d66d8fc415908ecf63e50f46cce67e8Robert Greenwalt } catch (RemoteException e) { 759d55a6b498d66d8fc415908ecf63e50f46cce67e8Robert Greenwalt } 760d55a6b498d66d8fc415908ecf63e50f46cce67e8Robert Greenwalt } 7619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project} 762