Merge "Rename PacManager to PacProxyInstaller" am: 3b26172c84

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1513130

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Idf8192ca563275048acccbf6163f7effc4b04781
This commit is contained in:
Aaron Huang
2021-01-14 01:54:51 +00:00
committed by Automerger Merge Worker
6 changed files with 35 additions and 31 deletions

View File

@@ -20,6 +20,7 @@ import android.os.ServiceManager;
import android.util.Log;
import com.android.net.IProxyService;
import com.google.android.collect.Lists;
import java.io.IOException;
@@ -50,7 +51,7 @@ public class PacProxySelector extends ProxySelector {
ServiceManager.getService(PROXY_SERVICE));
if (mProxyService == null) {
// Added because of b10267814 where mako is restarting.
Log.e(TAG, "PacManager: no proxy service");
Log.e(TAG, "PacProxyInstaller: no proxy service");
}
mDefaultList = Lists.newArrayList(java.net.Proxy.NO_PROXY);
}

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

@@ -19,8 +19,8 @@ import android.os.RemoteException;
import android.util.Log;
import com.android.net.IProxyPortListener;
import com.google.android.collect.Lists;
import com.google.android.collect.Sets;
import java.io.IOException;
import java.io.InputStream;
@@ -34,7 +34,6 @@ import java.net.SocketException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -361,7 +360,7 @@ public class ProxyServer extends Thread {
try {
mCallback.setProxyPort(port);
} catch (RemoteException e) {
Log.w(TAG, "Proxy failed to report port to PacManager", e);
Log.w(TAG, "Proxy failed to report port to PacProxyInstaller", e);
}
}
mPort = port;
@@ -372,7 +371,7 @@ public class ProxyServer extends Thread {
try {
callback.setProxyPort(mPort);
} catch (RemoteException e) {
Log.w(TAG, "Proxy failed to report port to PacManager", e);
Log.w(TAG, "Proxy failed to report port to PacProxyInstaller", e);
}
}
mCallback = callback;

View File

@@ -30,7 +30,7 @@ public class ProxyService extends Service {
private static ProxyServer server = null;
/** Keep these values up-to-date with PacManager.java */
/** Keep these values up-to-date with PacProxyInstaller.java */
public static final String KEY_PROXY = "keyProxy";
public static final String HOST = "localhost";
public static final String EXCL_LIST = "";

View File

@@ -1,11 +1,11 @@
/**
* Copyright (c) 2013, The Android Open Source Project
/*
* Copyright (C) 2013 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.server.connectivity;
import android.annotation.WorkerThread;
@@ -52,7 +53,7 @@ import java.net.URLConnection;
/**
* @hide
*/
public class PacManager {
public class PacProxyInstaller {
private static final String PAC_PACKAGE = "com.android.pacprocessor";
private static final String PAC_SERVICE = "com.android.pacprocessor.PacService";
private static final String PAC_SERVICE_NAME = "com.android.net.IProxyService";
@@ -60,7 +61,7 @@ public class PacManager {
private static final String PROXY_PACKAGE = "com.android.proxyhandler";
private static final String PROXY_SERVICE = "com.android.proxyhandler.ProxyService";
private static final String TAG = "PacManager";
private static final String TAG = "PacProxyInstaller";
private static final String ACTION_PAC_REFRESH = "android.net.proxy.PAC_REFRESH";
@@ -145,10 +146,10 @@ public class PacManager {
}
}
public PacManager(Context context, Handler handler, int proxyMessage) {
public PacProxyInstaller(Context context, Handler handler, int proxyMessage) {
mContext = context;
mLastPort = -1;
final HandlerThread netThread = new HandlerThread("android.pacmanager",
final HandlerThread netThread = new HandlerThread("android.pacproxyinstaller",
android.os.Process.THREAD_PRIORITY_DEFAULT);
netThread.start();
mNetThreadHandler = new Handler(netThread.getLooper());
@@ -163,16 +164,16 @@ public class PacManager {
private AlarmManager getAlarmManager() {
if (mAlarmManager == null) {
mAlarmManager = (AlarmManager)mContext.getSystemService(Context.ALARM_SERVICE);
mAlarmManager = mContext.getSystemService(AlarmManager.class);
}
return mAlarmManager;
}
/**
* Updates the PAC Manager with current Proxy information. This is called by
* Updates the PAC Proxy Installer with current Proxy information. This is called by
* the ProxyTracker directly before a broadcast takes place to allow
* the PacManager to indicate that the broadcast should not be sent and the
* PacManager will trigger a new broadcast when it is ready.
* the PacProxyInstaller to indicate that the broadcast should not be sent and the
* PacProxyInstaller will trigger a new broadcast when it is ready.
*
* @param proxy Proxy information that is about to be broadcast.
* @return Returns whether the broadcast should be sent : either DO_ or DONT_SEND_BROADCAST
@@ -233,10 +234,10 @@ public class PacManager {
}
private int getNextDelay(int currentDelay) {
if (++currentDelay > DELAY_4) {
return DELAY_4;
}
return currentDelay;
if (++currentDelay > DELAY_4) {
return DELAY_4;
}
return currentDelay;
}
private void longSchedule() {

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()))