diff options
author | Steve Howard <showard@google.com> | 2010-09-20 15:40:41 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-09-20 15:40:41 -0700 |
commit | d2319d8d9a2d2bc5edc9d7d20b7100f4c72cb2e1 (patch) | |
tree | f8952d0543cef0e0ffbda8ac0e888a6c328465c5 | |
parent | ee2ef3220fd27a6332acb2f65951a7fe91e9dfa6 (diff) | |
parent | a9e87c9cc375b8be43a05ad641545db26eee0d46 (diff) | |
download | frameworks_base-d2319d8d9a2d2bc5edc9d7d20b7100f4c72cb2e1.zip frameworks_base-d2319d8d9a2d2bc5edc9d7d20b7100f4c72cb2e1.tar.gz frameworks_base-d2319d8d9a2d2bc5edc9d7d20b7100f4c72cb2e1.tar.bz2 |
Merge "New error status for "destination file already exists"." into gingerbread
-rw-r--r-- | api/current.xml | 11 | ||||
-rw-r--r-- | core/java/android/net/DownloadManager.java | 22 | ||||
-rw-r--r-- | core/java/android/provider/Downloads.java | 7 |
3 files changed, 30 insertions, 10 deletions
diff --git a/api/current.xml b/api/current.xml index 8651c4d..af91389 100644 --- a/api/current.xml +++ b/api/current.xml @@ -96356,6 +96356,17 @@ visibility="public" > </field> +<field name="ERROR_FILE_ALREADY_EXISTS" + type="int" + transient="false" + volatile="false" + value="1009" + static="true" + final="true" + deprecated="not deprecated" + visibility="public" +> +</field> <field name="ERROR_FILE_ERROR" type="int" transient="false" diff --git a/core/java/android/net/DownloadManager.java b/core/java/android/net/DownloadManager.java index 5320da3..8bb747e 100644 --- a/core/java/android/net/DownloadManager.java +++ b/core/java/android/net/DownloadManager.java @@ -25,7 +25,6 @@ import android.os.ParcelFileDescriptor; import android.provider.BaseColumns; import android.provider.Downloads; -import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Arrays; @@ -195,6 +194,12 @@ public class DownloadManager { public final static int ERROR_CANNOT_RESUME = 1008; /** + * Value of {@link #COLUMN_ERROR_CODE} when the requested destination file already exists (the + * download manager will not overwrite an existing file). + */ + public final static int ERROR_FILE_ALREADY_EXISTS = 1009; + + /** * Broadcast intent action sent by the download manager when a download completes. */ public final static String ACTION_DOWNLOAD_COMPLETE = "android.intent.action.DOWNLOAD_COMPLETE"; @@ -235,10 +240,11 @@ public class DownloadManager { Downloads.COLUMN_URI, Downloads.COLUMN_MIME_TYPE, Downloads.COLUMN_TOTAL_BYTES, - Downloads._DATA, Downloads.COLUMN_STATUS, Downloads.COLUMN_CURRENT_BYTES, Downloads.COLUMN_LAST_MODIFICATION, + Downloads.COLUMN_DESTINATION, + Downloads.Impl.COLUMN_FILE_NAME_HINT, }; private static final Set<String> LONG_COLUMNS = new HashSet<String>( @@ -820,15 +826,10 @@ public class DownloadManager { } private String getLocalUri() { - String localUri = getUnderlyingString(Downloads.Impl._DATA); - if (localUri == null) { - return null; - } - long destinationType = getUnderlyingLong(Downloads.Impl.COLUMN_DESTINATION); if (destinationType == Downloads.Impl.DESTINATION_FILE_URI) { - // return file URI for external download - return Uri.fromFile(new File(localUri)).toString(); + // return client-provided file URI for external download + return getUnderlyingString(Downloads.Impl.COLUMN_FILE_NAME_HINT); } // return content URI for cache download @@ -894,6 +895,9 @@ public class DownloadManager { case Downloads.Impl.STATUS_CANNOT_RESUME: return ERROR_CANNOT_RESUME; + case Downloads.Impl.STATUS_FILE_ALREADY_EXISTS_ERROR: + return ERROR_FILE_ALREADY_EXISTS; + default: return ERROR_UNKNOWN; } diff --git a/core/java/android/provider/Downloads.java b/core/java/android/provider/Downloads.java index 74c7372..871a044 100644 --- a/core/java/android/provider/Downloads.java +++ b/core/java/android/provider/Downloads.java @@ -1077,7 +1077,12 @@ public final class Downloads { /** * The lowest-valued error status that is not an actual HTTP status code. */ - public static final int MIN_ARTIFICIAL_ERROR_STATUS = 489; + public static final int MIN_ARTIFICIAL_ERROR_STATUS = 488; + + /** + * The requested destination file already exists. + */ + public static final int STATUS_FILE_ALREADY_EXISTS_ERROR = 488; /** * Some possibly transient error occurred, but we can't resume the download. |