Update okhttp to a more recent commit.

Updating to upstream commit : 7b106923e078ac2435e8c8ce9d615f9903106ed8
/ 7th Mar 2014 / main branch.

The following changes were made to Android-only code:
1) HttpsHandler has been changed to deal with the fix for:
https://github.com/square/okhttp/issues/184 (commit 5d7fdba).
2) Platform.java changed to accomodate changes in okhttp Platform
method signatures.
3) .mk file updates to reflect src directory changes.

The following changes were made to OkHttp code:
1) Removal of org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
annotation from okio/src/main/java/okio/DeflaterSink.java

Change-Id: I644a883482ac7ee7d029785f110a2ca00762419b
diff --git a/android/main/java/com/squareup/okhttp/HttpHandler.java b/android/main/java/com/squareup/okhttp/HttpHandler.java
index c656c04..a7179bd 100644
--- a/android/main/java/com/squareup/okhttp/HttpHandler.java
+++ b/android/main/java/com/squareup/okhttp/HttpHandler.java
@@ -19,6 +19,7 @@
 
 import java.io.IOException;
 import java.net.Proxy;
+import java.net.ResponseCache;
 import java.net.URL;
 import java.net.URLConnection;
 import java.net.URLStreamHandler;
@@ -46,6 +47,11 @@
             client.setProxy(proxy);
         }
 
+        // Explicitly set the response cache.
+        ResponseCache responseCache = ResponseCache.getDefault();
+        if (responseCache != null) {
+          client.setResponseCache(responseCache);
+        }
         return client;
     }
 }
diff --git a/android/main/java/com/squareup/okhttp/HttpsHandler.java b/android/main/java/com/squareup/okhttp/HttpsHandler.java
index 421b7ff..191b7eb 100644
--- a/android/main/java/com/squareup/okhttp/HttpsHandler.java
+++ b/android/main/java/com/squareup/okhttp/HttpsHandler.java
@@ -17,11 +17,8 @@
 
 package com.squareup.okhttp;
 
-import java.io.IOException;
 import java.net.Proxy;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.URLStreamHandler;
+import java.net.ResponseCache;
 import java.util.Arrays;
 import java.util.List;
 
@@ -30,7 +27,7 @@
 import javax.net.ssl.HttpsURLConnection;
 
 public final class HttpsHandler extends HttpHandler {
-    private static final List<String> ENABLED_TRANSPORTS = Arrays.asList("http/1.1");
+    private static final List<Protocol> ENABLED_PROTOCOLS = Arrays.asList(Protocol.HTTP_11);
 
     @Override protected int getDefaultPort() {
         return 443;
@@ -39,7 +36,7 @@
     @Override
     protected OkHttpClient newOkHttpClient(Proxy proxy) {
         OkHttpClient client = super.newOkHttpClient(proxy);
-        client.setTransports(ENABLED_TRANSPORTS);
+        client.setProtocols(ENABLED_PROTOCOLS);
 
         HostnameVerifier verifier = HttpsURLConnection.getDefaultHostnameVerifier();
         // Assume that the internal verifier is better than the
@@ -47,6 +44,16 @@
         if (!(verifier instanceof DefaultHostnameVerifier)) {
             client.setHostnameVerifier(verifier);
         }
+        // OkHttp does not automatically honor the system-wide SSLSocketFactory set with
+        // HttpsURLConnection.setDefaultSSLSocketFactory().
+        // See https://github.com/square/okhttp/issues/184 for details.
+        client.setSslSocketFactory(HttpsURLConnection.getDefaultSSLSocketFactory());
+
+        // Explicitly set the response cache.
+        ResponseCache responseCache = ResponseCache.getDefault();
+        if (responseCache != null) {
+            client.setResponseCache(responseCache);
+        }
 
         return client;
     }
diff --git a/android/main/java/com/squareup/okhttp/internal/Platform.java b/android/main/java/com/squareup/okhttp/internal/Platform.java
index 0a95f07..e31bf75 100644
--- a/android/main/java/com/squareup/okhttp/internal/Platform.java
+++ b/android/main/java/com/squareup/okhttp/internal/Platform.java
@@ -20,16 +20,19 @@
 import java.io.IOException;
 import java.io.OutputStream;
 import java.net.InetSocketAddress;
-import java.net.NetworkInterface;
 import java.net.Socket;
 import java.net.SocketException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.util.List;
 import java.util.zip.Deflater;
 import java.util.zip.DeflaterOutputStream;
 import javax.net.ssl.SSLSocket;
+
 import com.android.org.conscrypt.OpenSSLSocketImpl;
+import com.squareup.okhttp.Protocol;
+import okio.ByteString;
 
 /**
  * Access to proprietary Android APIs. Doesn't use reflection.
@@ -37,12 +40,6 @@
 public final class Platform {
     private static final Platform PLATFORM = new Platform();
 
-    /*
-     * Default for the maximum transmission unit, used only if
-     * there's an error retrieving it via NetworkInterface.
-     */
-    private static final int DEFAULT_MTU = 1400;
-
     public static Platform get() {
         return PLATFORM;
     }
@@ -78,19 +75,31 @@
     /**
      * Returns the negotiated protocol, or null if no protocol was negotiated.
      */
-    public byte[] getNpnSelectedProtocol(SSLSocket socket) {
-        return socket instanceof OpenSSLSocketImpl
-                ? ((OpenSSLSocketImpl) socket).getNpnSelectedProtocol()
-                : null;
+    public ByteString getNpnSelectedProtocol(SSLSocket socket) {
+        if (!(socket instanceof OpenSSLSocketImpl)) {
+            return null;
+        }
+
+        OpenSSLSocketImpl socketImpl = (OpenSSLSocketImpl) socket;
+        // Prefer ALPN's result if it is present.
+        byte[] alpnResult = socketImpl.getAlpnSelectedProtocol();
+        if (alpnResult != null) {
+            return ByteString.of(alpnResult);
+        }
+        byte[] npnResult = socketImpl.getNpnSelectedProtocol();
+        return npnResult == null ? null : ByteString.of(npnResult);
     }
 
     /**
      * Sets client-supported protocols on a socket to send to a server. The
      * protocols are only sent if the socket implementation supports NPN.
      */
-    public void setNpnProtocols(SSLSocket socket, byte[] npnProtocols) {
+    public void setNpnProtocols(SSLSocket socket, List<Protocol> npnProtocols) {
         if (socket instanceof OpenSSLSocketImpl) {
-            ((OpenSSLSocketImpl) socket).setNpnProtocols(npnProtocols);
+            OpenSSLSocketImpl socketImpl = (OpenSSLSocketImpl) socket;
+            byte[] protocols = concatLengthPrefixed(npnProtocols);
+            socketImpl.setAlpnProtocols(protocols);
+            socketImpl.setNpnProtocols(protocols);
         }
     }
 
@@ -104,28 +113,6 @@
         return new DeflaterOutputStream(out, deflater, syncFlush);
     }
 
-    /**
-     * Returns the maximum transmission unit of the network interface used by
-     * {@code socket}, or a reasonable default if there's an error retrieving
-     * it from the socket.
-     *
-     * <p>The returned value should only be used as an optimization; such as to
-     * size buffers efficiently.
-     */
-    public int getMtu(Socket socket) {
-        try {
-            NetworkInterface networkInterface = NetworkInterface.getByInetAddress(
-                socket.getLocalAddress());
-            if (networkInterface != null) {
-                return networkInterface.getMTU();
-            }
-
-            return DEFAULT_MTU;
-        } catch (SocketException exception) {
-            return DEFAULT_MTU;
-        }
-    }
-
     public void connectSocket(Socket socket, InetSocketAddress address,
               int connectTimeout) throws IOException {
         socket.connect(address, connectTimeout);
@@ -135,4 +122,26 @@
     public String getPrefix() {
         return "X-Android";
     }
+
+    /**
+     * Concatenation of 8-bit, length prefixed protocol names.
+     *
+     * http://tools.ietf.org/html/draft-agl-tls-nextprotoneg-04#page-4
+     */
+    static byte[] concatLengthPrefixed(List<Protocol> protocols) {
+        int size = 0;
+        for (Protocol protocol : protocols) {
+            size += protocol.name.size() + 1; // add a byte for 8-bit length prefix.
+        }
+        byte[] result = new byte[size];
+        int pos = 0;
+        for (Protocol protocol : protocols) {
+            int nameSize = protocol.name.size();
+            result[pos++] = (byte) nameSize;
+            // toByteArray allocates an array, but this is only called on new connections.
+            System.arraycopy(protocol.name.toByteArray(), 0, result, pos, nameSize);
+            pos += nameSize;
+        }
+        return result;
+    }
 }