am d2319d8d: Merge "New error status for "destination file already exists"." into gingerbread

Merge commit 'd2319d8d9a2d2bc5edc9d7d20b7100f4c72cb2e1' into gingerbread-plus-aosp

* commit 'd2319d8d9a2d2bc5edc9d7d20b7100f4c72cb2e1':
  New error status for "destination file already exists".
This commit is contained in:
Steve Howard
2010-09-20 15:43:43 -07:00
committed by Android Git Automerger
3 changed files with 30 additions and 10 deletions

View File

@@ -98013,6 +98013,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"

View File

@@ -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;
@@ -194,6 +193,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.
*/
@@ -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;
}

View File

@@ -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.