From 1836a63e9286c176b2323b38314f51511a797688 Mon Sep 17 00:00:00 2001 From: Chalard Jean Date: Fri, 8 Jun 2018 19:39:24 +0900 Subject: [PATCH] [PT14] No-op refactoring of sendProxyBroadcast If mGlobalProxy is non-null, then getDefaultProxy returns mGlobalProxy so the first change is a no-op. If mGlobalProxy is null and mDefaultProxyEnabled is true, then getDefaultProxy returns mDefaultProxy, which has just been set to proxyInfo, so the second change is a no-op. If mGlobalProxy is null and mDefaultProxyEnabled is true, then getDefaultProxy returns mDefaultProxy ; if mGlobalProxy is null and mDefaultProxyEnabled is false, then getDefaultProxy returns null, therefore the third change is a no-op. Test: runtest Change-Id: I7c21062302bf54f4fc917c82e0175975051a55ec --- .../android/server/connectivity/ProxyTracker.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/connectivity/ProxyTracker.java b/services/core/java/com/android/server/connectivity/ProxyTracker.java index 47e85b5fd3..a90bba00c0 100644 --- a/services/core/java/com/android/server/connectivity/ProxyTracker.java +++ b/services/core/java/com/android/server/connectivity/ProxyTracker.java @@ -126,9 +126,9 @@ public class ProxyTracker { public ProxyInfo getDefaultProxy() { // This information is already available as a world read/writable jvm property. synchronized (mProxyLock) { - final ProxyInfo ret = mGlobalProxy; - if ((ret == null) && mDefaultProxyEnabled) return mDefaultProxy; - return ret; + if (mGlobalProxy != null) return mGlobalProxy; + if (mDefaultProxyEnabled) return mDefaultProxy; + return null; } } @@ -296,14 +296,14 @@ public class ProxyTracker { && (!Uri.EMPTY.equals(proxyInfo.getPacFileUrl())) && proxyInfo.getPacFileUrl().equals(mGlobalProxy.getPacFileUrl())) { mGlobalProxy = proxyInfo; - sendProxyBroadcast(mGlobalProxy); + sendProxyBroadcast(getDefaultProxy()); return; } mDefaultProxy = proxyInfo; if (mGlobalProxy != null) return; if (mDefaultProxyEnabled) { - sendProxyBroadcast(proxyInfo); + sendProxyBroadcast(getDefaultProxy()); } } } @@ -320,7 +320,7 @@ public class ProxyTracker { if (mDefaultProxyEnabled != enabled) { mDefaultProxyEnabled = enabled; if (mGlobalProxy == null && mDefaultProxy != null) { - sendProxyBroadcast(enabled ? mDefaultProxy : null); + sendProxyBroadcast(getDefaultProxy()); } } }