summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Monk <jmonk@google.com>2014-05-07 18:54:12 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-05-07 18:54:12 +0000
commit9d75ccb6a1b3b300c33ce3ceab5eaece0ad55d42 (patch)
treec6982d8d84912809b976a56e5b57d8beb7b737cc
parent39882e0813f22223cd888fb47114d03df8e08613 (diff)
parent207900c23b26d0df9ab28c709db4a1007d7d7904 (diff)
downloadframeworks_base-9d75ccb6a1b3b300c33ce3ceab5eaece0ad55d42.zip
frameworks_base-9d75ccb6a1b3b300c33ce3ceab5eaece0ad55d42.tar.gz
frameworks_base-9d75ccb6a1b3b300c33ce3ceab5eaece0ad55d42.tar.bz2
Merge "Make proxy API public"
-rw-r--r--api/current.txt15
-rw-r--r--core/java/android/app/ActivityThread.java6
-rw-r--r--core/java/android/net/ConnectivityManager.java14
-rw-r--r--core/java/android/net/IConnectivityManager.aidl8
-rw-r--r--core/java/android/net/LinkProperties.java12
-rw-r--r--core/java/android/net/Proxy.java34
-rw-r--r--core/java/android/net/ProxyInfo.aidl (renamed from core/java/android/net/ProxyProperties.aidl)2
-rw-r--r--core/java/android/net/ProxyInfo.java (renamed from core/java/android/net/ProxyProperties.java)176
-rw-r--r--services/core/java/com/android/server/ConnectivityService.java40
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java6
-rw-r--r--services/core/java/com/android/server/connectivity/PacManager.java14
11 files changed, 204 insertions, 123 deletions
diff --git a/api/current.txt b/api/current.txt
index 1c9f871..f2ecf91 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -15712,6 +15712,7 @@ package android.net {
method public android.net.NetworkInfo getActiveNetworkInfo();
method public android.net.NetworkInfo[] getAllNetworkInfo();
method public deprecated boolean getBackgroundDataSetting();
+ method public android.net.ProxyInfo getGlobalProxy();
method public android.net.NetworkInfo getNetworkInfo(int);
method public int getNetworkPreference();
method public boolean isActiveNetworkMetered();
@@ -15719,6 +15720,7 @@ package android.net {
method public static boolean isNetworkTypeValid(int);
method public void registerNetworkActiveListener(android.net.ConnectivityManager.OnNetworkActiveListener);
method public boolean requestRouteToHost(int, int);
+ method public void setGlobalProxy(android.net.ProxyInfo);
method public void setNetworkPreference(int);
method public int startUsingNetworkFeature(int, java.lang.String);
method public int stopUsingNetworkFeature(int, java.lang.String);
@@ -15894,9 +15896,22 @@ package android.net {
method public static final deprecated int getDefaultPort();
method public static final deprecated java.lang.String getHost(android.content.Context);
method public static final deprecated int getPort(android.content.Context);
+ field public static final java.lang.String EXTRA_PROXY_INFO = "android.intent.extra.PROXY_INFO";
field public static final java.lang.String PROXY_CHANGE_ACTION = "android.intent.action.PROXY_CHANGE";
}
+ public class ProxyInfo implements android.os.Parcelable {
+ method public static android.net.ProxyInfo buildDirectProxy(java.lang.String, int);
+ method public static android.net.ProxyInfo buildDirectProxy(java.lang.String, int, java.util.List<java.lang.String>);
+ method public static android.net.ProxyInfo buildPacProxy(android.net.Uri);
+ method public int describeContents();
+ method public java.lang.String[] getExclusionList();
+ method public java.lang.String getHost();
+ method public android.net.Uri getPacFileUrl();
+ method public int getPort();
+ method public void writeToParcel(android.os.Parcel, int);
+ }
+
public class SSLCertificateSocketFactory extends javax.net.ssl.SSLSocketFactory {
ctor public deprecated SSLCertificateSocketFactory(int);
method public java.net.Socket createSocket(java.net.Socket, java.lang.String, int, boolean) throws java.io.IOException;
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 3b2ff7f..b606088 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -46,7 +46,7 @@ import android.graphics.Canvas;
import android.hardware.display.DisplayManagerGlobal;
import android.net.IConnectivityManager;
import android.net.Proxy;
-import android.net.ProxyProperties;
+import android.net.ProxyInfo;
import android.opengl.GLUtils;
import android.os.AsyncTask;
import android.os.Binder;
@@ -4294,8 +4294,8 @@ public final class ActivityThread {
// crash if we can't get it.
IConnectivityManager service = IConnectivityManager.Stub.asInterface(b);
try {
- ProxyProperties proxyProperties = service.getProxy();
- Proxy.setHttpProxySystemProperty(proxyProperties);
+ ProxyInfo proxyInfo = service.getProxy();
+ Proxy.setHttpProxySystemProperty(proxyInfo);
} catch (RemoteException e) {}
}
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index 3da00b1..25708ea 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -1307,14 +1307,13 @@ public class ConnectivityManager {
* doing something unusual like general internal filtering this may be useful. On
* a private network where the proxy is not accessible, you may break HTTP using this.
*
- * @param p The a {@link ProxyProperties} object defining the new global
+ * @param p The a {@link ProxyInfo} object defining the new global
* HTTP proxy. A {@code null} value will clear the global HTTP proxy.
*
* <p>This method requires the call to hold the permission
* {@link android.Manifest.permission#CONNECTIVITY_INTERNAL}.
- * {@hide}
*/
- public void setGlobalProxy(ProxyProperties p) {
+ public void setGlobalProxy(ProxyInfo p) {
try {
mService.setGlobalProxy(p);
} catch (RemoteException e) {
@@ -1324,14 +1323,13 @@ public class ConnectivityManager {
/**
* Retrieve any network-independent global HTTP proxy.
*
- * @return {@link ProxyProperties} for the current global HTTP proxy or {@code null}
+ * @return {@link ProxyInfo} for the current global HTTP proxy or {@code null}
* if no global HTTP proxy is set.
*
* <p>This method requires the call to hold the permission
* {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
- * {@hide}
*/
- public ProxyProperties getGlobalProxy() {
+ public ProxyInfo getGlobalProxy() {
try {
return mService.getGlobalProxy();
} catch (RemoteException e) {
@@ -1343,14 +1341,14 @@ public class ConnectivityManager {
* Get the HTTP proxy settings for the current default network. Note that
* if a global proxy is set, it will override any per-network setting.
*
- * @return the {@link ProxyProperties} for the current HTTP proxy, or {@code null} if no
+ * @return the {@link ProxyInfo} for the current HTTP proxy, or {@code null} if no
* HTTP proxy is active.
*
* <p>This method requires the call to hold the permission
* {@link android.Manifest.permission#ACCESS_NETWORK_STATE}.
* {@hide}
*/
- public ProxyProperties getProxy() {
+ public ProxyInfo getProxy() {
try {
return mService.getProxy();
} catch (RemoteException e) {
diff --git a/core/java/android/net/IConnectivityManager.aidl b/core/java/android/net/IConnectivityManager.aidl
index 381a817..d53a856 100644
--- a/core/java/android/net/IConnectivityManager.aidl
+++ b/core/java/android/net/IConnectivityManager.aidl
@@ -21,7 +21,7 @@ import android.net.LinkProperties;
import android.net.NetworkInfo;
import android.net.NetworkQuotaInfo;
import android.net.NetworkState;
-import android.net.ProxyProperties;
+import android.net.ProxyInfo;
import android.os.IBinder;
import android.os.Messenger;
import android.os.ParcelFileDescriptor;
@@ -107,11 +107,11 @@ interface IConnectivityManager
void reportInetCondition(int networkType, int percentage);
- ProxyProperties getGlobalProxy();
+ ProxyInfo getGlobalProxy();
- void setGlobalProxy(in ProxyProperties p);
+ void setGlobalProxy(in ProxyInfo p);
- ProxyProperties getProxy();
+ ProxyInfo getProxy();
void setDataDependency(int networkType, boolean met);
diff --git a/core/java/android/net/LinkProperties.java b/core/java/android/net/LinkProperties.java
index 4dfd3d9..2dcc544 100644
--- a/core/java/android/net/LinkProperties.java
+++ b/core/java/android/net/LinkProperties.java
@@ -16,7 +16,7 @@
package android.net;
-import android.net.ProxyProperties;
+import android.net.ProxyInfo;
import android.os.Parcelable;
import android.os.Parcel;
import android.text.TextUtils;
@@ -65,7 +65,7 @@ public class LinkProperties implements Parcelable {
private ArrayList<InetAddress> mDnses = new ArrayList<InetAddress>();
private String mDomains;
private ArrayList<RouteInfo> mRoutes = new ArrayList<RouteInfo>();
- private ProxyProperties mHttpProxy;
+ private ProxyInfo mHttpProxy;
private int mMtu;
// Stores the properties of links that are "stacked" above this link.
@@ -101,7 +101,7 @@ public class LinkProperties implements Parcelable {
mDomains = source.getDomains();
for (RouteInfo r : source.getRoutes()) mRoutes.add(r);
mHttpProxy = (source.getHttpProxy() == null) ?
- null : new ProxyProperties(source.getHttpProxy());
+ null : new ProxyInfo(source.getHttpProxy());
for (LinkProperties l: source.mStackedLinks.values()) {
addStackedLink(l);
}
@@ -295,10 +295,10 @@ public class LinkProperties implements Parcelable {
return routes;
}
- public void setHttpProxy(ProxyProperties proxy) {
+ public void setHttpProxy(ProxyInfo proxy) {
mHttpProxy = proxy;
}
- public ProxyProperties getHttpProxy() {
+ public ProxyInfo getHttpProxy() {
return mHttpProxy;
}
@@ -720,7 +720,7 @@ public class LinkProperties implements Parcelable {
netProp.addRoute((RouteInfo)in.readParcelable(null));
}
if (in.readByte() == 1) {
- netProp.setHttpProxy((ProxyProperties)in.readParcelable(null));
+ netProp.setHttpProxy((ProxyInfo)in.readParcelable(null));
}
ArrayList<LinkProperties> stackedLinks = new ArrayList<LinkProperties>();
in.readList(stackedLinks, LinkProperties.class.getClassLoader());
diff --git a/core/java/android/net/Proxy.java b/core/java/android/net/Proxy.java
index bea8d1c..8f41e85 100644
--- a/core/java/android/net/Proxy.java
+++ b/core/java/android/net/Proxy.java
@@ -19,6 +19,7 @@ package android.net;
import android.annotation.SdkConstant;
import android.annotation.SdkConstant.SdkConstantType;
import android.content.Context;
+import android.net.ProxyInfo;
import android.text.TextUtils;
import android.util.Log;
@@ -63,8 +64,11 @@ public final class Proxy {
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
public static final String PROXY_CHANGE_ACTION = "android.intent.action.PROXY_CHANGE";
- /** {@hide} **/
- public static final String EXTRA_PROXY_INFO = "proxy";
+ /**
+ * Intent extra included with {@link #PROXY_CHANGE_ACTION} intents.
+ * It describes the new proxy being used (as a {@link ProxyInfo} object).
+ */
+ public static final String EXTRA_PROXY_INFO = "android.intent.extra.PROXY_INFO";
/** @hide */
public static final int PROXY_VALID = 0;
@@ -114,24 +118,14 @@ public final class Proxy {
*/
public static final java.net.Proxy getProxy(Context ctx, String url) {
String host = "";
- if (url != null) {
+ if ((url != null) && !isLocalHost(host)) {
URI uri = URI.create(url);
- host = uri.getHost();
- }
+ ProxySelector proxySelector = ProxySelector.getDefault();
- if (!isLocalHost(host)) {
- if (sConnectivityManager == null) {
- sConnectivityManager = (ConnectivityManager)ctx.getSystemService(
- Context.CONNECTIVITY_SERVICE);
- }
- if (sConnectivityManager == null) return java.net.Proxy.NO_PROXY;
-
- ProxyProperties proxyProperties = sConnectivityManager.getProxy();
+ List<java.net.Proxy> proxyList = proxySelector.select(uri);
- if (proxyProperties != null) {
- if (!proxyProperties.isExcluded(host)) {
- return proxyProperties.makeProxy();
- }
+ if (proxyList.size() > 0) {
+ return proxyList.get(0);
}
}
return java.net.Proxy.NO_PROXY;
@@ -275,7 +269,7 @@ public final class Proxy {
}
/** @hide */
- public static final void setHttpProxySystemProperty(ProxyProperties p) {
+ public static final void setHttpProxySystemProperty(ProxyInfo p) {
String host = null;
String port = null;
String exclList = null;
@@ -283,8 +277,8 @@ public final class Proxy {
if (p != null) {
host = p.getHost();
port = Integer.toString(p.getPort());
- exclList = p.getExclusionList();
- pacFileUrl = p.getPacFileUrl();
+ exclList = p.getExclusionListAsString();
+ pacFileUrl = p.getPacFileUrl().toString();
}
setHttpProxySystemProperty(host, port, exclList, pacFileUrl);
}
diff --git a/core/java/android/net/ProxyProperties.aidl b/core/java/android/net/ProxyInfo.aidl
index 02ea15d..2c91960 100644
--- a/core/java/android/net/ProxyProperties.aidl
+++ b/core/java/android/net/ProxyInfo.aidl
@@ -17,5 +17,5 @@
package android.net;
-parcelable ProxyProperties;
+parcelable ProxyInfo;
diff --git a/core/java/android/net/ProxyProperties.java b/core/java/android/net/ProxyInfo.java
index 50f45e8..b40941f 100644
--- a/core/java/android/net/ProxyProperties.java
+++ b/core/java/android/net/ProxyInfo.java
@@ -21,14 +21,23 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;
+import org.apache.http.client.HttpClient;
+
import java.net.InetSocketAddress;
+import java.net.URLConnection;
+import java.util.List;
import java.util.Locale;
/**
- * A container class for the http proxy info
- * @hide
+ * Describes a proxy configuration.
+ *
+ * Proxy configurations are already integrated within the Apache HTTP stack.
+ * So {@link URLConnection} and {@link HttpClient} will use them automatically.
+ *
+ * Other HTTP stacks will need to obtain the proxy info from
+ * {@link Proxy#PROXY_CHANGE_ACTION} broadcast as the extra {@link Proxy#EXTRA_PROXY_INFO}.
*/
-public class ProxyProperties implements Parcelable {
+public class ProxyInfo implements Parcelable {
private String mHost;
private int mPort;
@@ -36,32 +45,82 @@ public class ProxyProperties implements Parcelable {
private String[] mParsedExclusionList;
private String mPacFileUrl;
+ /**
+ *@hide
+ */
public static final String LOCAL_EXCL_LIST = "";
+ /**
+ *@hide
+ */
public static final int LOCAL_PORT = -1;
+ /**
+ *@hide
+ */
public static final String LOCAL_HOST = "localhost";
- public ProxyProperties(String host, int port, String exclList) {
+ /**
+ * Constructs a {@link ProxyInfo} object that points at a Direct proxy
+ * on the specified host and port.
+ */
+ public static ProxyInfo buildDirectProxy(String host, int port) {
+ return new ProxyInfo(host, port, null);
+ }
+
+ /**
+ * Constructs a {@link ProxyInfo} object that points at a Direct proxy
+ * on the specified host and port.
+ *
+ * The proxy will not be used to access any host in exclusion list, exclList.
+ *
+ * @param exclList Hosts to exclude using the proxy on connections for. These
+ * hosts can use wildcards such as *.example.com.
+ */
+ public static ProxyInfo buildDirectProxy(String host, int port, List<String> exclList) {
+ String[] array = exclList.toArray(new String[exclList.size()]);
+ return new ProxyInfo(host, port, TextUtils.join(",", array), array);
+ }
+
+ /**
+ * Construct a {@link ProxyInfo} that will download and run the PAC script
+ * at the specified URL.
+ */
+ public static ProxyInfo buildPacProxy(Uri pacUri) {
+ return new ProxyInfo(pacUri.toString());
+ }
+
+ /**
+ * Create a ProxyProperties that points at a HTTP Proxy.
+ * @hide
+ */
+ public ProxyInfo(String host, int port, String exclList) {
mHost = host;
mPort = port;
setExclusionList(exclList);
}
- public ProxyProperties(String pacFileUrl) {
+ /**
+ * Create a ProxyProperties that points at a PAC URL.
+ * @hide
+ */
+ public ProxyInfo(String pacFileUrl) {
mHost = LOCAL_HOST;
mPort = LOCAL_PORT;
setExclusionList(LOCAL_EXCL_LIST);
mPacFileUrl = pacFileUrl;
}
- // Only used in PacManager after Local Proxy is bound.
- public ProxyProperties(String pacFileUrl, int localProxyPort) {
+ /**
+ * Only used in PacManager after Local Proxy is bound.
+ * @hide
+ */
+ public ProxyInfo(String pacFileUrl, int localProxyPort) {
mHost = LOCAL_HOST;
mPort = localProxyPort;
setExclusionList(LOCAL_EXCL_LIST);
mPacFileUrl = pacFileUrl;
}
- private ProxyProperties(String host, int port, String exclList, String[] parsedExclList) {
+ private ProxyInfo(String host, int port, String exclList, String[] parsedExclList) {
mHost = host;
mPort = port;
mExclusionList = exclList;
@@ -70,16 +129,22 @@ public class ProxyProperties implements Parcelable {
}
// copy constructor instead of clone
- public ProxyProperties(ProxyProperties source) {
+ /**
+ * @hide
+ */
+ public ProxyInfo(ProxyInfo source) {
if (source != null) {
mHost = source.getHost();
mPort = source.getPort();
- mPacFileUrl = source.getPacFileUrl();
- mExclusionList = source.getExclusionList();
+ mPacFileUrl = source.mPacFileUrl;
+ mExclusionList = source.getExclusionListAsString();
mParsedExclusionList = source.mParsedExclusionList;
}
}
+ /**
+ * @hide
+ */
public InetSocketAddress getSocketAddress() {
InetSocketAddress inetSocketAddress = null;
try {
@@ -88,20 +153,46 @@ public class ProxyProperties implements Parcelable {
return inetSocketAddress;
}
- public String getPacFileUrl() {
- return mPacFileUrl;
+ /**
+ * Returns the URL of the current PAC script or null if there is
+ * no PAC script.
+ */
+ public Uri getPacFileUrl() {
+ if (TextUtils.isEmpty(mPacFileUrl)) {
+ return null;
+ }
+ return Uri.parse(mPacFileUrl);
}
+ /**
+ * When configured to use a Direct Proxy this returns the host
+ * of the proxy.
+ */
public String getHost() {
return mHost;
}
+ /**
+ * When configured to use a Direct Proxy this returns the port
+ * of the proxy
+ */
public int getPort() {
return mPort;
}
- // comma separated
- public String getExclusionList() {
+ /**
+ * When configured to use a Direct Proxy this returns the list
+ * of hosts for which the proxy is ignored.
+ */
+ public String[] getExclusionList() {
+ return mParsedExclusionList;
+ }
+
+ /**
+ * comma separated
+ * @hide
+ */
+ public String getExclusionListAsString() {
return mExclusionList;
}
@@ -111,33 +202,13 @@ public class ProxyProperties implements Parcelable {
if (mExclusionList == null) {
mParsedExclusionList = new String[0];
} else {
- String splitExclusionList[] = exclusionList.toLowerCase(Locale.ROOT).split(",");
- mParsedExclusionList = new String[splitExclusionList.length * 2];
- for (int i = 0; i < splitExclusionList.length; i++) {
- String s = splitExclusionList[i].trim();
- if (s.startsWith(".")) s = s.substring(1);
- mParsedExclusionList[i*2] = s;
- mParsedExclusionList[(i*2)+1] = "." + s;
- }
+ mParsedExclusionList = exclusionList.toLowerCase(Locale.ROOT).split(",");
}
}
- public boolean isExcluded(String url) {
- if (TextUtils.isEmpty(url) || mParsedExclusionList == null ||
- mParsedExclusionList.length == 0) return false;
-
- Uri u = Uri.parse(url);
- String urlDomain = u.getHost();
- if (urlDomain == null) return false;
- for (int i = 0; i< mParsedExclusionList.length; i+=2) {
- if (urlDomain.equals(mParsedExclusionList[i]) ||
- urlDomain.endsWith(mParsedExclusionList[i+1])) {
- return true;
- }
- }
- return false;
- }
-
+ /**
+ * @hide
+ */
public boolean isValid() {
if (!TextUtils.isEmpty(mPacFileUrl)) return true;
return Proxy.PROXY_VALID == Proxy.validate(mHost == null ? "" : mHost,
@@ -145,6 +216,9 @@ public class ProxyProperties implements Parcelable {
mExclusionList == null ? "" : mExclusionList);
}
+ /**
+ * @hide
+ */
public java.net.Proxy makeProxy() {
java.net.Proxy proxy = java.net.Proxy.NO_PROXY;
if (mHost != null) {
@@ -179,17 +253,17 @@ public class ProxyProperties implements Parcelable {
@Override
public boolean equals(Object o) {
- if (!(o instanceof ProxyProperties)) return false;
- ProxyProperties p = (ProxyProperties)o;
+ if (!(o instanceof ProxyInfo)) return false;
+ ProxyInfo p = (ProxyInfo)o;
// If PAC URL is present in either then they must be equal.
// Other parameters will only be for fall back.
if (!TextUtils.isEmpty(mPacFileUrl)) {
return mPacFileUrl.equals(p.getPacFileUrl()) && mPort == p.mPort;
}
- if (!TextUtils.isEmpty(p.getPacFileUrl())) {
+ if (!TextUtils.isEmpty(p.mPacFileUrl)) {
return false;
}
- if (mExclusionList != null && !mExclusionList.equals(p.getExclusionList())) return false;
+ if (mExclusionList != null && !mExclusionList.equals(p.getExclusionListAsString())) return false;
if (mHost != null && p.getHost() != null && mHost.equals(p.getHost()) == false) {
return false;
}
@@ -245,15 +319,15 @@ public class ProxyProperties implements Parcelable {
* Implement the Parcelable interface.
* @hide
*/
- public static final Creator<ProxyProperties> CREATOR =
- new Creator<ProxyProperties>() {
- public ProxyProperties createFromParcel(Parcel in) {
+ public static final Creator<ProxyInfo> CREATOR =
+ new Creator<ProxyInfo>() {
+ public ProxyInfo createFromParcel(Parcel in) {
String host = null;
int port = 0;
if (in.readByte() != 0) {
String url = in.readString();
int localPort = in.readInt();
- return new ProxyProperties(url, localPort);
+ return new ProxyInfo(url, localPort);
}
if (in.readByte() != 0) {
host = in.readString();
@@ -261,13 +335,13 @@ public class ProxyProperties implements Parcelable {
}
String exclList = in.readString();
String[] parsedExclList = in.readStringArray();
- ProxyProperties proxyProperties =
- new ProxyProperties(host, port, exclList, parsedExclList);
+ ProxyInfo proxyProperties =
+ new ProxyInfo(host, port, exclList, parsedExclList);
return proxyProperties;
}
- public ProxyProperties[] newArray(int size) {
- return new ProxyProperties[size];
+ public ProxyInfo[] newArray(int size) {
+ return new ProxyInfo[size];
}
};
}
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index 45cdb65..ea03eb7 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -74,7 +74,7 @@ import android.net.NetworkStateTracker;
import android.net.NetworkUtils;
import android.net.Proxy;
import android.net.ProxyDataTracker;
-import android.net.ProxyProperties;
+import android.net.ProxyInfo;
import android.net.RouteInfo;
import android.net.SamplingDataTracker;
import android.net.Uri;
@@ -406,12 +406,12 @@ public class ConnectivityService extends IConnectivityManager.Stub {
private ArrayList mInetLog;
// track the current default http proxy - tell the world if we get a new one (real change)
- private ProxyProperties mDefaultProxy = null;
+ private ProxyInfo mDefaultProxy = null;
private Object mProxyLock = new Object();
private boolean mDefaultProxyDisabled = false;
// track the global proxy.
- private ProxyProperties mGlobalProxy = null;
+ private ProxyInfo mGlobalProxy = null;
private PacManager mPacManager = null;
@@ -3192,7 +3192,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
break;
}
case EVENT_PROXY_HAS_CHANGED: {
- handleApplyDefaultProxy((ProxyProperties)msg.obj);
+ handleApplyDefaultProxy((ProxyInfo)msg.obj);
break;
}
}
@@ -3410,19 +3410,19 @@ public class ConnectivityService extends IConnectivityManager.Stub {
return;
}
- public ProxyProperties getProxy() {
+ public ProxyInfo getProxy() {
// this information is already available as a world read/writable jvm property
// so this API change wouldn't have a benifit. It also breaks the passing
// of proxy info to all the JVMs.
// enforceAccessPermission();
synchronized (mProxyLock) {
- ProxyProperties ret = mGlobalProxy;
+ ProxyInfo ret = mGlobalProxy;
if ((ret == null) && !mDefaultProxyDisabled) ret = mDefaultProxy;
return ret;
}
}
- public void setGlobalProxy(ProxyProperties proxyProperties) {
+ public void setGlobalProxy(ProxyInfo proxyProperties) {
enforceConnectivityInternalPermission();
synchronized (mProxyLock) {
@@ -3435,18 +3435,18 @@ public class ConnectivityService extends IConnectivityManager.Stub {
String exclList = "";
String pacFileUrl = "";
if (proxyProperties != null && (!TextUtils.isEmpty(proxyProperties.getHost()) ||
- !TextUtils.isEmpty(proxyProperties.getPacFileUrl()))) {
+ (proxyProperties.getPacFileUrl() != null))) {
if (!proxyProperties.isValid()) {
if (DBG)
log("Invalid proxy properties, ignoring: " + proxyProperties.toString());
return;
}
- mGlobalProxy = new ProxyProperties(proxyProperties);
+ mGlobalProxy = new ProxyInfo(proxyProperties);
host = mGlobalProxy.getHost();
port = mGlobalProxy.getPort();
- exclList = mGlobalProxy.getExclusionList();
+ exclList = mGlobalProxy.getExclusionListAsString();
if (proxyProperties.getPacFileUrl() != null) {
- pacFileUrl = proxyProperties.getPacFileUrl();
+ pacFileUrl = proxyProperties.getPacFileUrl().toString();
}
} else {
mGlobalProxy = null;
@@ -3478,11 +3478,11 @@ public class ConnectivityService extends IConnectivityManager.Stub {
Settings.Global.GLOBAL_HTTP_PROXY_EXCLUSION_LIST);
String pacFileUrl = Settings.Global.getString(res, Settings.Global.GLOBAL_HTTP_PROXY_PAC);
if (!TextUtils.isEmpty(host) || !TextUtils.isEmpty(pacFileUrl)) {
- ProxyProperties proxyProperties;
+ ProxyInfo proxyProperties;
if (!TextUtils.isEmpty(pacFileUrl)) {
- proxyProperties = new ProxyProperties(pacFileUrl);
+ proxyProperties = new ProxyInfo(pacFileUrl);
} else {
- proxyProperties = new ProxyProperties(host, port, exclList);
+ proxyProperties = new ProxyInfo(host, port, exclList);
}
if (!proxyProperties.isValid()) {
if (DBG) log("Invalid proxy properties, ignoring: " + proxyProperties.toString());
@@ -3495,7 +3495,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
}
}
- public ProxyProperties getGlobalProxy() {
+ public ProxyInfo getGlobalProxy() {
// this information is already available as a world read/writable jvm property
// so this API change wouldn't have a benifit. It also breaks the passing
// of proxy info to all the JVMs.
@@ -3505,9 +3505,9 @@ public class ConnectivityService extends IConnectivityManager.Stub {
}
}
- private void handleApplyDefaultProxy(ProxyProperties proxy) {
+ private void handleApplyDefaultProxy(ProxyInfo proxy) {
if (proxy != null && TextUtils.isEmpty(proxy.getHost())
- && TextUtils.isEmpty(proxy.getPacFileUrl())) {
+ && (proxy.getPacFileUrl() == null)) {
proxy = null;
}
synchronized (mProxyLock) {
@@ -3544,13 +3544,13 @@ public class ConnectivityService extends IConnectivityManager.Stub {
return;
}
}
- ProxyProperties p = new ProxyProperties(data[0], proxyPort, "");
+ ProxyInfo p = new ProxyInfo(data[0], proxyPort, "");
setGlobalProxy(p);
}
}
- private void sendProxyBroadcast(ProxyProperties proxy) {
- if (proxy == null) proxy = new ProxyProperties("", 0, "");
+ private void sendProxyBroadcast(ProxyInfo proxy) {
+ if (proxy == null) proxy = new ProxyInfo("", 0, "");
if (mPacManager.setCurrentProxyScriptUrl(proxy)) return;
if (DBG) log("sending Proxy Broadcast for " + proxy);
Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION);
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index cbb8377..a7a24e5 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -136,7 +136,7 @@ import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.net.Proxy;
-import android.net.ProxyProperties;
+import android.net.ProxyInfo;
import android.net.Uri;
import android.os.Binder;
import android.os.Build;
@@ -1323,7 +1323,7 @@ public final class ActivityManagerService extends ActivityManagerNative
}
} break;
case UPDATE_HTTP_PROXY_MSG: {
- ProxyProperties proxy = (ProxyProperties)msg.obj;
+ ProxyInfo proxy = (ProxyInfo)msg.obj;
String host = "";
String port = "";
String exclList = "";
@@ -13758,7 +13758,7 @@ public final class ActivityManagerService extends ActivityManagerNative
}
if (Proxy.PROXY_CHANGE_ACTION.equals(intent.getAction())) {
- ProxyProperties proxy = intent.getParcelableExtra("proxy");
+ ProxyInfo proxy = intent.getParcelableExtra("proxy");
mHandler.sendMessage(mHandler.obtainMessage(UPDATE_HTTP_PROXY_MSG, proxy));
}
diff --git a/services/core/java/com/android/server/connectivity/PacManager.java b/services/core/java/com/android/server/connectivity/PacManager.java
index 8815d0f..0749f24 100644
--- a/services/core/java/com/android/server/connectivity/PacManager.java
+++ b/services/core/java/com/android/server/connectivity/PacManager.java
@@ -24,7 +24,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.ServiceConnection;
-import android.net.ProxyProperties;
+import android.net.ProxyInfo;
import android.os.Handler;
import android.os.IBinder;
import android.os.RemoteException;
@@ -157,14 +157,14 @@ public class PacManager {
* @param proxy Proxy information that is about to be broadcast.
* @return Returns true when the broadcast should not be sent
*/
- public synchronized boolean setCurrentProxyScriptUrl(ProxyProperties proxy) {
- if (!TextUtils.isEmpty(proxy.getPacFileUrl())) {
+ public synchronized boolean setCurrentProxyScriptUrl(ProxyInfo proxy) {
+ if (proxy.getPacFileUrl() != null) {
if (proxy.getPacFileUrl().equals(mPacUrl) && (proxy.getPort() > 0)) {
// Allow to send broadcast, nothing to do.
return false;
}
synchronized (mProxyLock) {
- mPacUrl = proxy.getPacFileUrl();
+ mPacUrl = proxy.getPacFileUrl().toString();
}
mCurrentDelay = DELAY_1;
mHasSentBroadcast = false;
@@ -268,7 +268,7 @@ public class PacManager {
// Already bound no need to bind again.
if ((mProxyConnection != null) && (mConnection != null)) {
if (mLastPort != -1) {
- sendPacBroadcast(new ProxyProperties(mPacUrl, mLastPort));
+ sendPacBroadcast(new ProxyInfo(mPacUrl, mLastPort));
} else {
Log.e(TAG, "Received invalid port from Local Proxy,"
+ " PAC will not be operational");
@@ -362,7 +362,7 @@ public class PacManager {
mLastPort = -1;
}
- private void sendPacBroadcast(ProxyProperties proxy) {
+ private void sendPacBroadcast(ProxyInfo proxy) {
mConnectivityHandler.sendMessage(mConnectivityHandler.obtainMessage(mProxyMessage, proxy));
}
@@ -371,7 +371,7 @@ public class PacManager {
return;
}
if (!mHasSentBroadcast) {
- sendPacBroadcast(new ProxyProperties(mPacUrl, mLastPort));
+ sendPacBroadcast(new ProxyInfo(mPacUrl, mLastPort));
mHasSentBroadcast = true;
}
}