Some cleanup of Proxy class.

Switch to using InetSocketAddress.

Change-Id: Ibdb97fcd2d06eecaa1e847b78267180156089f27
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.Parcelable;
 
 import java.net.InetAddress;
+import java.net.InetSocketAddress;
 import java.net.UnknownHostException;
 
 /**
@@ -29,8 +30,7 @@
  */
 public class ProxyProperties implements Parcelable {
 
-    private InetAddress mProxy;
-    private int mPort;
+    private InetSocketAddress mProxy;
     private String mExclusionList;
 
     public ProxyProperties() {
@@ -39,8 +39,7 @@
     // 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 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 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 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 @@
                 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;
             }