OkHttp quick fix: canceled StreamAllocations can never recover

When a HttpURLConnection is disconnected in the middle of connecting,
this can lead to an infinite loop because:
 - StreamAllocation.findConnection() immediately throws
   (before advancing the RouteSelector)
 - StreamAllocation.recover() returns true, indicating that a
   retry is permissible
 - higher level logic then retries the connection indefinitely in
   a busy loop

This bug does not occur in the latest version of OkHttp (3.5) but
can be reproduced directly on top of OkHttp 2.7.5.

To give us more time to figure out the best fix, this CL makes the
narrowest possible fix for the concrete behavior observed in the wild.

There are related cases where StreamAllocation.recover() returns true
but findConnection() immediately throws; these have not been observed
and are not addressed by this CL:
 - StreamAllocation.released; this case looks at first glance like it
   is not reachable via publicly exposed API (HttpURLConnection)
 - canceled case for recover(IOException e, Sink requestBodyOut):
   touching this breaks OkHttp's
   CallTest.canceledBeforeIOSignalsOnFailure*() because the reported
   error message becomes something like "Socket closed", rather
   than reviewed "Canceled".

Test: CtsLibcoreTestCases
Test: CtsLibcoreOkHttpTestCases

Bug: 33763156

Change-Id: Ie8e80559f9364cbd0a01c54b441fc10402b37862
(cherry picked from commit 715f88092afc34bbe129118fa9ed737ad38ec050)
diff --git a/okhttp/src/main/java/com/squareup/okhttp/internal/http/StreamAllocation.java b/okhttp/src/main/java/com/squareup/okhttp/internal/http/StreamAllocation.java
index 7d95338..fd3f03f 100644
--- a/okhttp/src/main/java/com/squareup/okhttp/internal/http/StreamAllocation.java
+++ b/okhttp/src/main/java/com/squareup/okhttp/internal/http/StreamAllocation.java
@@ -314,6 +314,10 @@
   }
 
   public boolean recover(RouteException e) {
+    // Android-changed: Canceled StreamAllocations can never recover http://b/33763156
+    if (canceled) {
+      return false;
+    }
     if (connection != null) {
       connectionFailed(e.getLastConnectException());
     }