summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/java/android/net/Proxy.java13
-rw-r--r--core/java/android/net/ProxyProperties.java38
-rw-r--r--telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java5
3 files changed, 26 insertions, 30 deletions
diff --git a/core/java/android/net/Proxy.java b/core/java/android/net/Proxy.java
index e2e4d2c..9c63cd9 100644
--- a/core/java/android/net/Proxy.java
+++ b/core/java/android/net/Proxy.java
@@ -46,6 +46,8 @@ public final class Proxy {
// Set to true to enable extra debugging.
private static final boolean DEBUG = false;
+ // Used to notify an app that's caching the default connection proxy
+ // that either the default connection or its proxy has changed
public static final String PROXY_CHANGE_ACTION =
"android.intent.action.PROXY_CHANGE";
@@ -74,9 +76,10 @@ public final class Proxy {
EXCLLIST_PATTERN = Pattern.compile(EXCLLIST_REGEXP);
}
+ // useful because it holds the processed exclusion list - don't want to reparse it each time
private static class ProxySpec {
String[] exclusionList = null;
- InetSocketAddress proxyAddress = null;
+ InetSocketAddress address = null;
public ProxySpec() { };
}
@@ -151,7 +154,7 @@ public final class Proxy {
retval = java.net.Proxy.NO_PROXY;
} else {
retval =
- new java.net.Proxy(java.net.Proxy.Type.HTTP, sGlobalProxySpec.proxyAddress);
+ new java.net.Proxy(java.net.Proxy.Type.HTTP, sGlobalProxySpec.address);
}
} else {
// If network is WiFi, return no proxy.
@@ -187,7 +190,7 @@ public final class Proxy {
parseGlobalProxyInfoReadLocked(ctx);
}
if (sGlobalProxySpec != null) {
- InetSocketAddress sa = sGlobalProxySpec.proxyAddress;
+ InetSocketAddress sa = sGlobalProxySpec.address;
return sa.getHostName();
}
return getDefaultHost();
@@ -210,7 +213,7 @@ public final class Proxy {
parseGlobalProxyInfoReadLocked(ctx);
}
if (sGlobalProxySpec != null) {
- InetSocketAddress sa = sGlobalProxySpec.proxyAddress;
+ InetSocketAddress sa = sGlobalProxySpec.address;
return sa.getPort();
}
return getDefaultPort();
@@ -389,7 +392,7 @@ public final class Proxy {
int port = parsePort(proxyHost);
if (proxyHost != null) {
sGlobalProxySpec = new ProxySpec();
- sGlobalProxySpec.proxyAddress = new InetSocketAddress(host, port);
+ sGlobalProxySpec.address= new InetSocketAddress(host, port);
if ((exclusionListSpec != null) && (exclusionListSpec.length() != 0)) {
String[] exclusionListEntries = exclusionListSpec.toLowerCase().split(",");
String[] processedEntries = new String[exclusionListEntries.length];
diff --git a/core/java/android/net/ProxyProperties.java b/core/java/android/net/ProxyProperties.java
index bce7ec0..fb59fed 100644
--- a/core/java/android/net/ProxyProperties.java
+++ b/core/java/android/net/ProxyProperties.java
@@ -21,6 +21,7 @@ import android.os.Parcel;
import android.os.Parcelable;
import java.net.InetAddress;
+import java.net.InetSocketAddress;
import java.net.UnknownHostException;
/**
@@ -29,8 +30,7 @@ import java.net.UnknownHostException;
*/
public class ProxyProperties implements Parcelable {
- private InetAddress mProxy;
- private int mPort;
+ private InetSocketAddress mProxy;
private String mExclusionList;
public ProxyProperties() {
@@ -39,8 +39,7 @@ public class ProxyProperties implements Parcelable {
// copy constructor instead of clone
public ProxyProperties(ProxyProperties source) {
if (source != null) {
- mProxy = source.getAddress();
- mPort = source.getPort();
+ mProxy = source.getSocketAddress();
String exclusionList = source.getExclusionList();
if (exclusionList != null) {
mExclusionList = new String(exclusionList);
@@ -48,22 +47,14 @@ public class ProxyProperties implements Parcelable {
}
}
- public InetAddress getAddress() {
+ public InetSocketAddress getSocketAddress() {
return mProxy;
}
- public void setAddress(InetAddress proxy) {
+ public void setSocketAddress(InetSocketAddress proxy) {
mProxy = proxy;
}
- public int getPort() {
- return mPort;
- }
-
- public void setPort(int port) {
- mPort = port;
- }
-
public String getExclusionList() {
return mExclusionList;
}
@@ -76,7 +67,7 @@ public class ProxyProperties implements Parcelable {
public String toString() {
StringBuilder sb = new StringBuilder();
if (mProxy != null) {
- sb.append(mProxy.getHostAddress()).append(":").append(mPort);
+ sb.append(mProxy.toString());
if (mExclusionList != null) {
sb.append(" xl=").append(mExclusionList);
}
@@ -98,13 +89,15 @@ public class ProxyProperties implements Parcelable {
*/
public void writeToParcel(Parcel dest, int flags) {
if (mProxy != null) {
- dest.writeByte((byte)1);
- dest.writeString(mProxy.getHostName());
- dest.writeByteArray(mProxy.getAddress());
+ InetAddress addr = mProxy.getAddress();
+ if (addr != null) {
+ dest.writeByte((byte)1);
+ dest.writeByteArray(addr.getAddress());
+ dest.writeInt(mProxy.getPort());
+ }
} else {
dest.writeByte((byte)0);
}
- dest.writeInt(mPort);
dest.writeString(mExclusionList);
}
@@ -118,11 +111,10 @@ public class ProxyProperties implements Parcelable {
ProxyProperties proxyProperties = new ProxyProperties();
if (in.readByte() == 1) {
try {
- proxyProperties.setAddress(InetAddress.getByAddress(in.readString(),
- in.createByteArray()));
- } catch (UnknownHostException e) {}
+ InetAddress addr = InetAddress.getByAddress(in.createByteArray());
+ proxyProperties.setSocketAddress(new InetSocketAddress(addr, in.readInt()));
+ } catch (UnknownHostException e) { }
}
- proxyProperties.setPort(in.readInt());
proxyProperties.setExclusionList(in.readString());
return proxyProperties;
}
diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
index 4414460..885e5bc 100644
--- a/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
+++ b/telephony/java/com/android/internal/telephony/gsm/GsmDataConnectionTracker.java
@@ -58,6 +58,7 @@ import com.android.internal.telephony.DataConnection.FailCause;
import java.io.IOException;
import java.net.InetAddress;
+import java.net.InetSocketAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
@@ -1104,8 +1105,8 @@ public final class GsmDataConnectionTracker extends DataConnectionTracker {
if (apn.proxy != null && apn.proxy.length() != 0) {
try {
ProxyProperties proxy = new ProxyProperties();
- proxy.setAddress(InetAddress.getByName(apn.proxy));
- proxy.setPort(Integer.parseInt(apn.port));
+ proxy.setSocketAddress(new InetSocketAddress(InetAddress.getByName(apn.proxy),
+ Integer.parseInt(apn.port)));
mLinkProperties.setHttpProxy(proxy);
} catch (UnknownHostException e) {
Log.e(LOG_TAG, "UnknownHostException making ProxyProperties: " + e);