[PT08] Move setDefaultProxy to ProxyTracker
Test: runtest Change-Id: Idb7d2f2895aac63d54e3a6481379b739a726eff6
This commit is contained in:
@@ -3334,35 +3334,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
&& Uri.EMPTY.equals(proxy.getPacFileUrl())) {
|
||||
proxy = null;
|
||||
}
|
||||
synchronized (mProxyTracker.mProxyLock) {
|
||||
if (mProxyTracker.mDefaultProxy != null && mProxyTracker.mDefaultProxy.equals(proxy)) {
|
||||
return;
|
||||
}
|
||||
if (mProxyTracker.mDefaultProxy == proxy) return; // catches repeated nulls
|
||||
if (proxy != null && !proxy.isValid()) {
|
||||
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 ((mProxyTracker.mGlobalProxy != null) && (proxy != null)
|
||||
&& (!Uri.EMPTY.equals(proxy.getPacFileUrl()))
|
||||
&& proxy.getPacFileUrl().equals(mProxyTracker.mGlobalProxy.getPacFileUrl())) {
|
||||
mProxyTracker.mGlobalProxy = proxy;
|
||||
mProxyTracker.sendProxyBroadcast(mProxyTracker.mGlobalProxy);
|
||||
return;
|
||||
}
|
||||
mProxyTracker.mDefaultProxy = proxy;
|
||||
|
||||
if (mProxyTracker.mGlobalProxy != null) return;
|
||||
if (!mProxyTracker.mDefaultProxyDisabled) {
|
||||
mProxyTracker.sendProxyBroadcast(proxy);
|
||||
}
|
||||
}
|
||||
mProxyTracker.setDefaultProxy(proxy);
|
||||
}
|
||||
|
||||
// If the proxy has changed from oldLp to newLp, resend proxy broadcast with default proxy.
|
||||
|
||||
@@ -120,7 +120,7 @@ public class ProxyTracker {
|
||||
return mPacManager.setCurrentProxyScriptUrl(proxy);
|
||||
}
|
||||
|
||||
// TODO : make the argument NonNull final
|
||||
// TODO : make the argument NonNull final and the method private
|
||||
public void sendProxyBroadcast(@Nullable ProxyInfo proxy) {
|
||||
if (proxy == null) proxy = new ProxyInfo("", 0, "");
|
||||
if (setCurrentProxyScriptUrl(proxy)) return;
|
||||
@@ -182,4 +182,36 @@ public class ProxyTracker {
|
||||
sendProxyBroadcast(mGlobalProxy == null ? mDefaultProxy : proxyProperties);
|
||||
}
|
||||
}
|
||||
|
||||
public void setDefaultProxy(@Nullable ProxyInfo proxy) {
|
||||
synchronized (mProxyLock) {
|
||||
if (mDefaultProxy != null && mDefaultProxy.equals(proxy)) {
|
||||
return;
|
||||
}
|
||||
if (mDefaultProxy == proxy) return; // catches repeated nulls
|
||||
if (proxy != null && !proxy.isValid()) {
|
||||
if (DBG) Slog.d(TAG, "Invalid proxy properties, ignoring: " + proxy);
|
||||
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)
|
||||
&& (!Uri.EMPTY.equals(proxy.getPacFileUrl()))
|
||||
&& proxy.getPacFileUrl().equals(mGlobalProxy.getPacFileUrl())) {
|
||||
mGlobalProxy = proxy;
|
||||
sendProxyBroadcast(mGlobalProxy);
|
||||
return;
|
||||
}
|
||||
mDefaultProxy = proxy;
|
||||
|
||||
if (mGlobalProxy != null) return;
|
||||
if (!mDefaultProxyDisabled) {
|
||||
sendProxyBroadcast(proxy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user