summaryrefslogtreecommitdiffstats
path: root/core/java/android/net/ConnectivityManager.java
diff options
context:
space:
mode:
authorPaul Jensen <pauljensen@google.com>2014-12-11 05:49:18 +0000
committerandroid-build-merger <android-build-merger@google.com>2014-12-11 05:49:18 +0000
commit8f58207319fc2b73f83874892a544f8cf59cf7e9 (patch)
treeec8ea23fd881387d7ff50bf5fc3ff999b35f08a1 /core/java/android/net/ConnectivityManager.java
parentde6714474d9d54c5ba0d6a83eafe5ecb96bf337e (diff)
parentd9d48cc9c7ab0d1590918e199917968eafc48288 (diff)
downloadframeworks_base-8f58207319fc2b73f83874892a544f8cf59cf7e9.zip
frameworks_base-8f58207319fc2b73f83874892a544f8cf59cf7e9.tar.gz
frameworks_base-8f58207319fc2b73f83874892a544f8cf59cf7e9.tar.bz2
am 2122e14c: Merge "Fix several HTTP proxy issues with multinetworking." into lmp-mr1-dev
automerge: d9d48cc * commit 'd9d48cc9c7ab0d1590918e199917968eafc48288': Fix several HTTP proxy issues with multinetworking.
Diffstat (limited to 'core/java/android/net/ConnectivityManager.java')
-rw-r--r--core/java/android/net/ConnectivityManager.java47
1 files changed, 38 insertions, 9 deletions
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index 7d5db85..17ee494 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -441,6 +441,13 @@ public class ConnectivityManager {
public static final int NETID_UNSET = 0;
private final IConnectivityManager mService;
+ /**
+ * A kludge to facilitate static access where a Context pointer isn't available, like in the
+ * case of the static set/getProcessDefaultNetwork methods and from the Network class.
+ * TODO: Remove this after deprecating the static methods in favor of non-static methods or
+ * methods that take a Context argument.
+ */
+ private static ConnectivityManager sInstance;
private INetworkManagementService mNMService;
@@ -1392,6 +1399,7 @@ public class ConnectivityManager {
*/
public ConnectivityManager(IConnectivityManager service) {
mService = checkNotNull(service, "missing IConnectivityManager");
+ sInstance = this;
}
/** {@hide} */
@@ -1414,6 +1422,18 @@ public class ConnectivityManager {
}
/**
+ * @deprecated - use getSystemService. This is a kludge to support static access in certain
+ * situations where a Context pointer is unavailable.
+ * @hide
+ */
+ public static ConnectivityManager getInstance() {
+ if (sInstance == null) {
+ throw new IllegalStateException("No ConnectivityManager yet constructed");
+ }
+ return sInstance;
+ }
+
+ /**
* Get the set of tetherable, available interfaces. This list is limited by
* device configuration and current interface existence.
*
@@ -1744,20 +1764,26 @@ public class ConnectivityManager {
}
/**
- * Get the HTTP proxy settings for the current default network. Note that
- * if a global proxy is set, it will override any per-network setting.
+ * Get the current default HTTP proxy settings. If a global proxy is set it will be returned,
+ * otherwise if this process is bound to a {@link Network} using
+ * {@link #setProcessDefaultNetwork} then that {@code Network}'s proxy is returned, otherwise
+ * the default network's proxy is returned.
*
* @return the {@link ProxyInfo} for the current HTTP proxy, or {@code null} if no
* HTTP proxy is active.
- *
- * <p>This method requires the call to hold the permission
- * {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
- * {@hide}
- * @deprecated Deprecated in favor of {@link #getLinkProperties}
+ * @hide
*/
- public ProxyInfo getProxy() {
+ public ProxyInfo getDefaultProxy() {
+ final Network network = getProcessDefaultNetwork();
+ if (network != null) {
+ final ProxyInfo globalProxy = getGlobalProxy();
+ if (globalProxy != null) return globalProxy;
+ final LinkProperties lp = getLinkProperties(network);
+ if (lp != null) return lp.getHttpProxy();
+ return null;
+ }
try {
- return mService.getProxy();
+ return mService.getDefaultProxy();
} catch (RemoteException e) {
return null;
}
@@ -2470,6 +2496,9 @@ public class ConnectivityManager {
return true;
}
if (NetworkUtils.bindProcessToNetwork(netId)) {
+ // Set HTTP proxy system properties to match network.
+ // TODO: Deprecate this static method and replace it with a non-static version.
+ Proxy.setHttpProxySystemProperty(getInstance().getDefaultProxy());
// Must flush DNS cache as new network may have different DNS resolutions.
InetAddress.clearDnsCache();
// Must flush socket pool as idle sockets will be bound to previous network and may