Fix for the invalid Global Proxy Setting
Adding validation for Global Proxy setting before it is being set. Proxy is validated at the boot time also to make sure the value set is valid. Signed-off-by: Raj Mamadgi <rmamadgi@sta.samsung.com> bug:11598568 Change-Id: Idff5ae81119d8143da096b5291ecbfbc5875cbd4
This commit is contained in:
parent
8fe05f16a4
commit
08e512b425
2 changed files with 25 additions and 0 deletions
|
|
@ -139,6 +139,17 @@ public class ProxyProperties implements Parcelable {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
if (!TextUtils.isEmpty(mPacFileUrl)) return true;
|
||||
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() {
|
||||
java.net.Proxy proxy = java.net.Proxy.NO_PROXY;
|
||||
if (mHost != null) {
|
||||
|
|
|
|||
|
|
@ -3380,6 +3380,11 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||
String pacFileUrl = "";
|
||||
if (proxyProperties != null && (!TextUtils.isEmpty(proxyProperties.getHost()) ||
|
||||
!TextUtils.isEmpty(proxyProperties.getPacFileUrl()))) {
|
||||
if (!proxyProperties.isValid()) {
|
||||
if (DBG)
|
||||
log("Invalid proxy properties, ignoring: " + proxyProperties.toString());
|
||||
return;
|
||||
}
|
||||
mGlobalProxy = new ProxyProperties(proxyProperties);
|
||||
host = mGlobalProxy.getHost();
|
||||
port = mGlobalProxy.getPort();
|
||||
|
|
@ -3423,6 +3428,11 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||
} else {
|
||||
proxyProperties = new ProxyProperties(host, port, exclList);
|
||||
}
|
||||
if (!proxyProperties.isValid()) {
|
||||
if (DBG) log("Invalid proxy properties, ignoring: " + proxyProperties.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (mProxyLock) {
|
||||
mGlobalProxy = proxyProperties;
|
||||
}
|
||||
|
|
@ -3447,6 +3457,10 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
|||
synchronized (mProxyLock) {
|
||||
if (mDefaultProxy != null && mDefaultProxy.equals(proxy)) return;
|
||||
if (mDefaultProxy == proxy) return; // catches repeated nulls
|
||||
if (!proxy.isValid()) {
|
||||
if (DBG) log("Invalid proxy properties, ignoring: " + proxy.toString());
|
||||
return;
|
||||
}
|
||||
mDefaultProxy = proxy;
|
||||
|
||||
if (mGlobalProxy != null) return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue