Merge "Some cleanup of Proxy class."
This commit is contained in:
committed by
Android (Google) Code Review
commit
75ba3f8068
@@ -21,6 +21,7 @@ import android.os.Parcel;
|
|||||||
import android.os.Parcelable;
|
import android.os.Parcelable;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
import java.net.InetSocketAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,8 +30,7 @@ import java.net.UnknownHostException;
|
|||||||
*/
|
*/
|
||||||
public class ProxyProperties implements Parcelable {
|
public class ProxyProperties implements Parcelable {
|
||||||
|
|
||||||
private InetAddress mProxy;
|
private InetSocketAddress mProxy;
|
||||||
private int mPort;
|
|
||||||
private String mExclusionList;
|
private String mExclusionList;
|
||||||
|
|
||||||
public ProxyProperties() {
|
public ProxyProperties() {
|
||||||
@@ -39,8 +39,7 @@ public class ProxyProperties implements Parcelable {
|
|||||||
// copy constructor instead of clone
|
// copy constructor instead of clone
|
||||||
public ProxyProperties(ProxyProperties source) {
|
public ProxyProperties(ProxyProperties source) {
|
||||||
if (source != null) {
|
if (source != null) {
|
||||||
mProxy = source.getAddress();
|
mProxy = source.getSocketAddress();
|
||||||
mPort = source.getPort();
|
|
||||||
String exclusionList = source.getExclusionList();
|
String exclusionList = source.getExclusionList();
|
||||||
if (exclusionList != null) {
|
if (exclusionList != null) {
|
||||||
mExclusionList = new String(exclusionList);
|
mExclusionList = new String(exclusionList);
|
||||||
@@ -48,22 +47,14 @@ public class ProxyProperties implements Parcelable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public InetAddress getAddress() {
|
public InetSocketAddress getSocketAddress() {
|
||||||
return mProxy;
|
return mProxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAddress(InetAddress proxy) {
|
public void setSocketAddress(InetSocketAddress proxy) {
|
||||||
mProxy = proxy;
|
mProxy = proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPort() {
|
|
||||||
return mPort;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPort(int port) {
|
|
||||||
mPort = port;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getExclusionList() {
|
public String getExclusionList() {
|
||||||
return mExclusionList;
|
return mExclusionList;
|
||||||
}
|
}
|
||||||
@@ -76,7 +67,7 @@ public class ProxyProperties implements Parcelable {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
if (mProxy != null) {
|
if (mProxy != null) {
|
||||||
sb.append(mProxy.getHostAddress()).append(":").append(mPort);
|
sb.append(mProxy.toString());
|
||||||
if (mExclusionList != null) {
|
if (mExclusionList != null) {
|
||||||
sb.append(" xl=").append(mExclusionList);
|
sb.append(" xl=").append(mExclusionList);
|
||||||
}
|
}
|
||||||
@@ -98,13 +89,15 @@ public class ProxyProperties implements Parcelable {
|
|||||||
*/
|
*/
|
||||||
public void writeToParcel(Parcel dest, int flags) {
|
public void writeToParcel(Parcel dest, int flags) {
|
||||||
if (mProxy != null) {
|
if (mProxy != null) {
|
||||||
dest.writeByte((byte)1);
|
InetAddress addr = mProxy.getAddress();
|
||||||
dest.writeString(mProxy.getHostName());
|
if (addr != null) {
|
||||||
dest.writeByteArray(mProxy.getAddress());
|
dest.writeByte((byte)1);
|
||||||
|
dest.writeByteArray(addr.getAddress());
|
||||||
|
dest.writeInt(mProxy.getPort());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
dest.writeByte((byte)0);
|
dest.writeByte((byte)0);
|
||||||
}
|
}
|
||||||
dest.writeInt(mPort);
|
|
||||||
dest.writeString(mExclusionList);
|
dest.writeString(mExclusionList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,11 +111,10 @@ public class ProxyProperties implements Parcelable {
|
|||||||
ProxyProperties proxyProperties = new ProxyProperties();
|
ProxyProperties proxyProperties = new ProxyProperties();
|
||||||
if (in.readByte() == 1) {
|
if (in.readByte() == 1) {
|
||||||
try {
|
try {
|
||||||
proxyProperties.setAddress(InetAddress.getByAddress(in.readString(),
|
InetAddress addr = InetAddress.getByAddress(in.createByteArray());
|
||||||
in.createByteArray()));
|
proxyProperties.setSocketAddress(new InetSocketAddress(addr, in.readInt()));
|
||||||
} catch (UnknownHostException e) {}
|
} catch (UnknownHostException e) { }
|
||||||
}
|
}
|
||||||
proxyProperties.setPort(in.readInt());
|
|
||||||
proxyProperties.setExclusionList(in.readString());
|
proxyProperties.setExclusionList(in.readString());
|
||||||
return proxyProperties;
|
return proxyProperties;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user