summaryrefslogtreecommitdiffstats
path: root/services/java
diff options
context:
space:
mode:
authorChia-chi Yeh <chiachi@android.com>2011-10-06 15:29:50 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-10-06 15:29:50 -0700
commitb74931559b9e95b22ea632c243acda19fe8ea82c (patch)
tree6eba00f976e2f803b871a5dd1f6d67b3b732bd8e /services/java
parent893783ed8768a98cbfea09c4e60093e2580dd22b (diff)
parent4c12a47bffc51868285b17db9f00d40affc7c9e3 (diff)
downloadframeworks_base-b74931559b9e95b22ea632c243acda19fe8ea82c.zip
frameworks_base-b74931559b9e95b22ea632c243acda19fe8ea82c.tar.gz
frameworks_base-b74931559b9e95b22ea632c243acda19fe8ea82c.tar.bz2
Merge "VPN: temporarily disable the default proxy when VPN is active."
Diffstat (limited to 'services/java')
-rw-r--r--services/java/com/android/server/ConnectivityService.java53
1 files changed, 35 insertions, 18 deletions
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java
index ca807ab..ce31474 100644
--- a/services/java/com/android/server/ConnectivityService.java
+++ b/services/java/com/android/server/ConnectivityService.java
@@ -284,6 +284,9 @@ public class ConnectivityService extends IConnectivityManager.Stub {
// track the current default http proxy - tell the world if we get a new one (real change)
private ProxyProperties mDefaultProxy = null;
+ private Object mDefaultProxyLock = new Object();
+ private boolean mDefaultProxyDisabled = false;
+
// track the global proxy.
private ProxyProperties mGlobalProxy = null;
private final Object mGlobalProxyLock = new Object();
@@ -1770,7 +1773,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
}
}
if (mNetConfigs[netType].isDefault()) {
- handleApplyDefaultProxy(netType);
+ handleApplyDefaultProxy(newLp.getHttpProxy());
}
} else {
if (VDBG) {
@@ -2549,8 +2552,10 @@ public class ConnectivityService extends IConnectivityManager.Stub {
return;
}
- public synchronized ProxyProperties getProxy() {
- return mDefaultProxy;
+ public ProxyProperties getProxy() {
+ synchronized (mDefaultProxyLock) {
+ return mDefaultProxyDisabled ? null : mDefaultProxy;
+ }
}
public void setGlobalProxy(ProxyProperties proxyProperties) {
@@ -2604,20 +2609,19 @@ public class ConnectivityService extends IConnectivityManager.Stub {
}
}
- private void handleApplyDefaultProxy(int type) {
- // check if new default - push it out to all VM if so
- ProxyProperties proxy = mNetTrackers[type].getLinkProperties().getHttpProxy();
- synchronized (this) {
+ private void handleApplyDefaultProxy(ProxyProperties proxy) {
+ if (proxy != null && TextUtils.isEmpty(proxy.getHost())) {
+ proxy = null;
+ }
+ synchronized (mDefaultProxyLock) {
if (mDefaultProxy != null && mDefaultProxy.equals(proxy)) return;
if (mDefaultProxy == proxy) return;
- if (proxy != null && !TextUtils.isEmpty(proxy.getHost())) {
- mDefaultProxy = proxy;
- } else {
- mDefaultProxy = null;
+ mDefaultProxy = proxy;
+
+ if (!mDefaultProxyDisabled) {
+ sendProxyBroadcast(proxy);
}
}
- if (VDBG) log("changing default proxy to " + proxy);
- sendProxyBroadcast(proxy);
}
private void handleDeprecatedGlobalHttpProxy() {
@@ -2845,17 +2849,30 @@ public class ConnectivityService extends IConnectivityManager.Stub {
bumpDns();
}
- // TODO: temporarily remove http proxy?
+ // Temporarily disable the default proxy.
+ synchronized (mDefaultProxyLock) {
+ mDefaultProxyDisabled = true;
+ if (mDefaultProxy != null) {
+ sendProxyBroadcast(null);
+ }
+ }
+
+ // TODO: support proxy per network.
}
public void restore() {
synchronized (mDnsLock) {
- if (!mDnsOverridden) {
- return;
+ if (mDnsOverridden) {
+ mDnsOverridden = false;
+ mHandler.sendEmptyMessage(EVENT_RESTORE_DNS);
+ }
+ }
+ synchronized (mDefaultProxyLock) {
+ mDefaultProxyDisabled = false;
+ if (mDefaultProxy != null) {
+ sendProxyBroadcast(mDefaultProxy);
}
- mDnsOverridden = false;
}
- mHandler.sendEmptyMessage(EVENT_RESTORE_DNS);
}
}
}