Fix null handling in proxies.

ProxyInfo.getPacFileUrl() can not be null.  It will be equal to
Uri.EMPTY.  Checking for null was causing global proxies to never be
disabled.  Or more accurately, global proxies would be disabled, but
would reappear after a reboot.

ProxyInfo.getExclusionListByString() can be null.  If no
exclusion list was specified, the proxy settings would not be
successfully saved, they would disappear after reboot.

Bug: 18453223
Change-Id: I1c27e5dca5b9664bb7468ea909bff489fa110a07
This commit is contained in:
Geoffrey Borggaard
2014-11-20 14:35:32 -05:00
parent 35495fadb1
commit 6ff743e424

View File

@@ -2532,7 +2532,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
String exclList = ""; String exclList = "";
String pacFileUrl = ""; String pacFileUrl = "";
if (proxyProperties != null && (!TextUtils.isEmpty(proxyProperties.getHost()) || if (proxyProperties != null && (!TextUtils.isEmpty(proxyProperties.getHost()) ||
(proxyProperties.getPacFileUrl() != null))) { !Uri.EMPTY.equals(proxyProperties.getPacFileUrl()))) {
if (!proxyProperties.isValid()) { if (!proxyProperties.isValid()) {
if (DBG) if (DBG)
log("Invalid proxy properties, ignoring: " + proxyProperties.toString()); log("Invalid proxy properties, ignoring: " + proxyProperties.toString());
@@ -2542,7 +2542,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
host = mGlobalProxy.getHost(); host = mGlobalProxy.getHost();
port = mGlobalProxy.getPort(); port = mGlobalProxy.getPort();
exclList = mGlobalProxy.getExclusionListAsString(); exclList = mGlobalProxy.getExclusionListAsString();
if (proxyProperties.getPacFileUrl() != null) { if (!Uri.EMPTY.equals(proxyProperties.getPacFileUrl())) {
pacFileUrl = proxyProperties.getPacFileUrl().toString(); pacFileUrl = proxyProperties.getPacFileUrl().toString();
} }
} else { } else {
@@ -2604,7 +2604,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
private void handleApplyDefaultProxy(ProxyInfo proxy) { private void handleApplyDefaultProxy(ProxyInfo proxy) {
if (proxy != null && TextUtils.isEmpty(proxy.getHost()) if (proxy != null && TextUtils.isEmpty(proxy.getHost())
&& (proxy.getPacFileUrl() == null)) { && Uri.EMPTY.equals(proxy.getPacFileUrl())) {
proxy = null; proxy = null;
} }
synchronized (mProxyLock) { synchronized (mProxyLock) {
@@ -2620,7 +2620,8 @@ public class ConnectivityService extends IConnectivityManager.Stub {
// global (to get the correct local port), and send a broadcast. // global (to get the correct local port), and send a broadcast.
// TODO: Switch PacManager to have its own message to send back rather than // TODO: Switch PacManager to have its own message to send back rather than
// reusing EVENT_HAS_CHANGED_PROXY and this call to handleApplyDefaultProxy. // reusing EVENT_HAS_CHANGED_PROXY and this call to handleApplyDefaultProxy.
if ((mGlobalProxy != null) && (proxy != null) && (proxy.getPacFileUrl() != null) if ((mGlobalProxy != null) && (proxy != null)
&& (!Uri.EMPTY.equals(proxy.getPacFileUrl()))
&& proxy.getPacFileUrl().equals(mGlobalProxy.getPacFileUrl())) { && proxy.getPacFileUrl().equals(mGlobalProxy.getPacFileUrl())) {
mGlobalProxy = proxy; mGlobalProxy = proxy;
sendProxyBroadcast(mGlobalProxy); sendProxyBroadcast(mGlobalProxy);