am a3c50d75: Merge "Fix for the invalid Global Proxy Setting"

* commit 'a3c50d75ace37eb07c3fe9dc7756a9c56a4922ff':
  Fix for the invalid Global Proxy Setting
This commit is contained in:
Robert Greenwalt
2013-11-13 16:27:56 -08:00
committed by Android Git Automerger
2 changed files with 24 additions and 0 deletions

View File

@@ -115,6 +115,16 @@ public class ProxyProperties implements Parcelable {
return false; return false;
} }
public boolean isValid() {
try {
Proxy.validate(mHost == null ? "" : mHost, mPort == 0 ? "" : Integer.toString(mPort),
mExclusionList == null ? "" : mExclusionList);
} catch (IllegalArgumentException e) {
return false;
}
return true;
}
public java.net.Proxy makeProxy() { public java.net.Proxy makeProxy() {
java.net.Proxy proxy = java.net.Proxy.NO_PROXY; java.net.Proxy proxy = java.net.Proxy.NO_PROXY;
if (mHost != null) { if (mHost != null) {

View File

@@ -3138,6 +3138,11 @@ public class ConnectivityService extends IConnectivityManager.Stub {
int port = 0; int port = 0;
String exclList = ""; String exclList = "";
if (proxyProperties != null && !TextUtils.isEmpty(proxyProperties.getHost())) { if (proxyProperties != null && !TextUtils.isEmpty(proxyProperties.getHost())) {
if (!proxyProperties.isValid()) {
if (DBG)
log("Invalid proxy properties, ignoring: " + proxyProperties.toString());
return;
}
mGlobalProxy = new ProxyProperties(proxyProperties); mGlobalProxy = new ProxyProperties(proxyProperties);
host = mGlobalProxy.getHost(); host = mGlobalProxy.getHost();
port = mGlobalProxy.getPort(); port = mGlobalProxy.getPort();
@@ -3171,6 +3176,11 @@ public class ConnectivityService extends IConnectivityManager.Stub {
Settings.Global.GLOBAL_HTTP_PROXY_EXCLUSION_LIST); Settings.Global.GLOBAL_HTTP_PROXY_EXCLUSION_LIST);
if (!TextUtils.isEmpty(host)) { if (!TextUtils.isEmpty(host)) {
ProxyProperties proxyProperties = new ProxyProperties(host, port, exclList); ProxyProperties proxyProperties = new ProxyProperties(host, port, exclList);
if (!proxyProperties.isValid()) {
if (DBG) log("Invalid proxy properties, ignoring: " + proxyProperties.toString());
return;
}
synchronized (mProxyLock) { synchronized (mProxyLock) {
mGlobalProxy = proxyProperties; mGlobalProxy = proxyProperties;
} }
@@ -3194,6 +3204,10 @@ public class ConnectivityService extends IConnectivityManager.Stub {
synchronized (mProxyLock) { synchronized (mProxyLock) {
if (mDefaultProxy != null && mDefaultProxy.equals(proxy)) return; if (mDefaultProxy != null && mDefaultProxy.equals(proxy)) return;
if (mDefaultProxy == proxy) return; // catches repeated nulls if (mDefaultProxy == proxy) return; // catches repeated nulls
if (!proxy.isValid()) {
if (DBG) log("Invalid proxy properties, ignoring: " + proxy.toString());
return;
}
mDefaultProxy = proxy; mDefaultProxy = proxy;
if (mGlobalProxy != null) return; if (mGlobalProxy != null) return;