From c8b9171607e02d28c6ff10061306f2fa4a0fdfd9 Mon Sep 17 00:00:00 2001 From: Jason Monk Date: Mon, 28 Apr 2014 14:57:27 -0400 Subject: [PATCH] Fix Global Proxy when used with PAC Since PAC needs to relay the local proxy port back to the ConnectivityService it ends up calling handleApplyDefaultProxy... This works fine for PAC on WiFi, but when tested on global proxy (not currently used anywhere), it sets the mDefaultProxy. This mDefaultProxy does not get cleared when the global proxy is cleared and requires a reboot to get things cleared out. This CL adds a check to overwrite mGlobalProxy rather than mDefaultProxy in this use case. Change-Id: I92782d11e213b91f8ddda2faaf996a7252273fc3 --- .../java/com/android/server/ConnectivityService.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java index ea03eb7a33..dfffa8a463 100644 --- a/services/core/java/com/android/server/ConnectivityService.java +++ b/services/core/java/com/android/server/ConnectivityService.java @@ -3517,6 +3517,18 @@ public class ConnectivityService extends IConnectivityManager.Stub { if (DBG) log("Invalid proxy properties, ignoring: " + proxy.toString()); return; } + + // This call could be coming from the PacManager, containing the port of the local + // proxy. If this new proxy matches the global proxy then copy this proxy to the + // global (to get the correct local port), and send a broadcast. + // TODO: Switch PacManager to have its own message to send back rather than + // reusing EVENT_HAS_CHANGED_PROXY and this call to handleApplyDefaultProxy. + if ((mGlobalProxy != null) && (proxy != null) && (proxy.getPacFileUrl() != null) + && proxy.getPacFileUrl().equals(mGlobalProxy.getPacFileUrl())) { + mGlobalProxy = proxy; + sendProxyBroadcast(mGlobalProxy); + return; + } mDefaultProxy = proxy; if (mGlobalProxy != null) return;