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 * @hide
*/ */
public ProxyInfo(@NonNull Uri pacFileUrl, int localProxyPort) { 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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 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 // 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 // in its LinkProperties, or when ConnectivityService switches to a new default network, or
// when PacManager resolves the proxy. // when PacProxyInstaller resolves the proxy.
@Nullable @Nullable
@GuardedBy("mProxyLock") @GuardedBy("mProxyLock")
private volatile ProxyInfo mDefaultProxy = null; private volatile ProxyInfo mDefaultProxy = null;
@@ -79,13 +79,14 @@ public class ProxyTracker {
// The object responsible for Proxy Auto Configuration (PAC). // The object responsible for Proxy Auto Configuration (PAC).
@NonNull @NonNull
private final PacManager mPacManager; private final PacProxyInstaller mPacProxyInstaller;
public ProxyTracker(@NonNull final Context context, public ProxyTracker(@NonNull final Context context,
@NonNull final Handler connectivityServiceInternalHandler, final int pacChangedEvent) { @NonNull final Handler connectivityServiceInternalHandler, final int pacChangedEvent) {
mContext = context; mContext = context;
mConnectivityServiceHandler = connectivityServiceInternalHandler; 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 // 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)) { if (!TextUtils.isEmpty(pacFileUrl)) {
mConnectivityServiceHandler.post( mConnectivityServiceHandler.post(
() -> mPacManager.setCurrentProxyScriptUrl(proxyProperties)); () -> mPacProxyInstaller.setCurrentProxyScriptUrl(proxyProperties));
} }
} }
} }
@@ -225,7 +226,9 @@ public class ProxyTracker {
final ProxyInfo defaultProxy = getDefaultProxy(); final ProxyInfo defaultProxy = getDefaultProxy();
final ProxyInfo proxyInfo = null != defaultProxy ? final ProxyInfo proxyInfo = null != defaultProxy ?
defaultProxy : ProxyInfo.buildDirectProxy("", 0, Collections.emptyList()); defaultProxy : ProxyInfo.buildDirectProxy("", 0, Collections.emptyList());
if (mPacManager.setCurrentProxyScriptUrl(proxyInfo) == PacManager.DONT_SEND_BROADCAST) {
if (mPacProxyInstaller.setCurrentProxyScriptUrl(proxyInfo)
== PacProxyInstaller.DONT_SEND_BROADCAST) {
return; return;
} }
if (DBG) Log.d(TAG, "sending Proxy Broadcast for " + proxyInfo); if (DBG) Log.d(TAG, "sending Proxy Broadcast for " + proxyInfo);
@@ -305,10 +308,10 @@ public class ProxyTracker {
return; return;
} }
// This call could be coming from the PacManager, containing the port of the local // This call could be coming from the PacProxyInstaller, containing the port of the
// proxy. If this new proxy matches the global proxy then copy this proxy to 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. // 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. // reusing EVENT_HAS_CHANGED_PROXY and this call to handleApplyDefaultProxy.
if ((mGlobalProxy != null) && (proxyInfo != null) if ((mGlobalProxy != null) && (proxyInfo != null)
&& (!Uri.EMPTY.equals(proxyInfo.getPacFileUrl())) && (!Uri.EMPTY.equals(proxyInfo.getPacFileUrl()))