bug:3062216 (master) store correct status about network when paused
Vasu Nori [Sun, 23 Jan 2011 20:43:21 +0000 (12:43 -0800)]
bug:3062216
Change-Id: I4d510a9fc2095ec86991ae657e90d5f39bc55415

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

index 81e67a1..76a5c38 100644 (file)
@@ -213,7 +213,7 @@ public class DownloadThread extends Thread {
         addRequestHeaders(innerState, request);
 
         // check just before sending the request to avoid using an invalid connection at all
-        checkConnectivity(state);
+        checkConnectivity();
 
         HttpResponse response = sendRequest(state, client, request);
         handleExceptionalStatus(state, innerState, response);
@@ -230,7 +230,7 @@ public class DownloadThread extends Thread {
     /**
      * Check if current connectivity is valid for this request.
      */
-    private void checkConnectivity(State state) throws StopRequestException {
+    private void checkConnectivity() throws StopRequestException {
         int networkUsable = mInfo.checkCanUseNetwork();
         if (networkUsable != DownloadInfo.NETWORK_OK) {
             int status = Downloads.Impl.STATUS_WAITING_FOR_NETWORK;
@@ -548,7 +548,7 @@ public class DownloadThread extends Thread {
 
         updateDatabaseFromHeaders(state, innerState);
         // check connectivity again now that we know the total size
-        checkConnectivity(state);
+        checkConnectivity();
     }
 
     /**
@@ -763,8 +763,12 @@ public class DownloadThread extends Thread {
     }
 
     private int getFinalStatusForHttpError(State state) {
-        if (!Helpers.isNetworkAvailable(mSystemFacade)) {
-            return Downloads.Impl.STATUS_WAITING_FOR_NETWORK;
+        int networkUsable = mInfo.checkCanUseNetwork();
+        if (networkUsable != DownloadInfo.NETWORK_OK) {
+            return (networkUsable == DownloadInfo.NETWORK_UNUSABLE_DUE_TO_SIZE ||
+                    networkUsable == DownloadInfo.NETWORK_RECOMMENDED_UNUSABLE_DUE_TO_SIZE)
+                    ? Downloads.Impl.STATUS_QUEUED_FOR_WIFI
+                    : Downloads.Impl.STATUS_WAITING_FOR_NETWORK;
         } else if (mInfo.mNumFailed < Constants.MAX_RETRIES) {
             state.mCountRetry = true;
             return Downloads.Impl.STATUS_WAITING_TO_RETRY;