Merge "Rename PacManager to PacProxyInstaller"

This commit is contained in:
Aaron Huang
2021-01-14 01:52:24 +00:00
committed by Gerrit Code Review
2 changed files with 13 additions and 10 deletions

View File

@@ -127,7 +127,7 @@ public class ProxyInfo implements Parcelable {
}
/**
* Only used in PacManager after Local Proxy is bound.
* Only used in PacProxyInstaller after Local Proxy is bound.
* @hide
*/
public ProxyInfo(@NonNull Uri pacFileUrl, int localProxyPort) {

View File

@@ -1,5 +1,5 @@
/**
* Copyright (c) 2018, The Android Open Source Project
* Copyright (c) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -67,7 +67,7 @@ public class ProxyTracker {
// is not set. Individual networks have their own settings that override this. This member
// is set through setDefaultProxy, which is called when the default network changes proxies
// in its LinkProperties, or when ConnectivityService switches to a new default network, or
// when PacManager resolves the proxy.
// when PacProxyInstaller resolves the proxy.
@Nullable
@GuardedBy("mProxyLock")
private volatile ProxyInfo mDefaultProxy = null;
@@ -79,13 +79,14 @@ public class ProxyTracker {
// The object responsible for Proxy Auto Configuration (PAC).
@NonNull
private final PacManager mPacManager;
private final PacProxyInstaller mPacProxyInstaller;
public ProxyTracker(@NonNull final Context context,
@NonNull final Handler connectivityServiceInternalHandler, final int pacChangedEvent) {
mContext = context;
mConnectivityServiceHandler = connectivityServiceInternalHandler;
mPacManager = new PacManager(context, connectivityServiceInternalHandler, pacChangedEvent);
mPacProxyInstaller = new PacProxyInstaller(
context, connectivityServiceInternalHandler, pacChangedEvent);
}
// Convert empty ProxyInfo's to null as null-checks are used to determine if proxies are present
@@ -181,7 +182,7 @@ public class ProxyTracker {
if (!TextUtils.isEmpty(pacFileUrl)) {
mConnectivityServiceHandler.post(
() -> mPacManager.setCurrentProxyScriptUrl(proxyProperties));
() -> mPacProxyInstaller.setCurrentProxyScriptUrl(proxyProperties));
}
}
}
@@ -225,7 +226,9 @@ public class ProxyTracker {
final ProxyInfo defaultProxy = getDefaultProxy();
final ProxyInfo proxyInfo = null != defaultProxy ?
defaultProxy : ProxyInfo.buildDirectProxy("", 0, Collections.emptyList());
if (mPacManager.setCurrentProxyScriptUrl(proxyInfo) == PacManager.DONT_SEND_BROADCAST) {
if (mPacProxyInstaller.setCurrentProxyScriptUrl(proxyInfo)
== PacProxyInstaller.DONT_SEND_BROADCAST) {
return;
}
if (DBG) Log.d(TAG, "sending Proxy Broadcast for " + proxyInfo);
@@ -305,10 +308,10 @@ public class ProxyTracker {
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
// This call could be coming from the PacProxyInstaller, 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
// TODO: Switch PacProxyInstaller to have its own message to send back rather than
// reusing EVENT_HAS_CHANGED_PROXY and this call to handleApplyDefaultProxy.
if ((mGlobalProxy != null) && (proxyInfo != null)
&& (!Uri.EMPTY.equals(proxyInfo.getPacFileUrl()))