summaryrefslogtreecommitdiffstats
path: root/src/com/android/providers/downloads/Helpers.java
diff options
context:
space:
mode:
authorSteve Howard <showard@google.com>2010-07-30 18:55:38 -0700
committerSteve Howard <showard@google.com>2010-08-16 14:29:33 -0700
commitadb6887d3270d180c94eaf90878d5b67d74a8f28 (patch)
tree8d0af2656dbf21cbb5b25a19d25e2c86f743e33a /src/com/android/providers/downloads/Helpers.java
parente61798da80558450f580ed948d0d469bd6423d8e (diff)
downloadandroid_packages_providers_DownloadProvider-adb6887d3270d180c94eaf90878d5b67d74a8f28.tar.gz
android_packages_providers_DownloadProvider-adb6887d3270d180c94eaf90878d5b67d74a8f28.tar.bz2
android_packages_providers_DownloadProvider-adb6887d3270d180c94eaf90878d5b67d74a8f28.zip
Clean up error codes returned by download manager.
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
Diffstat (limited to 'src/com/android/providers/downloads/Helpers.java')
-rw-r--r--src/com/android/providers/downloads/Helpers.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/com/android/providers/downloads/Helpers.java b/src/com/android/providers/downloads/Helpers.java
index f2988954..5d546ff6 100644
--- a/src/com/android/providers/downloads/Helpers.java
+++ b/src/com/android/providers/downloads/Helpers.java
@@ -94,9 +94,10 @@ public class Helpers {
String contentLocation,
String mimeType,
int destination,
- long contentLength) throws FileNotFoundException {
+ long contentLength,
+ boolean isPublicApi) throws FileNotFoundException {
- if (!canHandleDownload(context, mimeType, destination)) {
+ if (!canHandleDownload(context, mimeType, destination, isPublicApi)) {
return new DownloadFileInfo(null, null, Downloads.Impl.STATUS_NOT_ACCEPTABLE);
}
@@ -156,7 +157,12 @@ public class Helpers {
return chooseUniqueFilename(destination, filename, extension, recoveryDir);
}
- private static boolean canHandleDownload(Context context, String mimeType, int destination) {
+ private static boolean canHandleDownload(Context context, String mimeType, int destination,
+ boolean isPublicApi) {
+ if (isPublicApi) {
+ return true;
+ }
+
if (destination == Downloads.Impl.DESTINATION_EXTERNAL
|| destination == Downloads.Impl.DESTINATION_CACHE_PARTITION_PURGEABLE) {
if (mimeType == null) {