diff options
author | Irfan Sheriff <isheriff@google.com> | 2010-09-27 16:24:23 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-09-27 16:24:23 -0700 |
commit | 1beeab70a22c1d880b9aa7dfba09ef1d4203a37d (patch) | |
tree | e4ac9f99d4a94a3680819cd5221d733070d96dc5 | |
parent | 6442d92b10e9cbcfa0387486263f0f14b6c009d0 (diff) | |
parent | 798ffa12379d26d698f97b104e97a8309b059a62 (diff) | |
download | frameworks_base-1beeab70a22c1d880b9aa7dfba09ef1d4203a37d.zip frameworks_base-1beeab70a22c1d880b9aa7dfba09ef1d4203a37d.tar.gz frameworks_base-1beeab70a22c1d880b9aa7dfba09ef1d4203a37d.tar.bz2 |
Merge "use hostname when address null ProxyProperties parcelling"
-rw-r--r-- | core/java/android/net/ProxyProperties.java | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/core/java/android/net/ProxyProperties.java b/core/java/android/net/ProxyProperties.java index 140b71f..5fd0d89 100644 --- a/core/java/android/net/ProxyProperties.java +++ b/core/java/android/net/ProxyProperties.java @@ -88,13 +88,23 @@ public class ProxyProperties implements Parcelable { * @hide */ public void writeToParcel(Parcel dest, int flags) { + String host = null; if (mProxy != null) { - InetAddress addr = mProxy.getAddress(); - if (addr != null) { - dest.writeByte((byte)1); - dest.writeByteArray(addr.getAddress()); - dest.writeInt(mProxy.getPort()); - } + try { + InetAddress addr = mProxy.getAddress(); + if (addr != null) { + host = addr.getHostAddress(); + } 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 { dest.writeByte((byte)0); } @@ -111,9 +121,11 @@ public class ProxyProperties implements Parcelable { ProxyProperties proxyProperties = new ProxyProperties(); if (in.readByte() == 1) { try { - InetAddress addr = InetAddress.getByAddress(in.createByteArray()); - proxyProperties.setSocketAddress(new InetSocketAddress(addr, in.readInt())); - } catch (UnknownHostException e) { } + String host = in.readString(); + int port = in.readInt(); + proxyProperties.setSocketAddress(InetSocketAddress.createUnresolved( + host, port)); + } catch (IllegalArgumentException e) { } } proxyProperties.setExclusionList(in.readString()); return proxyProperties; |