Merge "bug:3069735 in Download UI app, handle deletes correctly" into gingerbread
This commit is contained in:
@ -24649,6 +24649,17 @@
|
|||||||
visibility="public"
|
visibility="public"
|
||||||
>
|
>
|
||||||
</field>
|
</field>
|
||||||
|
<field name="COLUMN_MEDIAPROVIDER_URI"
|
||||||
|
type="java.lang.String"
|
||||||
|
transient="false"
|
||||||
|
volatile="false"
|
||||||
|
value=""mediaprovider_uri""
|
||||||
|
static="true"
|
||||||
|
final="true"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
</field>
|
||||||
<field name="COLUMN_MEDIA_TYPE"
|
<field name="COLUMN_MEDIA_TYPE"
|
||||||
type="java.lang.String"
|
type="java.lang.String"
|
||||||
transient="false"
|
transient="false"
|
||||||
|
@ -28,7 +28,6 @@ import android.os.Environment;
|
|||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.provider.BaseColumns;
|
import android.provider.BaseColumns;
|
||||||
import android.provider.Downloads;
|
import android.provider.Downloads;
|
||||||
import android.util.Log;
|
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -136,6 +135,12 @@ public class DownloadManager {
|
|||||||
*/
|
*/
|
||||||
public final static String COLUMN_LAST_MODIFIED_TIMESTAMP = "last_modified_timestamp";
|
public final static String COLUMN_LAST_MODIFIED_TIMESTAMP = "last_modified_timestamp";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The URI to the corresponding entry in MediaProvider for this downloaded entry. It is
|
||||||
|
* used to delete the entries from MediaProvider database when it is deleted from the
|
||||||
|
* downloaded list.
|
||||||
|
*/
|
||||||
|
public static final String COLUMN_MEDIAPROVIDER_URI = "mediaprovider_uri";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Value of {@link #COLUMN_STATUS} when the download is waiting to start.
|
* Value of {@link #COLUMN_STATUS} when the download is waiting to start.
|
||||||
@ -266,6 +271,7 @@ public class DownloadManager {
|
|||||||
// this array must contain all public columns
|
// this array must contain all public columns
|
||||||
private static final String[] COLUMNS = new String[] {
|
private static final String[] COLUMNS = new String[] {
|
||||||
COLUMN_ID,
|
COLUMN_ID,
|
||||||
|
COLUMN_MEDIAPROVIDER_URI,
|
||||||
COLUMN_TITLE,
|
COLUMN_TITLE,
|
||||||
COLUMN_DESCRIPTION,
|
COLUMN_DESCRIPTION,
|
||||||
COLUMN_URI,
|
COLUMN_URI,
|
||||||
@ -281,6 +287,7 @@ public class DownloadManager {
|
|||||||
// columns to request from DownloadProvider
|
// columns to request from DownloadProvider
|
||||||
private static final String[] UNDERLYING_COLUMNS = new String[] {
|
private static final String[] UNDERLYING_COLUMNS = new String[] {
|
||||||
Downloads.Impl._ID,
|
Downloads.Impl._ID,
|
||||||
|
Downloads.Impl.COLUMN_MEDIAPROVIDER_URI,
|
||||||
Downloads.COLUMN_TITLE,
|
Downloads.COLUMN_TITLE,
|
||||||
Downloads.COLUMN_DESCRIPTION,
|
Downloads.COLUMN_DESCRIPTION,
|
||||||
Downloads.COLUMN_URI,
|
Downloads.COLUMN_URI,
|
||||||
@ -677,6 +684,9 @@ public class DownloadManager {
|
|||||||
selectionParts.add(Downloads.Impl.COLUMN_IS_VISIBLE_IN_DOWNLOADS_UI + " != '0'");
|
selectionParts.add(Downloads.Impl.COLUMN_IS_VISIBLE_IN_DOWNLOADS_UI + " != '0'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// only return rows which are not marked 'deleted = 1'
|
||||||
|
selectionParts.add(Downloads.Impl.COLUMN_DELETED + " != '1'");
|
||||||
|
|
||||||
String selection = joinStrings(" AND ", selectionParts);
|
String selection = joinStrings(" AND ", selectionParts);
|
||||||
String orderDirection = (mOrderDirection == ORDER_ASCENDING ? "ASC" : "DESC");
|
String orderDirection = (mOrderDirection == ORDER_ASCENDING ? "ASC" : "DESC");
|
||||||
String orderBy = mOrderByColumn + " " + orderDirection;
|
String orderBy = mOrderByColumn + " " + orderDirection;
|
||||||
@ -742,6 +752,26 @@ public class DownloadManager {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marks the specified download as 'to be deleted'. This is done when a completed download
|
||||||
|
* is to be removed but the row was stored without enough info to delete the corresponding
|
||||||
|
* metadata from Mediaprovider database. Actual cleanup of this row is done in DownloadService.
|
||||||
|
*
|
||||||
|
* @param ids the IDs of the downloads to be marked 'deleted'
|
||||||
|
* @return the number of downloads actually updated
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public int markRowDeleted(long... ids) {
|
||||||
|
if (ids == null || ids.length == 0) {
|
||||||
|
// called with nothing to remove!
|
||||||
|
throw new IllegalArgumentException("input param 'ids' can't be null");
|
||||||
|
}
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put(Downloads.Impl.COLUMN_DELETED, 1);
|
||||||
|
return mResolver.update(mBaseUri, values, getWhereClauseForIds(ids),
|
||||||
|
getWhereArgsForIds(ids));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancel downloads and remove them from the download manager. Each download will be stopped if
|
* Cancel downloads and remove them from the download manager. Each download will be stopped if
|
||||||
* it was running, and it will no longer be accessible through the download manager. If a file
|
* it was running, and it will no longer be accessible through the download manager. If a file
|
||||||
@ -950,6 +980,9 @@ public class DownloadManager {
|
|||||||
if (column.equals(COLUMN_MEDIA_TYPE)) {
|
if (column.equals(COLUMN_MEDIA_TYPE)) {
|
||||||
return getUnderlyingString(Downloads.COLUMN_MIME_TYPE);
|
return getUnderlyingString(Downloads.COLUMN_MIME_TYPE);
|
||||||
}
|
}
|
||||||
|
if (column.equals(COLUMN_MEDIAPROVIDER_URI)) {
|
||||||
|
return getUnderlyingString(Downloads.Impl.COLUMN_MEDIAPROVIDER_URI);
|
||||||
|
}
|
||||||
|
|
||||||
assert column.equals(COLUMN_LOCAL_URI);
|
assert column.equals(COLUMN_LOCAL_URI);
|
||||||
return getLocalUri();
|
return getLocalUri();
|
||||||
|
@ -300,6 +300,15 @@ public final class Downloads {
|
|||||||
*/
|
*/
|
||||||
public static final String COLUMN_DESCRIPTION = "description";
|
public static final String COLUMN_DESCRIPTION = "description";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to true if this download is deleted. It is completely removed from the database
|
||||||
|
* when MediaProvider database also deletes the metadata asociated with this downloaded file.
|
||||||
|
* <P>Type: BOOLEAN</P>
|
||||||
|
* <P>Owner can Read</P>
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
public static final String COLUMN_DELETED = "deleted";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lists the destinations that an application can specify for a download.
|
* Lists the destinations that an application can specify for a download.
|
||||||
*/
|
*/
|
||||||
@ -881,6 +890,23 @@ public final class Downloads {
|
|||||||
public static final String COLUMN_BYPASS_RECOMMENDED_SIZE_LIMIT =
|
public static final String COLUMN_BYPASS_RECOMMENDED_SIZE_LIMIT =
|
||||||
"bypass_recommended_size_limit";
|
"bypass_recommended_size_limit";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to true if this download is deleted. It is completely removed from the database
|
||||||
|
* when MediaProvider database also deletes the metadata asociated with this downloaded file.
|
||||||
|
* <P>Type: BOOLEAN</P>
|
||||||
|
* <P>Owner can Read</P>
|
||||||
|
*/
|
||||||
|
public static final String COLUMN_DELETED = "deleted";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The URI to the corresponding entry in MediaProvider for this downloaded entry. It is
|
||||||
|
* used to delete the entries from MediaProvider database when it is deleted from the
|
||||||
|
* downloaded list.
|
||||||
|
* <P>Type: TEXT</P>
|
||||||
|
* <P>Owner can Read</P>
|
||||||
|
*/
|
||||||
|
public static final String COLUMN_MEDIAPROVIDER_URI = "mediaprovider_uri";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lists the destinations that an application can specify for a download.
|
* Lists the destinations that an application can specify for a download.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user