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:
@@ -20,6 +20,7 @@ import android.os.ServiceManager;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.net.IProxyService;
|
import com.android.net.IProxyService;
|
||||||
|
|
||||||
import com.google.android.collect.Lists;
|
import com.google.android.collect.Lists;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -50,7 +51,7 @@ public class PacProxySelector extends ProxySelector {
|
|||||||
ServiceManager.getService(PROXY_SERVICE));
|
ServiceManager.getService(PROXY_SERVICE));
|
||||||
if (mProxyService == null) {
|
if (mProxyService == null) {
|
||||||
// Added because of b10267814 where mako is restarting.
|
// 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);
|
mDefaultList = Lists.newArrayList(java.net.Proxy.NO_PROXY);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ import android.os.RemoteException;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.net.IProxyPortListener;
|
import com.android.net.IProxyPortListener;
|
||||||
|
|
||||||
import com.google.android.collect.Lists;
|
import com.google.android.collect.Lists;
|
||||||
import com.google.android.collect.Sets;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@@ -34,7 +34,6 @@ import java.net.SocketException;
|
|||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
|
||||||
@@ -361,7 +360,7 @@ public class ProxyServer extends Thread {
|
|||||||
try {
|
try {
|
||||||
mCallback.setProxyPort(port);
|
mCallback.setProxyPort(port);
|
||||||
} catch (RemoteException e) {
|
} 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;
|
mPort = port;
|
||||||
@@ -372,7 +371,7 @@ public class ProxyServer extends Thread {
|
|||||||
try {
|
try {
|
||||||
callback.setProxyPort(mPort);
|
callback.setProxyPort(mPort);
|
||||||
} catch (RemoteException e) {
|
} 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;
|
mCallback = callback;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class ProxyService extends Service {
|
|||||||
|
|
||||||
private static ProxyServer server = null;
|
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 KEY_PROXY = "keyProxy";
|
||||||
public static final String HOST = "localhost";
|
public static final String HOST = "localhost";
|
||||||
public static final String EXCL_LIST = "";
|
public static final String EXCL_LIST = "";
|
||||||
|
|||||||
@@ -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");
|
* 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.
|
||||||
* You may obtain a copy of the License at
|
* 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
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* 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
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.server.connectivity;
|
package com.android.server.connectivity;
|
||||||
|
|
||||||
import android.annotation.WorkerThread;
|
import android.annotation.WorkerThread;
|
||||||
@@ -52,7 +53,7 @@ import java.net.URLConnection;
|
|||||||
/**
|
/**
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public class PacManager {
|
public class PacProxyInstaller {
|
||||||
private static final String PAC_PACKAGE = "com.android.pacprocessor";
|
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 = "com.android.pacprocessor.PacService";
|
||||||
private static final String PAC_SERVICE_NAME = "com.android.net.IProxyService";
|
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_PACKAGE = "com.android.proxyhandler";
|
||||||
private static final String PROXY_SERVICE = "com.android.proxyhandler.ProxyService";
|
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";
|
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;
|
mContext = context;
|
||||||
mLastPort = -1;
|
mLastPort = -1;
|
||||||
final HandlerThread netThread = new HandlerThread("android.pacmanager",
|
final HandlerThread netThread = new HandlerThread("android.pacproxyinstaller",
|
||||||
android.os.Process.THREAD_PRIORITY_DEFAULT);
|
android.os.Process.THREAD_PRIORITY_DEFAULT);
|
||||||
netThread.start();
|
netThread.start();
|
||||||
mNetThreadHandler = new Handler(netThread.getLooper());
|
mNetThreadHandler = new Handler(netThread.getLooper());
|
||||||
@@ -163,16 +164,16 @@ public class PacManager {
|
|||||||
|
|
||||||
private AlarmManager getAlarmManager() {
|
private AlarmManager getAlarmManager() {
|
||||||
if (mAlarmManager == null) {
|
if (mAlarmManager == null) {
|
||||||
mAlarmManager = (AlarmManager)mContext.getSystemService(Context.ALARM_SERVICE);
|
mAlarmManager = mContext.getSystemService(AlarmManager.class);
|
||||||
}
|
}
|
||||||
return mAlarmManager;
|
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 ProxyTracker directly before a broadcast takes place to allow
|
||||||
* the PacManager to indicate that the broadcast should not be sent and the
|
* the PacProxyInstaller to indicate that the broadcast should not be sent and the
|
||||||
* PacManager will trigger a new broadcast when it is ready.
|
* PacProxyInstaller will trigger a new broadcast when it is ready.
|
||||||
*
|
*
|
||||||
* @param proxy Proxy information that is about to be broadcast.
|
* @param proxy Proxy information that is about to be broadcast.
|
||||||
* @return Returns whether the broadcast should be sent : either DO_ or DONT_SEND_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) {
|
private int getNextDelay(int currentDelay) {
|
||||||
if (++currentDelay > DELAY_4) {
|
if (++currentDelay > DELAY_4) {
|
||||||
return DELAY_4;
|
return DELAY_4;
|
||||||
}
|
}
|
||||||
return currentDelay;
|
return currentDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void longSchedule() {
|
private void longSchedule() {
|
||||||
@@ -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()))
|
||||||
|
|||||||
Reference in New Issue
Block a user