[PT07] Small cleanup of setGlobalProxy
Test: runtest Change-Id: I4825e6326f7ce7bd45d625d57824f8d27c51d6f2
This commit is contained in:
@@ -139,14 +139,15 @@ public class ProxyTracker {
|
|||||||
|
|
||||||
public void setGlobalProxy(@Nullable ProxyInfo proxyProperties) {
|
public void setGlobalProxy(@Nullable ProxyInfo proxyProperties) {
|
||||||
synchronized (mProxyLock) {
|
synchronized (mProxyLock) {
|
||||||
|
// ProxyInfo#equals is not commutative :( and is public API, so it can't be fixed.
|
||||||
if (proxyProperties == mGlobalProxy) return;
|
if (proxyProperties == mGlobalProxy) return;
|
||||||
if (proxyProperties != null && proxyProperties.equals(mGlobalProxy)) return;
|
if (proxyProperties != null && proxyProperties.equals(mGlobalProxy)) return;
|
||||||
if (mGlobalProxy != null && mGlobalProxy.equals(proxyProperties)) return;
|
if (mGlobalProxy != null && mGlobalProxy.equals(proxyProperties)) return;
|
||||||
|
|
||||||
String host = "";
|
final String host;
|
||||||
int port = 0;
|
final int port;
|
||||||
String exclList = "";
|
final String exclList;
|
||||||
String pacFileUrl = "";
|
final String pacFileUrl;
|
||||||
if (proxyProperties != null && (!TextUtils.isEmpty(proxyProperties.getHost()) ||
|
if (proxyProperties != null && (!TextUtils.isEmpty(proxyProperties.getHost()) ||
|
||||||
!Uri.EMPTY.equals(proxyProperties.getPacFileUrl()))) {
|
!Uri.EMPTY.equals(proxyProperties.getPacFileUrl()))) {
|
||||||
if (!proxyProperties.isValid()) {
|
if (!proxyProperties.isValid()) {
|
||||||
@@ -157,10 +158,13 @@ public class ProxyTracker {
|
|||||||
host = mGlobalProxy.getHost();
|
host = mGlobalProxy.getHost();
|
||||||
port = mGlobalProxy.getPort();
|
port = mGlobalProxy.getPort();
|
||||||
exclList = mGlobalProxy.getExclusionListAsString();
|
exclList = mGlobalProxy.getExclusionListAsString();
|
||||||
if (!Uri.EMPTY.equals(proxyProperties.getPacFileUrl())) {
|
pacFileUrl = Uri.EMPTY.equals(proxyProperties.getPacFileUrl())
|
||||||
pacFileUrl = proxyProperties.getPacFileUrl().toString();
|
? "" : proxyProperties.getPacFileUrl().toString();
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
|
host = "";
|
||||||
|
port = 0;
|
||||||
|
exclList = "";
|
||||||
|
pacFileUrl = "";
|
||||||
mGlobalProxy = null;
|
mGlobalProxy = null;
|
||||||
}
|
}
|
||||||
final ContentResolver res = mContext.getContentResolver();
|
final ContentResolver res = mContext.getContentResolver();
|
||||||
@@ -175,10 +179,7 @@ public class ProxyTracker {
|
|||||||
Binder.restoreCallingIdentity(token);
|
Binder.restoreCallingIdentity(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mGlobalProxy == null) {
|
sendProxyBroadcast(mGlobalProxy == null ? mDefaultProxy : proxyProperties);
|
||||||
proxyProperties = mDefaultProxy;
|
|
||||||
}
|
|
||||||
sendProxyBroadcast(proxyProperties);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user