Try the next address after any type of connection failure.

Previously we'd fail IPv4 if IPv6 failed with a EHOSTUNREACH
error (which may be thrown as a SocketException or as a
NoRouteToHostException, depending on the platform).

Bug: http://b/5293809
Change-Id: Idca2e9bd561a23cff88b1399d45db65b96980148
diff --git a/src/org/apache/http/impl/conn/DefaultClientConnectionOperator.java b/src/org/apache/http/impl/conn/DefaultClientConnectionOperator.java
index fbc762d..d208853 100644
--- a/src/org/apache/http/impl/conn/DefaultClientConnectionOperator.java
+++ b/src/org/apache/http/impl/conn/DefaultClientConnectionOperator.java
@@ -36,6 +36,7 @@
 import java.net.Socket;
 import java.net.InetAddress;
 
+import java.net.SocketException;
 import org.apache.http.HttpHost;
 import org.apache.http.params.HttpParams;
 import org.apache.http.params.HttpConnectionParams;
@@ -173,10 +174,15 @@
                     conn.openCompleted(sf.isSecure(sock), params);
                 }
                 break;
-            } catch (ConnectException ex) {
+            // BEGIN android-changed
+            //       catch SocketException to cover any kind of connect failure
+            } catch (SocketException ex) {
                 if (i == addresses.length - 1) {
-                    throw new HttpHostConnectException(target, ex);
+                    ConnectException cause = ex instanceof ConnectException
+                            ? (ConnectException) ex : new ConnectException(ex.getMessage(), ex);
+                    throw new HttpHostConnectException(target, cause);
                 }
+            // END android-changed
             } catch (ConnectTimeoutException ex) {
                 if (i == addresses.length - 1) {
                     throw ex;
@@ -220,7 +226,7 @@
         }
 
         final LayeredSocketFactory lsf = (LayeredSocketFactory) schm.getSocketFactory();
-        final Socket sock; 
+        final Socket sock;
         try {
             sock = lsf.createSocket
                 (conn.getSocket(), target.getHostName(), schm.resolvePort(target.getPort()), true);