resolved conflicts for merge of f85aa9ef to gingerbread-plus-aosp
Steve Howard [Fri, 30 Jul 2010 18:39:28 +0000 (11:39 -0700)]
Change-Id: I0adb03f16a6f0cc648886e02c79ffde63e18f99f

1  2 
src/com/android/providers/downloads/DownloadThread.java

@@@ -142,32 -143,23 +146,27 @@@ public class DownloadThread extends Thr
              if (Constants.LOGV) {
                  Log.v(Constants.TAG, "initiating download for " + mInfo.mUri);
              }
-             setupDestinationFile(state, innerState);
-             client = AndroidHttpClient.newInstance(userAgent(), mContext);
-             // Set or unset proxy, which may have changed since last GET request.
-             // setDefaultProxy() supports null as proxy parameter.
-             ConnRouteParams.setDefaultProxy(client.getParams(),
-                     Proxy.getPreferredHttpHost(mContext, mInfo.mUri));
-             request = new HttpGet(mInfo.mUri);
-             addRequestHeaders(innerState, request);
-             // check connectivity just before sending
-             if (!mInfo.canUseNetwork()) {
-                 state.mFinalStatus = Downloads.Impl.STATUS_RUNNING_PAUSED;
-                 return;
-             }
  
-             HttpResponse response = sendRequest(state, client, request);
-             handleExceptionalStatus(state, innerState, response);
+             client = AndroidHttpClient.newInstance(userAgent(), mContext);
  
-             if (Constants.LOGV) {
-                 Log.v(Constants.TAG, "received response for " + mInfo.mUri);
+             boolean finished = false;
+             while(!finished) {
++                // Set or unset proxy, which may have changed since last GET request.
++                // setDefaultProxy() supports null as proxy parameter.
++                ConnRouteParams.setDefaultProxy(client.getParams(),
++                        Proxy.getPreferredHttpHost(mContext, state.mRequestUri));
+                 HttpGet request = new HttpGet(state.mRequestUri);
+                 try {
+                     executeDownload(state, client, request);
+                     finished = true;
+                 } catch (RetryDownload exc) {
+                     // fall through
+                 } finally {
+                     request.abort();
+                     request = null;
+                 }
              }
  
-             processResponseHeaders(state, innerState, response);
-             InputStream entityStream = openResponseEntity(state, response);
-             transferData(state, innerState, data, entityStream);
              if (Constants.LOGV) {
                  Log.v(Constants.TAG, "download completed for " + mInfo.mUri);
              }