Merge "use hostname when address null ProxyProperties parcelling"

This commit is contained in:
Irfan Sheriff
2010-09-27 16:24:23 -07:00
committed by Android (Google) Code Review

View File

@@ -88,13 +88,23 @@ public class ProxyProperties implements Parcelable {
* @hide * @hide
*/ */
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
String host = null;
if (mProxy != null) { if (mProxy != null) {
InetAddress addr = mProxy.getAddress(); try {
if (addr != null) { InetAddress addr = mProxy.getAddress();
dest.writeByte((byte)1); if (addr != null) {
dest.writeByteArray(addr.getAddress()); host = addr.getHostAddress();
dest.writeInt(mProxy.getPort()); } else {
} /* Does not resolve when addr is null */
host = mProxy.getHostName();
}
} catch (Exception e) { }
}
if (host != null) {
dest.writeByte((byte)1);
dest.writeString(host);
dest.writeInt(mProxy.getPort());
} else { } else {
dest.writeByte((byte)0); dest.writeByte((byte)0);
} }
@@ -111,9 +121,11 @@ public class ProxyProperties implements Parcelable {
ProxyProperties proxyProperties = new ProxyProperties(); ProxyProperties proxyProperties = new ProxyProperties();
if (in.readByte() == 1) { if (in.readByte() == 1) {
try { try {
InetAddress addr = InetAddress.getByAddress(in.createByteArray()); String host = in.readString();
proxyProperties.setSocketAddress(new InetSocketAddress(addr, in.readInt())); int port = in.readInt();
} catch (UnknownHostException e) { } proxyProperties.setSocketAddress(InetSocketAddress.createUnresolved(
host, port));
} catch (IllegalArgumentException e) { }
} }
proxyProperties.setExclusionList(in.readString()); proxyProperties.setExclusionList(in.readString());
return proxyProperties; return proxyProperties;