Merge changes I66e40b4b,I599a2ff9,I7c210623

* changes:
  [PT16] Simplification of sendProxyBroadcast.
  [PT15] Tiny bugfix in setGlobalProxy
  [PT14] No-op refactoring of sendProxyBroadcast
This commit is contained in:
Treehugger Robot
2018-10-16 14:48:33 +00:00
committed by Gerrit Code Review
2 changed files with 11 additions and 12 deletions

View File

@@ -3495,7 +3495,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
ProxyInfo oldProxyInfo = oldLp == null ? null : oldLp.getHttpProxy(); ProxyInfo oldProxyInfo = oldLp == null ? null : oldLp.getHttpProxy();
if (!ProxyTracker.proxyInfoEqual(newProxyInfo, oldProxyInfo)) { if (!ProxyTracker.proxyInfoEqual(newProxyInfo, oldProxyInfo)) {
mProxyTracker.sendProxyBroadcast(mProxyTracker.getDefaultProxy()); mProxyTracker.sendProxyBroadcast();
} }
} }

View File

@@ -126,9 +126,9 @@ public class ProxyTracker {
public ProxyInfo getDefaultProxy() { public ProxyInfo getDefaultProxy() {
// This information is already available as a world read/writable jvm property. // This information is already available as a world read/writable jvm property.
synchronized (mProxyLock) { synchronized (mProxyLock) {
final ProxyInfo ret = mGlobalProxy; if (mGlobalProxy != null) return mGlobalProxy;
if ((ret == null) && mDefaultProxyEnabled) return mDefaultProxy; if (mDefaultProxyEnabled) return mDefaultProxy;
return ret; return null;
} }
} }
@@ -204,11 +204,10 @@ public class ProxyTracker {
* *
* Confusingly this method also sets the PAC file URL. TODO : separate this, it has nothing * Confusingly this method also sets the PAC file URL. TODO : separate this, it has nothing
* to do in a "sendProxyBroadcast" method. * to do in a "sendProxyBroadcast" method.
* @param proxyInfo the proxy spec, or null for no proxy.
*/ */
// TODO : make the argument NonNull final and the method private public void sendProxyBroadcast() {
public void sendProxyBroadcast(@Nullable ProxyInfo proxyInfo) { final ProxyInfo defaultProxy = getDefaultProxy();
if (proxyInfo == null) proxyInfo = new ProxyInfo("", 0, ""); final ProxyInfo proxyInfo = null != defaultProxy ? defaultProxy : new ProxyInfo("", 0, "");
if (mPacManager.setCurrentProxyScriptUrl(proxyInfo)) return; if (mPacManager.setCurrentProxyScriptUrl(proxyInfo)) return;
if (DBG) Slog.d(TAG, "sending Proxy Broadcast for " + proxyInfo); if (DBG) Slog.d(TAG, "sending Proxy Broadcast for " + proxyInfo);
Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION); Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION);
@@ -269,7 +268,7 @@ public class ProxyTracker {
Binder.restoreCallingIdentity(token); Binder.restoreCallingIdentity(token);
} }
sendProxyBroadcast(mGlobalProxy == null ? mDefaultProxy : proxyInfo); sendProxyBroadcast();
} }
} }
@@ -296,14 +295,14 @@ public class ProxyTracker {
&& (!Uri.EMPTY.equals(proxyInfo.getPacFileUrl())) && (!Uri.EMPTY.equals(proxyInfo.getPacFileUrl()))
&& proxyInfo.getPacFileUrl().equals(mGlobalProxy.getPacFileUrl())) { && proxyInfo.getPacFileUrl().equals(mGlobalProxy.getPacFileUrl())) {
mGlobalProxy = proxyInfo; mGlobalProxy = proxyInfo;
sendProxyBroadcast(mGlobalProxy); sendProxyBroadcast();
return; return;
} }
mDefaultProxy = proxyInfo; mDefaultProxy = proxyInfo;
if (mGlobalProxy != null) return; if (mGlobalProxy != null) return;
if (mDefaultProxyEnabled) { if (mDefaultProxyEnabled) {
sendProxyBroadcast(proxyInfo); sendProxyBroadcast();
} }
} }
} }
@@ -320,7 +319,7 @@ public class ProxyTracker {
if (mDefaultProxyEnabled != enabled) { if (mDefaultProxyEnabled != enabled) {
mDefaultProxyEnabled = enabled; mDefaultProxyEnabled = enabled;
if (mGlobalProxy == null && mDefaultProxy != null) { if (mGlobalProxy == null && mDefaultProxy != null) {
sendProxyBroadcast(enabled ? mDefaultProxy : null); sendProxyBroadcast();
} }
} }
} }