Fixing rare crashes in the login page
[pub/Android/ownCloud.git] / src / com / owncloud / android / authenticator / EasySSLSocketFactory.java
index 0a3f8be..1bb1aa6 100644 (file)
@@ -115,6 +115,7 @@ public class EasySSLSocketFactory implements ProtocolSocketFactory {
     }
 
     private static SSLContext createEasySSLContext() {
+        Log.d(TAG, "Creating Easy SSL Context");
         try {
             SSLContext context = SSLContext.getInstance("TLS");
             context.init(null, new TrustManager[] { new EasyX509TrustManager(
@@ -127,6 +128,7 @@ public class EasySSLSocketFactory implements ProtocolSocketFactory {
     }
 
     private SSLContext getSSLContext() {
+        Log.d(TAG, "Getting Easy SSL Context");
         if (this.sslcontext == null) {
             this.sslcontext = createEasySSLContext();
         }
@@ -138,6 +140,7 @@ public class EasySSLSocketFactory implements ProtocolSocketFactory {
      */
     public Socket createSocket(String host, int port, InetAddress clientHost,
             int clientPort) throws IOException, UnknownHostException {
+        Log.d(TAG, "Creating SSL Socket with remote " + host + ":" + port + ", client " + clientHost + ":" + clientPort);
 
         return getSSLContext().getSocketFactory().createSocket(host, port,
                 clientHost, clientPort);
@@ -170,26 +173,29 @@ public class EasySSLSocketFactory implements ProtocolSocketFactory {
             final InetAddress localAddress, final int localPort,
             final HttpConnectionParams params) throws IOException,
             UnknownHostException, ConnectTimeoutException {
+        Log.d(TAG, "Creating SSL Socket with remote " + host + ":" + port + ", local " + localAddress + ":" + localPort + ", params: " + params);
         if (params == null) {
             throw new IllegalArgumentException("Parameters may not be null");
         }
         int timeout = params.getConnectionTimeout();
         SocketFactory socketfactory = getSSLContext().getSocketFactory();
-        if (timeout == 0) {
+        /*if (timeout == 0) {
+            Log.d(TAG, " ... with connection timeout 0 and socket timeout " + params.getSoTimeout());
             Socket socket = socketfactory.createSocket(host, port, localAddress,
                     localPort);
             socket.setSoTimeout(params.getSoTimeout());
             return socket;
-        } else {
-            Socket socket = socketfactory.createSocket();
-            SocketAddress localaddr = new InetSocketAddress(localAddress,
-                    localPort);
-            SocketAddress remoteaddr = new InetSocketAddress(host, port);
-            socket.setSoTimeout(params.getSoTimeout());
-            socket.bind(localaddr);
-            socket.connect(remoteaddr, timeout);
-            return socket;
-        }
+        } else {*/
+        Log.d(TAG, " ... with connection timeout " + timeout + " and socket timeout " + params.getSoTimeout());
+        Socket socket = socketfactory.createSocket();
+        SocketAddress localaddr = new InetSocketAddress(localAddress,
+                localPort);
+        SocketAddress remoteaddr = new InetSocketAddress(host, port);
+        socket.setSoTimeout(params.getSoTimeout());
+        socket.bind(localaddr);
+        socket.connect(remoteaddr, timeout);
+        return socket;
+        //}
     }
 
     /**
@@ -197,6 +203,7 @@ public class EasySSLSocketFactory implements ProtocolSocketFactory {
      */
     public Socket createSocket(String host, int port) throws IOException,
             UnknownHostException {
+        Log.d(TAG, "Creating SSL Socket with remote " + host + ":" + port);
         return getSSLContext().getSocketFactory().createSocket(host, port);
     }
 
@@ -205,6 +212,7 @@ public class EasySSLSocketFactory implements ProtocolSocketFactory {
      */
     public Socket createSocket(Socket socket, String host, int port,
             boolean autoClose) throws IOException, UnknownHostException {
+        Log.d(TAG, "Creating SSL Socket from other shocket " + socket + " to remote " + host + ":" + port);
         return getSSLContext().getSocketFactory().createSocket(socket, host,
                 port, autoClose);
     }