ConnectivityManager.java revision 671644c3ef92a9153ea5bd495e132d5fe6674234
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 19f0ceede8fff5df24e5c98701d81c2b71eb138aa9Jeff Sharkeyimport static com.android.internal.util.Preconditions.checkNotNull; 20f0ceede8fff5df24e5c98701d81c2b71eb138aa9Jeff Sharkey 219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.annotation.SdkConstant; 229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.annotation.SdkConstant.SdkConstantType; 2342acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwaltimport android.os.Binder; 243a844fcf5a0e70a19c38dc500306b9ebe4e1413bJeff Sharkeyimport android.os.Build.VERSION_CODES; 259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.os.RemoteException; 26961e30458319cfd50e1892ba7dd14a1d0ebe4cc7Jeff Sharkeyimport android.provider.Settings; 279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 28585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwaltimport java.net.InetAddress; 29585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt 309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project/** 319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Class that answers queries about the state of network connectivity. It also 329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * notifies applications when network connectivity changes. Get an instance 339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * of this class by calling 349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.content.Context#getSystemService(String) Context.getSystemService(Context.CONNECTIVITY_SERVICE)}. 359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p> 369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * The primary responsibilities of this class are to: 379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <ol> 389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Monitor network connections (Wi-Fi, GPRS, UMTS, etc.)</li> 399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Send broadcast intents when network connectivity changes</li> 409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Attempt to "fail over" to another network when connectivity to a network 419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * is lost</li> 429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <li>Provide an API that allows applications to query the coarse-grained or fine-grained 439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * state of the available networks</li> 449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * </ol> 459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 46c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkeypublic class ConnectivityManager { 47c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey private static final String TAG = "ConnectivityManager"; 48c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey 499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * A change in network connectivity has occurred. A connection has either 519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * been established or lost. The NetworkInfo for the affected network is 529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * sent as an extra; it should be consulted to see what kind of 539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * connectivity event occurred. 549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p/> 559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * If this is a connection that was the result of failing over from a 569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * disconnected network, then the FAILOVER_CONNECTION boolean extra is 579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * set to true. 589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p/> 599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * For a loss of connectivity, if the connectivity manager is attempting 609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * to connect (or has already connected) to another network, the 619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * NetworkInfo for the new network is also passed as an extra. This lets 629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * any receivers of the broadcast know that they should not necessarily 639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * tell the user that no data traffic will be possible. Instead, the 649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * reciever should expect another broadcast soon, indicating either that 659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * the failover attempt succeeded (and so there is still overall data 669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * connectivity), or that the failover attempt failed, meaning that all 679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * connectivity has been lost. 689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p/> 699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * For a disconnect event, the boolean extra EXTRA_NO_CONNECTIVITY 709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * is set to {@code true} if there are no connected networks at all. 719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public static final String CONNECTIVITY_ACTION = "android.net.conn.CONNECTIVITY_CHANGE"; 73f0ceede8fff5df24e5c98701d81c2b71eb138aa9Jeff Sharkey 749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 75961e30458319cfd50e1892ba7dd14a1d0ebe4cc7Jeff Sharkey * Identical to {@link #CONNECTIVITY_ACTION} broadcast, but sent without any 76961e30458319cfd50e1892ba7dd14a1d0ebe4cc7Jeff Sharkey * applicable {@link Settings.Secure#CONNECTIVITY_CHANGE_DELAY}. 77961e30458319cfd50e1892ba7dd14a1d0ebe4cc7Jeff Sharkey * 78961e30458319cfd50e1892ba7dd14a1d0ebe4cc7Jeff Sharkey * @hide 79961e30458319cfd50e1892ba7dd14a1d0ebe4cc7Jeff Sharkey */ 80961e30458319cfd50e1892ba7dd14a1d0ebe4cc7Jeff Sharkey public static final String CONNECTIVITY_ACTION_IMMEDIATE = 81961e30458319cfd50e1892ba7dd14a1d0ebe4cc7Jeff Sharkey "android.net.conn.CONNECTIVITY_CHANGE_IMMEDIATE"; 82961e30458319cfd50e1892ba7dd14a1d0ebe4cc7Jeff Sharkey 83961e30458319cfd50e1892ba7dd14a1d0ebe4cc7Jeff Sharkey /** 849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * The lookup key for a {@link NetworkInfo} object. Retrieve with 859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.content.Intent#getParcelableExtra(String)}. 86f0ceede8fff5df24e5c98701d81c2b71eb138aa9Jeff Sharkey * 87f0ceede8fff5df24e5c98701d81c2b71eb138aa9Jeff Sharkey * @deprecated Since {@link NetworkInfo} can vary based on UID, applications 88f0ceede8fff5df24e5c98701d81c2b71eb138aa9Jeff Sharkey * should always obtain network information through 89f0ceede8fff5df24e5c98701d81c2b71eb138aa9Jeff Sharkey * {@link #getActiveNetworkInfo()} or 90f0ceede8fff5df24e5c98701d81c2b71eb138aa9Jeff Sharkey * {@link #getAllNetworkInfo()}. 919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 92f0ceede8fff5df24e5c98701d81c2b71eb138aa9Jeff Sharkey @Deprecated 939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public static final String EXTRA_NETWORK_INFO = "networkInfo"; 94f0ceede8fff5df24e5c98701d81c2b71eb138aa9Jeff Sharkey 959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * The lookup key for a boolean that indicates whether a connect event 979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * is for a network to which the connectivity manager was failing over 989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * following a disconnect on another network. 999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Retrieve it with {@link android.content.Intent#getBooleanExtra(String,boolean)}. 1009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 1019066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public static final String EXTRA_IS_FAILOVER = "isFailover"; 1029066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 1039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * The lookup key for a {@link NetworkInfo} object. This is supplied when 1049066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * there is another network that it may be possible to connect to. Retrieve with 1059066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@link android.content.Intent#getParcelableExtra(String)}. 1069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 1079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public static final String EXTRA_OTHER_NETWORK_INFO = "otherNetwork"; 1089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 1099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * The lookup key for a boolean that indicates whether there is a 1109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * complete lack of connectivity, i.e., no network is available. 1119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Retrieve it with {@link android.content.Intent#getBooleanExtra(String,boolean)}. 1129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 1139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public static final String EXTRA_NO_CONNECTIVITY = "noConnectivity"; 1149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 1159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * The lookup key for a string that indicates why an attempt to connect 1169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * to a network failed. The string has no particular structure. It is 1179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * intended to be used in notifications presented to users. Retrieve 1189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * it with {@link android.content.Intent#getStringExtra(String)}. 1199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 1209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public static final String EXTRA_REASON = "reason"; 1219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 1229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * The lookup key for a string that provides optionally supplied 1239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * extra information about the network state. The information 1249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * may be passed up from the lower networking layers, and its 1259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * meaning may be specific to a particular network type. Retrieve 1269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * it with {@link android.content.Intent#getStringExtra(String)}. 1279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 1289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public static final String EXTRA_EXTRA_INFO = "extraInfo"; 129d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt /** 130d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt * The lookup key for an int that provides information about 131d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt * our connection to the internet at large. 0 indicates no connection, 132d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt * 100 indicates a great connection. Retrieve it with 133c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey * {@link android.content.Intent#getIntExtra(String, int)}. 134d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt * {@hide} 135d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt */ 136d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt public static final String EXTRA_INET_CONDITION = "inetCondition"; 1379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 1399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Broadcast Action: The setting for background data usage has changed 1409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * values. Use {@link #getBackgroundDataSetting()} to get the current value. 1419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p> 1429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * If an application uses the network in the background, it should listen 1439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * for this broadcast and stop using the background data if the value is 144c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey * {@code false}. 1459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 1469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 1479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public static final String ACTION_BACKGROUND_DATA_SETTING_CHANGED = 1489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project "android.net.conn.BACKGROUND_DATA_SETTING_CHANGED"; 1499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1501e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt /** 1511e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt * Broadcast Action: The network connection may not be good 1521e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt * uses {@code ConnectivityManager.EXTRA_INET_CONDITION} and 1531e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt * {@code ConnectivityManager.EXTRA_NETWORK_INFO} to specify 1541e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt * the network and it's condition. 1551e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt * @hide 1561e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt */ 1571e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt public static final String INET_CONDITION_ACTION = 1581e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt "android.net.conn.INET_CONDITION_ACTION"; 1591e9aac2bd855f12708d3049eff4435fa4a2f4317Robert Greenwalt 16042acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt /** 161d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt * Broadcast Action: A tetherable connection has come or gone 162d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt * TODO - finish the doc 163d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt * @hide 164d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt */ 165d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt public static final String ACTION_TETHER_STATE_CHANGED = 166d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt "android.net.conn.TETHER_STATE_CHANGED"; 167d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt 168d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt /** 169d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt * @hide 1702a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt * gives a String[] 171d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt */ 1722a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt public static final String EXTRA_AVAILABLE_TETHER = "availableArray"; 173d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt 174d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt /** 175d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt * @hide 1762a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt * gives a String[] 177d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt */ 1782a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt public static final String EXTRA_ACTIVE_TETHER = "activeArray"; 1792a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt 1802a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt /** 1812a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt * @hide 1822a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt * gives a String[] 1832a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt */ 1842a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt public static final String EXTRA_ERRORED_TETHER = "erroredArray"; 185d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt 186d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt /** 187ccf83af1017b7b1eaf12f6ec3d2cb2137a7cdda9Robert Greenwalt * The absence of APN.. 188ccf83af1017b7b1eaf12f6ec3d2cb2137a7cdda9Robert Greenwalt * @hide 189ccf83af1017b7b1eaf12f6ec3d2cb2137a7cdda9Robert Greenwalt */ 190ccf83af1017b7b1eaf12f6ec3d2cb2137a7cdda9Robert Greenwalt public static final int TYPE_NONE = -1; 191ccf83af1017b7b1eaf12f6ec3d2cb2137a7cdda9Robert Greenwalt 192ccf83af1017b7b1eaf12f6ec3d2cb2137a7cdda9Robert Greenwalt /** 19342acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * The Default Mobile data connection. When active, all data traffic 19497ab2d4f86ee9c2b661a00688e934fc7030df22eRobert Greenwalt * will use this connection by default. 19542acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt */ 19642acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt public static final int TYPE_MOBILE = 0; 19742acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt /** 19842acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * The Default WIFI data connection. When active, all data traffic 19997ab2d4f86ee9c2b661a00688e934fc7030df22eRobert Greenwalt * will use this connection by default. 20042acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt */ 20142acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt public static final int TYPE_WIFI = 1; 20242acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt /** 20342acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * An MMS-specific Mobile data connection. This connection may be the 2041bc3c3775b7b2cbaec50cd377db437f284478de0Robert Greenwalt * same as {@link #TYPE_MOBILE} but it may be different. This is used 20542acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * by applications needing to talk to the carrier's Multimedia Messaging 20642acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * Service servers. It may coexist with default data connections. 20742acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt */ 20842acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt public static final int TYPE_MOBILE_MMS = 2; 20942acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt /** 21042acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * A SUPL-specific Mobile data connection. This connection may be the 2111bc3c3775b7b2cbaec50cd377db437f284478de0Robert Greenwalt * same as {@link #TYPE_MOBILE} but it may be different. This is used 21242acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * by applications needing to talk to the carrier's Secure User Plane 21342acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * Location servers for help locating the device. It may coexist with 21442acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * default data connections. 21542acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt */ 21642acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt public static final int TYPE_MOBILE_SUPL = 3; 21742acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt /** 21842acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * A DUN-specific Mobile data connection. This connection may be the 2191bc3c3775b7b2cbaec50cd377db437f284478de0Robert Greenwalt * same as {@link #TYPE_MOBILE} but it may be different. This is used 22042acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * by applicaitons performing a Dial Up Networking bridge so that 22142acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * the carrier is aware of DUN traffic. It may coexist with default data 22242acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * connections. 22342acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt */ 22442acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt public static final int TYPE_MOBILE_DUN = 4; 22542acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt /** 22642acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * A High Priority Mobile data connection. This connection is typically 2271bc3c3775b7b2cbaec50cd377db437f284478de0Robert Greenwalt * the same as {@link #TYPE_MOBILE} but the routing setup is different. 22842acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * Only requesting processes will have access to the Mobile DNS servers 22942acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt * and only IP's explicitly requested via {@link #requestRouteToHost} 230c849cdf5cfde007ce591838c4e2b777fb4843c8dRobert Greenwalt * will route over this interface if a default route exists. 23142acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt */ 23242acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt public static final int TYPE_MOBILE_HIPRI = 5; 2338214deb542392f48b6c3fdc377fdf976c0b17a32jsh /** 2348214deb542392f48b6c3fdc377fdf976c0b17a32jsh * The Default WiMAX data connection. When active, all data traffic 23597ab2d4f86ee9c2b661a00688e934fc7030df22eRobert Greenwalt * will use this connection by default. 2368214deb542392f48b6c3fdc377fdf976c0b17a32jsh */ 2378214deb542392f48b6c3fdc377fdf976c0b17a32jsh public static final int TYPE_WIMAX = 6; 238da3d5e6587c1476d489495ac93e84ebf223024c9Robert Greenwalt 23915c7439acb22ab079dd2ebe42bdf0d2ffd525c5dJaikumar Ganesh /** 24097ab2d4f86ee9c2b661a00688e934fc7030df22eRobert Greenwalt * The Default Bluetooth data connection. When active, all data traffic 24197ab2d4f86ee9c2b661a00688e934fc7030df22eRobert Greenwalt * will use this connection by default. 24215c7439acb22ab079dd2ebe42bdf0d2ffd525c5dJaikumar Ganesh */ 24315c7439acb22ab079dd2ebe42bdf0d2ffd525c5dJaikumar Ganesh public static final int TYPE_BLUETOOTH = 7; 24415c7439acb22ab079dd2ebe42bdf0d2ffd525c5dJaikumar Ganesh 2456081084e8831d12d2dd5a9a340ee7d35a54edb8aRobert Greenwalt /** 2466081084e8831d12d2dd5a9a340ee7d35a54edb8aRobert Greenwalt * Dummy data connection. This should not be used on shipping devices. 2476081084e8831d12d2dd5a9a340ee7d35a54edb8aRobert Greenwalt */ 24815c7439acb22ab079dd2ebe42bdf0d2ffd525c5dJaikumar Ganesh public static final int TYPE_DUMMY = 8; 2499d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville 2506081084e8831d12d2dd5a9a340ee7d35a54edb8aRobert Greenwalt /** 25197ab2d4f86ee9c2b661a00688e934fc7030df22eRobert Greenwalt * The Default Ethernet data connection. When active, all data traffic 25297ab2d4f86ee9c2b661a00688e934fc7030df22eRobert Greenwalt * will use this connection by default. 2536081084e8831d12d2dd5a9a340ee7d35a54edb8aRobert Greenwalt */ 254e12aec941dfc93b76b5efb9bc9f30d2ba3469434Robert Greenwalt public static final int TYPE_ETHERNET = 9; 2556081084e8831d12d2dd5a9a340ee7d35a54edb8aRobert Greenwalt 2569d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville /** 2579d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville * Over the air Adminstration. 2589d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville * {@hide} 2599d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville */ 2609d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville public static final int TYPE_MOBILE_FOTA = 10; 2619d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville 2629d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville /** 2639d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville * IP Multimedia Subsystem 2649d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville * {@hide} 2659d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville */ 2669d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville public static final int TYPE_MOBILE_IMS = 11; 2679d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville 2689d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville /** 2699d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville * Carrier Branded Services 2709d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville * {@hide} 2719d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville */ 2729d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville public static final int TYPE_MOBILE_CBS = 12; 2739d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville 274aea743aaa43a833fd8ff3dc56205197583152d5frepo sync /** 275aea743aaa43a833fd8ff3dc56205197583152d5frepo sync * A Wi-Fi p2p connection. Only requesting processes will have access to 276aea743aaa43a833fd8ff3dc56205197583152d5frepo sync * the peers connected. 277aea743aaa43a833fd8ff3dc56205197583152d5frepo sync * {@hide} 278aea743aaa43a833fd8ff3dc56205197583152d5frepo sync */ 279aea743aaa43a833fd8ff3dc56205197583152d5frepo sync public static final int TYPE_WIFI_P2P = 13; 280aea743aaa43a833fd8ff3dc56205197583152d5frepo sync 2819d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville /** {@hide} */ 282aea743aaa43a833fd8ff3dc56205197583152d5frepo sync public static final int MAX_RADIO_TYPE = TYPE_WIFI_P2P; 2839d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville 2849d7d62801ddb206d2ea96d74864a9edfe54d2eeeWink Saville /** {@hide} */ 285aea743aaa43a833fd8ff3dc56205197583152d5frepo sync public static final int MAX_NETWORK_TYPE = TYPE_WIFI_P2P; 2869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 2879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public static final int DEFAULT_NETWORK_PREFERENCE = TYPE_WIFI; 2889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 289c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey private final IConnectivityManager mService; 2909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 291d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey public static boolean isNetworkTypeValid(int networkType) { 29242acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt return networkType >= 0 && networkType <= MAX_NETWORK_TYPE; 2939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 2949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 295d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey /** {@hide} */ 296d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey public static String getNetworkTypeName(int type) { 297d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey switch (type) { 298d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE: 299d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return "MOBILE"; 300d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_WIFI: 301d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return "WIFI"; 302d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_MMS: 303d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return "MOBILE_MMS"; 304d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_SUPL: 305d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return "MOBILE_SUPL"; 306d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_DUN: 307d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return "MOBILE_DUN"; 308d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_HIPRI: 309d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return "MOBILE_HIPRI"; 310d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_WIMAX: 311d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return "WIMAX"; 312d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_BLUETOOTH: 313d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return "BLUETOOTH"; 314d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_DUMMY: 315d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return "DUMMY"; 316d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_ETHERNET: 317d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return "ETHERNET"; 318d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_FOTA: 319d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return "MOBILE_FOTA"; 320d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_IMS: 321d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return "MOBILE_IMS"; 322d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_CBS: 323d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return "MOBILE_CBS"; 324aea743aaa43a833fd8ff3dc56205197583152d5frepo sync case TYPE_WIFI_P2P: 325aea743aaa43a833fd8ff3dc56205197583152d5frepo sync return "WIFI_P2P"; 326d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey default: 327d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return Integer.toString(type); 328d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey } 329d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey } 330d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey 331d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey /** {@hide} */ 332d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey public static boolean isNetworkTypeMobile(int networkType) { 333d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey switch (networkType) { 334d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE: 335d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_MMS: 336d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_SUPL: 337d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_DUN: 338d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_HIPRI: 339d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_FOTA: 340d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_IMS: 341d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey case TYPE_MOBILE_CBS: 342d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return true; 343d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey default: 344d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey return false; 345d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey } 346d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey } 347d2a458750e5a3d490af09cecb5c28370baf0a913Jeff Sharkey 3489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public void setNetworkPreference(int preference) { 3499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project try { 3509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project mService.setNetworkPreference(preference); 3519066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } catch (RemoteException e) { 3529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 3539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 3549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 3559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public int getNetworkPreference() { 3569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project try { 3579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return mService.getNetworkPreference(); 3589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } catch (RemoteException e) { 3599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return -1; 3609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 3619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 3629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 363671644c3ef92a9153ea5bd495e132d5fe6674234Scott Main /** 364671644c3ef92a9153ea5bd495e132d5fe6674234Scott Main * Gets you info about the current data network. 365671644c3ef92a9153ea5bd495e132d5fe6674234Scott Main * Call {@link NetworkInfo#isConnected()} on the returned {@link NetworkInfo} 366671644c3ef92a9153ea5bd495e132d5fe6674234Scott Main * to check if the device has a data connection. 367671644c3ef92a9153ea5bd495e132d5fe6674234Scott Main */ 3689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public NetworkInfo getActiveNetworkInfo() { 3699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project try { 3709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return mService.getActiveNetworkInfo(); 3719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } catch (RemoteException e) { 3729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return null; 3739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 3749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 3759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 376c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey /** {@hide} */ 377c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey public NetworkInfo getActiveNetworkInfoForUid(int uid) { 378c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey try { 379c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey return mService.getActiveNetworkInfoForUid(uid); 380c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey } catch (RemoteException e) { 381c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey return null; 382c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey } 383c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey } 384c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey 3859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public NetworkInfo getNetworkInfo(int networkType) { 3869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project try { 3879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return mService.getNetworkInfo(networkType); 3889066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } catch (RemoteException e) { 3899066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return null; 3909066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 3919066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 3929066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 3939066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public NetworkInfo[] getAllNetworkInfo() { 3949066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project try { 3959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return mService.getAllNetworkInfo(); 3969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } catch (RemoteException e) { 3979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return null; 3989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 3999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 4009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 401c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey /** {@hide} */ 402d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt public LinkProperties getActiveLinkProperties() { 403d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt try { 404d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt return mService.getActiveLinkProperties(); 405d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt } catch (RemoteException e) { 406d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt return null; 407d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt } 408d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt } 409d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt 410c006f1aec15454782c35e028ad64d79a5c161cc1Jeff Sharkey /** {@hide} */ 411d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt public LinkProperties getLinkProperties(int networkType) { 412d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt try { 413d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt return mService.getLinkProperties(networkType); 414d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt } catch (RemoteException e) { 415d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt return null; 416d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt } 417d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt } 418d192dad69e9e5a820c5c11d8cd34460c9cc2ed11Robert Greenwalt 4199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** {@hide} */ 4209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public boolean setRadios(boolean turnOn) { 4219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project try { 4229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return mService.setRadios(turnOn); 4239066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } catch (RemoteException e) { 4249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return false; 4259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 4269066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 4279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 4289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** {@hide} */ 4299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public boolean setRadio(int networkType, boolean turnOn) { 4309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project try { 4319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return mService.setRadio(networkType, turnOn); 4329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } catch (RemoteException e) { 4339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return false; 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 * Tells the underlying networking system that the caller wants to 4399066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * begin using the named feature. The interpretation of {@code feature} 4409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * is completely up to each networking implementation. 4419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param networkType specifies which network the request pertains to 4429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param feature the name of the feature to be used 4439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @return an integer value representing the outcome of the request. 4449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * The interpretation of this value is specific to each networking 4459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * implementation+feature combination, except that the value {@code -1} 4469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * always indicates failure. 4479066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 4489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public int startUsingNetworkFeature(int networkType, String feature) { 4499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project try { 45042acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt return mService.startUsingNetworkFeature(networkType, feature, 45142acef37339afe6ac608c842f1637870ee9c4f6cRobert Greenwalt new Binder()); 4529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } catch (RemoteException e) { 4539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return -1; 4549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 4559066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 4569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 4579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 4589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Tells the underlying networking system that the caller is finished 4599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * using the named feature. The interpretation of {@code feature} 4609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * is completely up to each networking implementation. 4619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param networkType specifies which network the request pertains to 4629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param feature the name of the feature that is no longer needed 4639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @return an integer value representing the outcome of the request. 4649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * The interpretation of this value is specific to each networking 4659066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * implementation+feature combination, except that the value {@code -1} 4669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * always indicates failure. 4679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 4689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public int stopUsingNetworkFeature(int networkType, String feature) { 4699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project try { 4709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return mService.stopUsingNetworkFeature(networkType, feature); 4719066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } catch (RemoteException e) { 4729066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return -1; 4739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 4749066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 4759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 4769066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 4779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Ensure that a network route exists to deliver traffic to the specified 4789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * host via the specified network interface. An attempt to add a route that 4799066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * already exists is ignored, but treated as successful. 4809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param networkType the type of the network over which traffic to the specified 4819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * host is to be routed 4829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param hostAddress the IP address of the host to which the route is desired 4839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @return {@code true} on success, {@code false} on failure 4849066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 4859066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public boolean requestRouteToHost(int networkType, int hostAddress) { 486585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt InetAddress inetAddress = NetworkUtils.intToInetAddress(hostAddress); 487585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt 488585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt if (inetAddress == null) { 489585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt return false; 490585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt } 491585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt 492585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt return requestRouteToHostAddress(networkType, inetAddress); 493585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt } 494585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt 495585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt /** 496585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt * Ensure that a network route exists to deliver traffic to the specified 497585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt * host via the specified network interface. An attempt to add a route that 498585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt * already exists is ignored, but treated as successful. 499585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt * @param networkType the type of the network over which traffic to the specified 500585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt * host is to be routed 501585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt * @param hostAddress the IP address of the host to which the route is desired 502585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt * @return {@code true} on success, {@code false} on failure 503585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt * @hide 504585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt */ 505585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt public boolean requestRouteToHostAddress(int networkType, InetAddress hostAddress) { 506585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt byte[] address = hostAddress.getAddress(); 5079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project try { 508585ac0fc8dde3fe35ec4c71c8f215f2c84139b8bRobert Greenwalt return mService.requestRouteToHostAddress(networkType, address); 5099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } catch (RemoteException e) { 5109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project return false; 5119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 5129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 5139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 5149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 5159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Returns the value of the setting for background data usage. If false, 5169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * applications should not use the network if the application is not in the 5179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * foreground. Developers should respect this setting, and check the value 5189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * of this before performing any background data operations. 5199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * <p> 5209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * All applications that have background services that use the network 5219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * should listen to {@link #ACTION_BACKGROUND_DATA_SETTING_CHANGED}. 5223a844fcf5a0e70a19c38dc500306b9ebe4e1413bJeff Sharkey * <p> 5234cc5333539f57b54663b0a6e398a11a0aaefc8bbScott Main * @deprecated As of {@link VERSION_CODES#ICE_CREAM_SANDWICH}, availability of 5243a844fcf5a0e70a19c38dc500306b9ebe4e1413bJeff Sharkey * background data depends on several combined factors, and this method will 5253a844fcf5a0e70a19c38dc500306b9ebe4e1413bJeff Sharkey * always return {@code true}. Instead, when background data is unavailable, 5263a844fcf5a0e70a19c38dc500306b9ebe4e1413bJeff Sharkey * {@link #getActiveNetworkInfo()} will now appear disconnected. 5276fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang * 5289066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @return Whether background data usage is allowed. 5299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 5303a844fcf5a0e70a19c38dc500306b9ebe4e1413bJeff Sharkey @Deprecated 5319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public boolean getBackgroundDataSetting() { 5323a844fcf5a0e70a19c38dc500306b9ebe4e1413bJeff Sharkey // assume that background data is allowed; final authority is 5333a844fcf5a0e70a19c38dc500306b9ebe4e1413bJeff Sharkey // NetworkInfo which may be blocked. 5343a844fcf5a0e70a19c38dc500306b9ebe4e1413bJeff Sharkey return true; 5359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 5369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 5379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 5389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Sets the value of the setting for background data usage. 539c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt * 5409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @param allowBackgroundData Whether an application should use data while 5419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * it is in the background. 542c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt * 5439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @attr ref android.Manifest.permission#CHANGE_BACKGROUND_DATA_SETTING 5449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @see #getBackgroundDataSetting() 5459066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * @hide 5469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 5473a844fcf5a0e70a19c38dc500306b9ebe4e1413bJeff Sharkey @Deprecated 5489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public void setBackgroundDataSetting(boolean allowBackgroundData) { 5493a844fcf5a0e70a19c38dc500306b9ebe4e1413bJeff Sharkey // ignored 5509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 551c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt 552c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt /** 553f0ceede8fff5df24e5c98701d81c2b71eb138aa9Jeff Sharkey * Return quota status for the current active network, or {@code null} if no 554f0ceede8fff5df24e5c98701d81c2b71eb138aa9Jeff Sharkey * network is active. Quota status can change rapidly, so these values 555f0ceede8fff5df24e5c98701d81c2b71eb138aa9Jeff Sharkey * shouldn't be cached. 55644a3e0d497f19fad1de4b73eb0eb6d3b6132c405Jeff Sharkey * 55744a3e0d497f19fad1de4b73eb0eb6d3b6132c405Jeff Sharkey * @hide 558f0ceede8fff5df24e5c98701d81c2b71eb138aa9Jeff Sharkey */ 559f0ceede8fff5df24e5c98701d81c2b71eb138aa9Jeff Sharkey public NetworkQuotaInfo getActiveNetworkQuotaInfo() { 560f0ceede8fff5df24e5c98701d81c2b71eb138aa9Jeff Sharkey try { 561f0ceede8fff5df24e5c98701d81c2b71eb138aa9Jeff Sharkey return mService.getActiveNetworkQuotaInfo(); 562f0ceede8fff5df24e5c98701d81c2b71eb138aa9Jeff Sharkey } catch (RemoteException e) { 563f0ceede8fff5df24e5c98701d81c2b71eb138aa9Jeff Sharkey return null; 564f0ceede8fff5df24e5c98701d81c2b71eb138aa9Jeff Sharkey } 565f0ceede8fff5df24e5c98701d81c2b71eb138aa9Jeff Sharkey } 566f0ceede8fff5df24e5c98701d81c2b71eb138aa9Jeff Sharkey 567f0ceede8fff5df24e5c98701d81c2b71eb138aa9Jeff Sharkey /** 568c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt * Gets the value of the setting for enabling Mobile data. 569c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt * 570c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt * @return Whether mobile data is enabled. 571c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt * @hide 572c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt */ 573c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt public boolean getMobileDataEnabled() { 574c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt try { 575c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt return mService.getMobileDataEnabled(); 576c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt } catch (RemoteException e) { 577c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt return true; 578c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt } 579c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt } 580c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt 581c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt /** 582c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt * Sets the persisted value for enabling/disabling Mobile data. 583c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt * 5845a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt * @param enabled Whether the mobile data connection should be 585c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt * used or not. 586c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt * @hide 587c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt */ 588c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt public void setMobileDataEnabled(boolean enabled) { 589c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt try { 590c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt mService.setMobileDataEnabled(enabled); 591c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt } catch (RemoteException e) { 592c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt } 593c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt } 594c03fa5014912684367174ff3cce664deb29f5e0eRobert Greenwalt 5959066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 5969066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * {@hide} 5979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 5989066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public ConnectivityManager(IConnectivityManager service) { 599f0ceede8fff5df24e5c98701d81c2b71eb138aa9Jeff Sharkey mService = checkNotNull(service, "missing IConnectivityManager"); 6009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 601d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt 602d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt /** 603d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt * {@hide} 604d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt */ 605d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt public String[] getTetherableIfaces() { 606d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt try { 607d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt return mService.getTetherableIfaces(); 608d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt } catch (RemoteException e) { 609d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt return new String[0]; 610d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt } 611d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt } 612d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt 613d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt /** 614d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt * {@hide} 615d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt */ 616d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt public String[] getTetheredIfaces() { 617d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt try { 618d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt return mService.getTetheredIfaces(); 619d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt } catch (RemoteException e) { 620d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt return new String[0]; 621d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt } 622d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt } 623d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt 624d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt /** 625d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt * {@hide} 626d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt */ 6275a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public String[] getTetheringErroredIfaces() { 6285a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt try { 6295a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt return mService.getTetheringErroredIfaces(); 6305a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt } catch (RemoteException e) { 6315a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt return new String[0]; 6325a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt } 6335a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt } 6345a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt 6355a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt /** 6365a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt * @return error A TETHER_ERROR value indicating success or failure type 6375a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt * {@hide} 6385a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt */ 6395a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public int tether(String iface) { 640d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt try { 641d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt return mService.tether(iface); 642d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt } catch (RemoteException e) { 6435a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt return TETHER_ERROR_SERVICE_UNAVAIL; 644d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt } 645d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt } 646d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt 647d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt /** 6485a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt * @return error A TETHER_ERROR value indicating success or failure type 649d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt * {@hide} 650d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt */ 6515a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public int untether(String iface) { 652d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt try { 653d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt return mService.untether(iface); 654d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt } catch (RemoteException e) { 6555a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt return TETHER_ERROR_SERVICE_UNAVAIL; 656d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt } 657d0e18ffb82b59d38aeaf0e552f48e734202719abRobert Greenwalt } 6582a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt 6592a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt /** 6602a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt * {@hide} 6612a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt */ 6622a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt public boolean isTetheringSupported() { 6632a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt try { 6642a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt return mService.isTetheringSupported(); 6652a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt } catch (RemoteException e) { 6662a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt return false; 6672a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt } 6682a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt } 6692a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt 6702a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt /** 6712a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt * {@hide} 6722a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt */ 6732a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt public String[] getTetherableUsbRegexs() { 6742a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt try { 6752a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt return mService.getTetherableUsbRegexs(); 6762a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt } catch (RemoteException e) { 6772a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt return new String[0]; 6782a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt } 6792a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt } 6802a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt 6812a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt /** 6822a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt * {@hide} 6832a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt */ 6842a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt public String[] getTetherableWifiRegexs() { 6852a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt try { 6862a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt return mService.getTetherableWifiRegexs(); 6872a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt } catch (RemoteException e) { 6882a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt return new String[0]; 6892a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt } 6902a091d7aa0c174986387e5d56bf97a87fe075bdbRobert Greenwalt } 6915a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt 6926fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang /** 6936fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang * {@hide} 6946fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang */ 6956fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang public String[] getTetherableBluetoothRegexs() { 6966fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang try { 6976fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang return mService.getTetherableBluetoothRegexs(); 6986fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang } catch (RemoteException e) { 6996fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang return new String[0]; 7006fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang } 7016fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang } 7026fdd0c6274c81b337ad35b70480f881daf7354c3Danica Chang 7036c2260b3af3a9243aa7f04cf03106f31817cb4c1Mike Lockwood /** 7046c2260b3af3a9243aa7f04cf03106f31817cb4c1Mike Lockwood * {@hide} 7056c2260b3af3a9243aa7f04cf03106f31817cb4c1Mike Lockwood */ 7066c2260b3af3a9243aa7f04cf03106f31817cb4c1Mike Lockwood public int setUsbTethering(boolean enable) { 7076c2260b3af3a9243aa7f04cf03106f31817cb4c1Mike Lockwood try { 7086c2260b3af3a9243aa7f04cf03106f31817cb4c1Mike Lockwood return mService.setUsbTethering(enable); 7096c2260b3af3a9243aa7f04cf03106f31817cb4c1Mike Lockwood } catch (RemoteException e) { 7106c2260b3af3a9243aa7f04cf03106f31817cb4c1Mike Lockwood return TETHER_ERROR_SERVICE_UNAVAIL; 7116c2260b3af3a9243aa7f04cf03106f31817cb4c1Mike Lockwood } 7126c2260b3af3a9243aa7f04cf03106f31817cb4c1Mike Lockwood } 7136c2260b3af3a9243aa7f04cf03106f31817cb4c1Mike Lockwood 7145a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt /** {@hide} */ 7155a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public static final int TETHER_ERROR_NO_ERROR = 0; 7165a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt /** {@hide} */ 7175a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public static final int TETHER_ERROR_UNKNOWN_IFACE = 1; 7185a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt /** {@hide} */ 7195a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public static final int TETHER_ERROR_SERVICE_UNAVAIL = 2; 7205a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt /** {@hide} */ 7215a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public static final int TETHER_ERROR_UNSUPPORTED = 3; 7225a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt /** {@hide} */ 7235a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public static final int TETHER_ERROR_UNAVAIL_IFACE = 4; 7245a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt /** {@hide} */ 7255a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public static final int TETHER_ERROR_MASTER_ERROR = 5; 7265a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt /** {@hide} */ 7275a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public static final int TETHER_ERROR_TETHER_IFACE_ERROR = 6; 7285a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt /** {@hide} */ 7295a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public static final int TETHER_ERROR_UNTETHER_IFACE_ERROR = 7; 7305a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt /** {@hide} */ 7315a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public static final int TETHER_ERROR_ENABLE_NAT_ERROR = 8; 7325a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt /** {@hide} */ 7335a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public static final int TETHER_ERROR_DISABLE_NAT_ERROR = 9; 7345a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt /** {@hide} */ 7355a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public static final int TETHER_ERROR_IFACE_CFG_ERROR = 10; 7365a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt 7375a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt /** 7385a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt * @param iface The name of the interface we're interested in 7395a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt * @return error The error code of the last error tethering or untethering the named 7405a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt * interface 7415a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt * {@hide} 7425a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt */ 7435a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt public int getLastTetherError(String iface) { 7445a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt try { 7455a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt return mService.getLastTetherError(iface); 7465a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt } catch (RemoteException e) { 7475a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt return TETHER_ERROR_SERVICE_UNAVAIL; 7485a73506cdd466f2b96686ced3ff0f7ca224d1143Robert Greenwalt } 74914f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt } 75014f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt 75114f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt /** 75214f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt * Ensure the device stays awake until we connect with the next network 75314f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt * @param forWhome The name of the network going down for logging purposes 75414f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt * @return {@code true} on success, {@code false} on failure 75514f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt * {@hide} 75614f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt */ 75714f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt public boolean requestNetworkTransitionWakelock(String forWhom) { 75814f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt try { 75914f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt mService.requestNetworkTransitionWakelock(forWhom); 76014f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt return true; 76114f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt } catch (RemoteException e) { 76214f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt return false; 76314f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt } 76414f2ef4c9da27a3d58d65dc9f684c5f764ee279aRobert Greenwalt } 765ca4306c976d393c3cd04270bc2de0af2f4f30fa5Robert Greenwalt 76667fd6c92922a94f46c7b6793a808f473a43eddd3Robert Greenwalt /** 767d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt * @param networkType The type of network you want to report on 768d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt * @param percentage The quality of the connection 0 is bad, 100 is good 769d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt * {@hide} 770d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt */ 771d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt public void reportInetCondition(int networkType, int percentage) { 772d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt try { 773d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt mService.reportInetCondition(networkType, percentage); 774d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt } catch (RemoteException e) { 775d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt } 776d7085fcf6567452a9d6fc69b0c6b1bf556f4c1b9Robert Greenwalt } 777434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt 778434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt /** 779434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt * @param proxyProperties The definition for the new global http proxy 780434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt * {@hide} 781434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt */ 782434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt public void setGlobalProxy(ProxyProperties p) { 783434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt try { 784434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt mService.setGlobalProxy(p); 785434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt } catch (RemoteException e) { 786434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt } 787434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt } 788434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt 789434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt /** 790434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt * @return proxyProperties for the current global proxy 791434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt * {@hide} 792434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt */ 793434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt public ProxyProperties getGlobalProxy() { 794434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt try { 795434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt return mService.getGlobalProxy(); 796434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt } catch (RemoteException e) { 797434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt return null; 798434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt } 799434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt } 800434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt 801434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt /** 802434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt * @return proxyProperties for the current proxy (global if set, network specific if not) 803434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt * {@hide} 804434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt */ 805434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt public ProxyProperties getProxy() { 806434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt try { 807434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt return mService.getProxy(); 808434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt } catch (RemoteException e) { 809434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt return null; 810434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt } 811434203a277cd2f237a71508a3d5a7d1602126cd5Robert Greenwalt } 812d55a6b498d66d8fc415908ecf63e50f46cce67e8Robert Greenwalt 813d55a6b498d66d8fc415908ecf63e50f46cce67e8Robert Greenwalt /** 814d55a6b498d66d8fc415908ecf63e50f46cce67e8Robert Greenwalt * @param networkType The network who's dependence has changed 815d55a6b498d66d8fc415908ecf63e50f46cce67e8Robert Greenwalt * @param met Boolean - true if network use is ok, false if not 816d55a6b498d66d8fc415908ecf63e50f46cce67e8Robert Greenwalt * {@hide} 817d55a6b498d66d8fc415908ecf63e50f46cce67e8Robert Greenwalt */ 818d55a6b498d66d8fc415908ecf63e50f46cce67e8Robert Greenwalt public void setDataDependency(int networkType, boolean met) { 819d55a6b498d66d8fc415908ecf63e50f46cce67e8Robert Greenwalt try { 820d55a6b498d66d8fc415908ecf63e50f46cce67e8Robert Greenwalt mService.setDataDependency(networkType, met); 821d55a6b498d66d8fc415908ecf63e50f46cce67e8Robert Greenwalt } catch (RemoteException e) { 822d55a6b498d66d8fc415908ecf63e50f46cce67e8Robert Greenwalt } 823d55a6b498d66d8fc415908ecf63e50f46cce67e8Robert Greenwalt } 8249b2886e24301e5d4e7052ec4a6eaff273d3f516cRobert Greenwalt 8259b2886e24301e5d4e7052ec4a6eaff273d3f516cRobert Greenwalt /** 8269b2886e24301e5d4e7052ec4a6eaff273d3f516cRobert Greenwalt * Returns true if the hardware supports the given network type 8279b2886e24301e5d4e7052ec4a6eaff273d3f516cRobert Greenwalt * else it returns false. This doesn't indicate we have coverage 8289b2886e24301e5d4e7052ec4a6eaff273d3f516cRobert Greenwalt * or are authorized onto a network, just whether or not the 8299b2886e24301e5d4e7052ec4a6eaff273d3f516cRobert Greenwalt * hardware supports it. For example a gsm phone without a sim 8309b2886e24301e5d4e7052ec4a6eaff273d3f516cRobert Greenwalt * should still return true for mobile data, but a wifi only tablet 8319b2886e24301e5d4e7052ec4a6eaff273d3f516cRobert Greenwalt * would return false. 8329b2886e24301e5d4e7052ec4a6eaff273d3f516cRobert Greenwalt * @param networkType The nework type we'd like to check 8339b2886e24301e5d4e7052ec4a6eaff273d3f516cRobert Greenwalt * @return true if supported, else false 8349b2886e24301e5d4e7052ec4a6eaff273d3f516cRobert Greenwalt * @hide 8359b2886e24301e5d4e7052ec4a6eaff273d3f516cRobert Greenwalt */ 8369b2886e24301e5d4e7052ec4a6eaff273d3f516cRobert Greenwalt public boolean isNetworkSupported(int networkType) { 8379b2886e24301e5d4e7052ec4a6eaff273d3f516cRobert Greenwalt try { 8389b2886e24301e5d4e7052ec4a6eaff273d3f516cRobert Greenwalt return mService.isNetworkSupported(networkType); 8399b2886e24301e5d4e7052ec4a6eaff273d3f516cRobert Greenwalt } catch (RemoteException e) {} 8409b2886e24301e5d4e7052ec4a6eaff273d3f516cRobert Greenwalt return false; 8419b2886e24301e5d4e7052ec4a6eaff273d3f516cRobert Greenwalt } 8429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project} 843