summaryrefslogtreecommitdiffstats
path: root/src/com/android/providers/downloads/DownloadThread.java
Commit message (Collapse)AuthorAgeFilesLines
* Sanity check only after updating from file size.Jeff Sharkey2011-10-241-7/+7
| | | | | | | | Database values can be stale, so delay sanity check until after updating from file size on disk. Bug: 5484249 Change-Id: Ia648a575d4a3a391a1f06a866c8282f2d569f15e
* NPE check before finalizeDestinationFile().Jeff Sharkey2011-10-141-3/+5
| | | | | Bug: 5461417 Change-Id: I16f1e8594162b006b80bf7f2cdc6630d0dedfa38
* fix DownloadThread's use of ETag, range headersDoug Zongker2011-08-291-46/+54
| | | | | | | | | | | | | | | | | | DownloadThread was only maintaining ETag and the file size for the duration of one HTTP request, rather than over all the requests needed to fetch a file, which kind of defeats the point of having them. Fix this by moving several state variables from InnerState to State, and initializing the total bytes and current bytes values from the download database. Skip actually making the HTTP request if we've already downloaded all the bytes of the file. This works around bug 5217390 by making the second DownloadThread do nothing instead of trying to fetch past the end of the file. (A real fix would eliminate the race condition that causes the second thread to get created in the first place.) Bug: 5217390 Change-Id: Ib5b8f87398b4ed2cb3d7f09569e245b55a89da5a
* Migrate setThreadStatsTag() from String to int.Jeff Sharkey2011-06-251-1/+1
| | | | | Bug: 4948913 Change-Id: I831b9149208f0cc007cf3ebede3ef433b2636600
* Teach DownloadManager about network policy.Jeff Sharkey2011-06-171-19/+67
| | | | | | | | | | | Now network access is determined by using getActiveNetworkInfoForUid() which uses BLOCKED to indicate that network should be rejected for the requesting UID. While download in progress, watch for any policy changes that should trigger pause. Also check NetworkInfo.isConnected() for correctness. Change-Id: I1efa79823f15ecc3fa088a6719da1b770c64b255
* Merge "Download provider change for DRM Forward Lock plugin: to convert .dm ↵Gloria Wang2011-06-031-39/+30
|\ | | | | | | files to .fl files during downloading For bug 3188041"
| * Download provider change for DRM Forward Lock plugin:Gloria Wang2011-04-191-39/+30
| | | | | | | | | | | | | | to convert .dm files to .fl files during downloading For bug 3188041 Change-Id: I882b851664432fba3e57dc25a6be827b48006e69
* | Add Socket tagging for granular data accounting.Jeff Sharkey2011-05-131-5/+14
|/ | | | | | | | Tag active downloads, and account data usage towards UID that made the original request. Also release WakeLock only after we've cleaned up the download. Change-Id: I72d58c6a51beaeb357e59aae4d7c0f5ac9abaa8d
* am 32d9917c: am 7666801a: Merge "bug:4121206 handle STOPSHIP comments/code" ↵Vasu Nori2011-03-171-2/+0
|\ | | | | | | | | | | | | into honeycomb-mr1 * commit '32d9917cd4f56cabcbafa645c8cd89cd832ac523': bug:4121206 handle STOPSHIP comments/code
| * bug:4121206 handle STOPSHIP comments/codeVasu Nori2011-03-171-2/+0
| | | | | | | | Change-Id: I3c9f8e3b11dd301a0921d89e0333883489f37e55
* | (master) bug:3204324 allow no more than certain number of concurrent downloadsVasu Nori2011-03-101-6/+8
|/ | | | Change-Id: Ibbce0782fcf7649209d6f56be240209cebd9045b
* bug:3422868 collect additional info to debug this problemVasu Nori2011-02-101-1/+10
| | | | | | | this bug is not so easy to reproduce. so, this CL will produce some additional logging info for better insight Change-Id: I0d53c647f1b98a49eb93b937c8e7203723c33dbe
* bug:3435895 listen to media_mounted broadcast intentVasu Nori2011-02-081-0/+5
| | | | | | and retry downloads that failed due to the error "sdcard media not mounted" Change-Id: Id181b8167d331214f72679c85f18cc8b9b969e40
* am d47f3711: am 3ea897d9: Merge "bug:3396889 (HC branch) fix STOPSHIP code" ↵Vasu Nori2011-01-261-2/+1
|\ | | | | | | | | | | | | into honeycomb * commit 'd47f37112d4d0a95cd78e6ec3e14cbbb362b1595': bug:3396889 (HC branch) fix STOPSHIP code
| * bug:3396889 (HC branch) fix STOPSHIP codeVasu Nori2011-01-261-2/+1
| | | | | | | | Change-Id: I1eeb8c5a9936db08bc5997980dc6c7307691034e
* | bug:3062216 (master) store correct status about network when pausedVasu Nori2011-01-241-5/+9
|/ | | | | bug:3062216 Change-Id: I4d510a9fc2095ec86991ae657e90d5f39bc55415
* manual merge of GB change Change-Id: I1acf2fb9491d24f5e109206a91dda3eea429e447Vasu Nori2011-01-161-6/+5
| | | | Change-Id: Ibaf889d78fc99a32038a77671036fc6a5068580f
* bug:3338089 NPE in downloadthreadVasu Nori2011-01-111-2/+8
| | | | Change-Id: I95b4c52598092e9f6ffa1713b36ac11d44e26279
* bug:3338089 print better error msg in DownloadThread when exception occursVasu Nori2011-01-101-4/+1
| | | | | | | when download thread gets an exception and aborts a download, print the stacktrace of the exception - so one can debug the problem. Change-Id: Iab1bae3b6180d8601e84020453ff35815ae3e69f
* Revert "Merge "downloadmanager should use "files" dir - not "cache" dir to ↵Vasu Nori2011-01-071-2/+2
| | | | | | | store its files" into honeycomb" This reverts commit 7d96bafa59111d9ca735e5ef86dc0598f946b2be, reversing changes made to 2ce876d2d7000b0c3a1430c5f4932568090f5170.
* downloadmanager should use "files" dir - not "cache" dir to store its filesVasu Nori2011-01-071-2/+2
| | | | | | | | | | | | | data/data/com.android.providers.downlaods/cache is being used to store the downloaded files, when the user doesn't specify the destination path. but system seems to remove files from this dir EVEN when space is running low. bug:3324673 instead, let DownloadManager use data/data/com.android.providers.downlaods/files dir Downlaodmanager manages its space anyway. Change-Id: I2eb15570395a214477891f50f635fada0b466544
* bug:3286430 set quota on downloads data dirVasu Nori2010-12-231-103/+99
| | | | | | | | | | make sure the doanloads data dir size is limited by some quote - 100MB default and 200MB for SR. bug:3286430 tests are in Change-Id: I688f7e058511089bec7fa21e972e23780604d98a Change-Id: Iba7fab9fa91ea018f35e1c3ef5ec0e6b03cba650
* Download dir: /data/data/com.android.providers.downloads/cache NOT /cacheVasu Nori2010-12-141-3/+5
| | | | | | | | | | bug:3264401 still to do: make sure only N bytes are taken up by downloads dir N = a value specific to each device. default = 100MB. Change-Id: I2a49f4b3831d3a8d7be13b5fd46d85d56e831e38
* manually merging Change-Id: If7dc0f86ea7a3c4394603416ca0fc33847f10fa7Vasu Nori2010-12-031-1/+1
| | | | | | need this CL from GB. without it, downloads are badly broken in master. Change-Id: I82ebc467f877bed50e373c437481ad19e14635bf
* am 084c3dc3: am 26f86843: Merge "(GB MR) bug:3144642 temporary small fix in ↵Vasu Nori2010-12-021-1/+1
|\ | | | | | | | | | | | | GB MR and real fix in HC" into gingerbread * commit '084c3dc34ed9e6ae9ddc471819de0d6d55021dfd': (GB MR) bug:3144642 temporary small fix in GB MR and real fix in HC
| * am 26f86843: Merge "(GB MR) bug:3144642 temporary small fix in GB MR and ↵Vasu Nori2010-12-021-1/+2
| |\ | | | | | | | | | | | | | | | | | | real fix in HC" into gingerbread * commit '26f86843f48b3d7878837a1a9f93865b3eba0aee': (GB MR) bug:3144642 temporary small fix in GB MR and real fix in HC
| | * (GB MR) bug:3144642 temporary small fix in GB MR and real fix in HCVasu Nori2010-12-021-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Real fix is in Change-Id: Ifea1544737023008eff44aef9acd976902a0c143 In the database, sometimes _data column in downloads is set to null and sometimes to empty string. this is inconsistent and causes bugs such as bug:3144642. This bug is caused by line# 793 in DownloadThread. state.mFileName is null sometimes and empty string sometimes - because the correspodning field is set inconsistentlt in downloads.db _data column. in GB MR, apply a bandaid because real fix could be too risky for GB. Change-Id: I115b3ba6cfe0262269dbbc4c336b9e1d63c618e4
* | | when a download fails, store the error msg in dbVasu Nori2010-11-111-8/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | useful for debugging for bugs like bug:3187299 without this error message, one doesn't know WHY downloads fail. to prevent PII info in database, there is a STOPSHIP comment around storage of this error message in database. Change-Id: I612e383aef8483b68b772f70dff722a5daea2ef5
* | | remove usage of hidden public constants.Vasu Nori2010-10-201-1/+0
|/ / | | | | | | Change-Id: I2edf1bef5e741de8193cb293807e3ace42003b0c
* | am d4dc8501: Merge "Seriously improve error reporting in DownloadThread." ↵Steve Howard2010-10-011-111/+84
|\| | | | | | | | | | | | | | | | | into gingerbread Merge commit 'd4dc8501ecb89b91f865510207297dd960afe031' into gingerbread-plus-aosp * commit 'd4dc8501ecb89b91f865510207297dd960afe031': Seriously improve error reporting in DownloadThread.
| * Seriously improve error reporting in DownloadThread.Steve Howard2010-09-301-111/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | My old error reporting strategy for DownloadThread was to log the stack trace for the exception, so we'd know exactly what conditions caused the StopRequest. hackbod suggested that we shouldn't log tracebacks as they clutter the log. Instead, we should just always include a little string tag explaining why the request is being stopped -- this is more concise and more useful to developers. There are three main changes here to acheive this goal: * make StopRequest require a short, log-friendly error message upon construction, and add such a message to all construction sites * make a similar change to GenerateSaveFileError, so that the variety of errors that originate with Helpers.generateSaveFile() get similarly fine-grained and concise error reporting * make network usable checking code return a distinct error code for each distinct negative condition, and add a utility to return a log-friendly error message for each such code. Finally, I cleaned up some of the ways errors/exceptions are handled in the process. Change-Id: Ie70cbf3f2960e260e97f8449258e25218d0f900f
* | resolved conflicts for merge of b108a273 to gingerbread-plus-aospSteve Howard2010-09-301-17/+24
|\| | | | | | | Change-Id: Iced3a5360702fdeb299f8b987a353d3aeca7629b
| * Improve how the download manager reports paused statuses.Steve Howard2010-09-291-17/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change makes the download manager report more detail when a download is paused. Rather than always reporting status RUNNING_PAUSED, there are now four different statuses: * paused by the app * waiting to retry after a network error * waiting for network connectivity * queued for wifi due to size limits This allows a few improvements: * code deciding when to run a download can be improved and cleaned up (I've taken some extra steps in cleaning up this particular code) * notification code no longer has to rely on the in-memory-only "mPausedReason" member of DownloadInfo; instead, it knows from the status that the download is queued for wifi, and can display the appropriate string. This moves the string fetching out into the UI-specific logic and is a sign that this is really the right way to do things. And finally, the real motivation for this change: I've changed the meaning of "Queued" in the downloads UI so it now means "Queued for WiFi'. This is what was originally intended, I'd misunderstood. What was formerly known as "Queued", a download that hadn't started, is now displayed as "In progress" (it's always a transient state so it's basically meaningless anyway). Otherwise it remains the same (in particular, downloads paused for other reasons are still reported as "In progress"). I've also increased some of the logging in DownloadThread a bit, as this change initally introduced some bugs that were impossible to track down without that logging. There have been other bug reports that were impossible to diagnose and these few extra log statements should really help, without cluttering logs too much. I've taken care to avoid potentially introducing any PII into the logs. Change-Id: Id0b8d65fc8e4406ad7ffa1439ffc22a0281b051f
* | am ebb555c0: Support multi-valued HTTP headers, handle new API changesSteve Howard2010-09-231-3/+3
|\| | | | | | | | | | | | | Merge commit 'ebb555c0687061993dd6a22d15f6aab2437ee8c5' into gingerbread-plus-aosp * commit 'ebb555c0687061993dd6a22d15f6aab2437ee8c5': Support multi-valued HTTP headers, handle new API changes
| * Support multi-valued HTTP headers, handle new API changesSteve Howard2010-09-221-3/+3
| | | | | | | | | | | | | | | | | | * backend support for multiple values for the same HTTP headers, for corresponding API changes * other minor changes in response to DownloadManager API changes Change-Id: I7c595e94a60ed7afaca6cc3fb4c05aaeeff20c2a
* | am d3197296: Implement dialogs for wifi required + recommended limits.Steve Howard2010-09-211-1/+7
|\| | | | | | | | | | | | | Merge commit 'd319729622da1893e895f2e35f41d01ecdca3705' into gingerbread-plus-aosp * commit 'd319729622da1893e895f2e35f41d01ecdca3705': Implement dialogs for wifi required + recommended limits.
| * Implement dialogs for wifi required + recommended limits.Steve Howard2010-09-211-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change extends the original work to add a size limit over which wifi is required to download a file. First, this change adds a second size limit, over which wifi is recommended but not required. The user has the option to bypass this limit. Second, this change implements dialogs shown to the user when either limit is exceeded. These dialogs are shown by the background download manager service when a download is started and found to be over the limit (and wifi is not connected). I'm including one small fix to the unit tests needed from the previous change. Change-Id: Ia0f0acaa7b0d00e98355925c3446c0472048df10
* | am dc738781: Merge "Improve file error reporting + new detailed error ↵Steve Howard2010-09-201-3/+12
|\| | | | | | | | | | | | | | | | | messages in UI" into gingerbread Merge commit 'dc738781156d0f5ac1db62838d42c876d740810d' into gingerbread-plus-aosp * commit 'dc738781156d0f5ac1db62838d42c876d740810d': Improve file error reporting + new detailed error messages in UI
| * Improve file error reporting + new detailed error messages in UISteve Howard2010-09-201-3/+12
| | | | | | | | | | | | | | | | | | | | | | * support new error code for "destination file already exists" * improve error handling for various file error cases to return a more specific error code when appropriate * make UI support more detailed error messages for some cases * use Uri.getPath() instead of Uri.getSchemeSpecificPart() for file URIs Change-Id: Icb01d4d3b47c7776be3ddcd8347212e950cd023e
* | resolved conflicts for merge of 3d55d829 to gingerbread-plus-aospSteve Howard2010-09-161-20/+6
|\| | | | | | | Change-Id: I18ede2f2d5ad8aa40cd61bdb7213659d356fdf57
| * New URI structure with "my_downloads" and "all_downloads"Steve Howard2010-09-141-21/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change introduces a second view into the download manager database via a set of URIs starting with /all_downloads, renaming the original /download URIs to /my_downloads. In addition to making things more clear, this change allows the downloads UI to grant permissions on individual downloads to viewer apps. The old semantics were: * for ordinary callers, /download included only downloads initiated by the calling UID * for intraprocess calls or calls by root, /download included all downloads The new semantics are * /my_downloads always includes only downloads initiated by the calling UID, and requires only INTERNET permission. It could just as well require no permission, but that's not possible in the framework, since path-permissions can only broaden access, not tighten it. It doesn't matter, because these URIs are useless without INTERNET permission -- if a user can't initiate downloads, there's no reason to read this. * /all_downloads always includes all downloads on the system, and requires the new permission ACCESS_ALL_DOWNLOADS. This permission is currently protectionLevel=signature -- this could be relaxed later to support third-party download managers. All download manager code has been changed to use /all_downloads URIs, except when passing a URI to another app. In making this change across the download manager code, I've taken some liberties in cleaning things up. Other apps are unchanged and will use /my_downloads. Finally, this incorporates changes to DownloadManager to return a content URI for /cache downloads -- the download UI no longer assumes it's a file URI, and it grants permissions to the receiver of the VIEW intent. The public API test has also been updated. I've also fixed some null cursor checking in DownloadManager. Change-Id: I05a501eb4388249fe80c43724405657c950d7238
* | am 97d590d5: Add UI message when queued for wifi due to size.Steve Howard2010-08-201-0/+1
|\| | | | | | | | | | | | | Merge commit '97d590d5a1f583acb7992d20851bdc6cd0454d12' into gingerbread-plus-aosp * commit '97d590d5a1f583acb7992d20851bdc6cd0454d12': Add UI message when queued for wifi due to size.
| * Add UI message when queued for wifi due to size.Steve Howard2010-08-201-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As it stands, when a download is paused because it's too big to proceed over mobile, and must proceed over wifi, it looks like any other paused download, with no indication of why it's paused. That may be passable for most other reasons for pausing a download, but it seems too confusing for this case. So this change adds a simple string message that replaces the progress bar when a download is paused for this reason (the icon also changes to a warning). The implementation isn't beautiful and could use some improvement, but I think it's acceptable and necessary. The exact UI design and wording are certainly open to change. Change-Id: I753d57f463e2614b5694bdc178d2a51066da8ca3
* | am adb6887d: Clean up error codes returned by download manager.Steve Howard2010-08-171-87/+84
|\| | | | | | | | | | | | | Merge commit 'adb6887d3270d180c94eaf90878d5b67d74a8f28' into gingerbread-plus-aosp * commit 'adb6887d3270d180c94eaf90878d5b67d74a8f28': Clean up error codes returned by download manager.
| * Clean up error codes returned by download manager.Steve Howard2010-08-161-87/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This set of changes cleans up the error codes returned by the download manager in various failure cases, aiming for improved consistency. Error codes are part of the public API so it's important to get this right now. The main changes here are: * Refactoring the flow of error status information throughout DownloadThread to make it more explicit, by having StopRequest accept a status code in its constructor and eliminating State.mFinaStatus. * Eliminating the use of valid HTTP 4xx statuses when those statuses weren't actually returned by the server. Now, if the returned error code is a valid HTTP status code, that means it was returned by the server. These cases have been replaced with more sensible artificial error codes, including a new ERROR_CANNOT_RESUME when an interrupted download can't be resumed. * Improvements to some of the error handling code paths -- ensuring we don't clear the cache for external downloads, ensuring we don't fail with CANNOT_RESUME when the download hasn't actually started yet, removing the restriction on acceptable mime types for public API downloads. Change-Id: I0d825845fe0fe7ed5df74bad26e8d34ac0d1cc4e
* | am dea0a5f8: Add test for many interruptions to a single download.Steve Howard2010-07-301-80/+46
|\| | | | | | | | | | | | | Merge commit 'dea0a5f8e5804d3aba40eaa7de763dd88058384e' into gingerbread-plus-aosp * commit 'dea0a5f8e5804d3aba40eaa7de763dd88058384e': Add test for many interruptions to a single download.
| * Add test for many interruptions to a single download.Steve Howard2010-07-271-80/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adding a new test case for downloads that undergo many interruptions (as may happen with a very large download that takes many hours). Includes some refactoring in the test suite. Early on, this test exposed a race condition in which the download manager got some I/O exception while reading from the MockWebServer. I went in and improved/refactored much of the error logging code in DownloadThread to try and track this down. Unfortunately, once I finished, the race condition no longer seems to be reproducible, even with hundreds of runs of the test case. So I've given up on it for now. In any event, error logging is better and much duplicate code has been eliminated.
* | resolved conflicts for merge of f85aa9ef to gingerbread-plus-aospSteve Howard2010-07-301-65/+94
|\| | | | | | | Change-Id: I0adb03f16a6f0cc648886e02c79ffde63e18f99f
| * Improved support for 302/307 redirects.Steve Howard2010-07-271-61/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change the download manager's handling of 302/307 temporary redirects so that after an interruption of any kind, the delayed retry/resume will return to the original URI. This complies better with the HTTP spec. This change also makes the download manager handle other redirects immediately rather than using the delay that's otherwise applied to download errors. I made one more method extraction in DownloadThread to simplify this change, pulling the top-level logic for a single request into executeDownload(). It was then just a matter of introducing a new RetryDownload exeception, similar to StopRequest, and making the redirection code use it. Change-Id: Ic719c5725a9fd2e5eebe4dc03453ee71d9f27cd4
* | am f6b4c24b: Fix bug with closing output stream for external downloads.Steve Howard2010-07-271-0/+1
|\| | | | | | | | | | | | | Merge commit 'f6b4c24b4a876daa3f4e91d6da418983222b9dfd' into gingerbread-plus-aosp * commit 'f6b4c24b4a876daa3f4e91d6da418983222b9dfd': Fix bug with closing output stream for external downloads.