Loading services/java/com/android/server/ConnectivityService.java +35 −18 Original line number Original line Diff line number Diff line Loading @@ -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) // track the current default http proxy - tell the world if we get a new one (real change) private ProxyProperties mDefaultProxy = null; private ProxyProperties mDefaultProxy = null; private Object mDefaultProxyLock = new Object(); private boolean mDefaultProxyDisabled = false; // track the global proxy. // track the global proxy. private ProxyProperties mGlobalProxy = null; private ProxyProperties mGlobalProxy = null; private final Object mGlobalProxyLock = new Object(); private final Object mGlobalProxyLock = new Object(); Loading Loading @@ -1770,7 +1773,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } } } if (mNetConfigs[netType].isDefault()) { if (mNetConfigs[netType].isDefault()) { handleApplyDefaultProxy(netType); handleApplyDefaultProxy(newLp.getHttpProxy()); } } } else { } else { if (VDBG) { if (VDBG) { Loading Loading @@ -2549,8 +2552,10 @@ public class ConnectivityService extends IConnectivityManager.Stub { return; return; } } public synchronized ProxyProperties getProxy() { public ProxyProperties getProxy() { return mDefaultProxy; synchronized (mDefaultProxyLock) { return mDefaultProxyDisabled ? null : mDefaultProxy; } } } public void setGlobalProxy(ProxyProperties proxyProperties) { public void setGlobalProxy(ProxyProperties proxyProperties) { Loading Loading @@ -2604,20 +2609,19 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } } } private void handleApplyDefaultProxy(int type) { private void handleApplyDefaultProxy(ProxyProperties proxy) { // check if new default - push it out to all VM if so if (proxy != null && TextUtils.isEmpty(proxy.getHost())) { ProxyProperties proxy = mNetTrackers[type].getLinkProperties().getHttpProxy(); proxy = null; synchronized (this) { } synchronized (mDefaultProxyLock) { if (mDefaultProxy != null && mDefaultProxy.equals(proxy)) return; if (mDefaultProxy != null && mDefaultProxy.equals(proxy)) return; if (mDefaultProxy == proxy) return; if (mDefaultProxy == proxy) return; if (proxy != null && !TextUtils.isEmpty(proxy.getHost())) { mDefaultProxy = proxy; mDefaultProxy = proxy; } else { mDefaultProxy = null; if (!mDefaultProxyDisabled) { sendProxyBroadcast(proxy); } } } } if (VDBG) log("changing default proxy to " + proxy); sendProxyBroadcast(proxy); } } private void handleDeprecatedGlobalHttpProxy() { private void handleDeprecatedGlobalHttpProxy() { Loading Loading @@ -2845,17 +2849,30 @@ public class ConnectivityService extends IConnectivityManager.Stub { bumpDns(); 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() { public void restore() { synchronized (mDnsLock) { synchronized (mDnsLock) { if (!mDnsOverridden) { if (mDnsOverridden) { return; } mDnsOverridden = false; mDnsOverridden = false; } mHandler.sendEmptyMessage(EVENT_RESTORE_DNS); mHandler.sendEmptyMessage(EVENT_RESTORE_DNS); } } } } synchronized (mDefaultProxyLock) { mDefaultProxyDisabled = false; if (mDefaultProxy != null) { sendProxyBroadcast(mDefaultProxy); } } } } } } Loading
services/java/com/android/server/ConnectivityService.java +35 −18 Original line number Original line Diff line number Diff line Loading @@ -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) // track the current default http proxy - tell the world if we get a new one (real change) private ProxyProperties mDefaultProxy = null; private ProxyProperties mDefaultProxy = null; private Object mDefaultProxyLock = new Object(); private boolean mDefaultProxyDisabled = false; // track the global proxy. // track the global proxy. private ProxyProperties mGlobalProxy = null; private ProxyProperties mGlobalProxy = null; private final Object mGlobalProxyLock = new Object(); private final Object mGlobalProxyLock = new Object(); Loading Loading @@ -1770,7 +1773,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } } } if (mNetConfigs[netType].isDefault()) { if (mNetConfigs[netType].isDefault()) { handleApplyDefaultProxy(netType); handleApplyDefaultProxy(newLp.getHttpProxy()); } } } else { } else { if (VDBG) { if (VDBG) { Loading Loading @@ -2549,8 +2552,10 @@ public class ConnectivityService extends IConnectivityManager.Stub { return; return; } } public synchronized ProxyProperties getProxy() { public ProxyProperties getProxy() { return mDefaultProxy; synchronized (mDefaultProxyLock) { return mDefaultProxyDisabled ? null : mDefaultProxy; } } } public void setGlobalProxy(ProxyProperties proxyProperties) { public void setGlobalProxy(ProxyProperties proxyProperties) { Loading Loading @@ -2604,20 +2609,19 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } } } private void handleApplyDefaultProxy(int type) { private void handleApplyDefaultProxy(ProxyProperties proxy) { // check if new default - push it out to all VM if so if (proxy != null && TextUtils.isEmpty(proxy.getHost())) { ProxyProperties proxy = mNetTrackers[type].getLinkProperties().getHttpProxy(); proxy = null; synchronized (this) { } synchronized (mDefaultProxyLock) { if (mDefaultProxy != null && mDefaultProxy.equals(proxy)) return; if (mDefaultProxy != null && mDefaultProxy.equals(proxy)) return; if (mDefaultProxy == proxy) return; if (mDefaultProxy == proxy) return; if (proxy != null && !TextUtils.isEmpty(proxy.getHost())) { mDefaultProxy = proxy; mDefaultProxy = proxy; } else { mDefaultProxy = null; if (!mDefaultProxyDisabled) { sendProxyBroadcast(proxy); } } } } if (VDBG) log("changing default proxy to " + proxy); sendProxyBroadcast(proxy); } } private void handleDeprecatedGlobalHttpProxy() { private void handleDeprecatedGlobalHttpProxy() { Loading Loading @@ -2845,17 +2849,30 @@ public class ConnectivityService extends IConnectivityManager.Stub { bumpDns(); 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() { public void restore() { synchronized (mDnsLock) { synchronized (mDnsLock) { if (!mDnsOverridden) { if (mDnsOverridden) { return; } mDnsOverridden = false; mDnsOverridden = false; } mHandler.sendEmptyMessage(EVENT_RESTORE_DNS); mHandler.sendEmptyMessage(EVENT_RESTORE_DNS); } } } } synchronized (mDefaultProxyLock) { mDefaultProxyDisabled = false; if (mDefaultProxy != null) { sendProxyBroadcast(mDefaultProxy); } } } } } }