am 2a1fb433: am 4c514f2a: am 594eeb08: Merge "Fix for the invalid Global Proxy Setting" into klp-dev am: 8fa42e3cfb

Original change: undetermined

Change-Id: I3c3a1a9975716b59183e9ba5aeea059e4514c3ac
This commit is contained in:
Robert Greenwalt
2021-05-31 06:52:55 +00:00
committed by Automerger Merge Worker
2 changed files with 25 additions and 0 deletions

View File

@@ -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) {

View File

@@ -3351,6 +3351,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();
@@ -3394,6 +3399,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;
}
@@ -3418,6 +3428,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;