am b8f7a483
: Merge "bug:3082865 don\'t use IN to construct sql to delete downloads" into gingerbread
Merge commit 'b8f7a4831ac26d0447fd8a2982416b2627a286b5' into gingerbread-plus-aosp * commit 'b8f7a4831ac26d0447fd8a2982416b2627a286b5': bug:3082865 don't use IN to construct sql to delete downloads
This commit is contained in:
@ -28,6 +28,7 @@ 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;
|
||||||
@ -53,6 +54,8 @@ import java.util.Set;
|
|||||||
* download in a notification or from the downloads UI.
|
* download in a notification or from the downloads UI.
|
||||||
*/
|
*/
|
||||||
public class DownloadManager {
|
public class DownloadManager {
|
||||||
|
private static final String TAG = "DownloadManager";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An identifier for a particular download, unique across the system. Clients use this ID to
|
* An identifier for a particular download, unique across the system. Clients use this ID to
|
||||||
* make subsequent calls related to the download.
|
* make subsequent calls related to the download.
|
||||||
@ -748,20 +751,11 @@ public class DownloadManager {
|
|||||||
* @return the number of downloads actually removed
|
* @return the number of downloads actually removed
|
||||||
*/
|
*/
|
||||||
public int remove(long... ids) {
|
public int remove(long... ids) {
|
||||||
StringBuilder whereClause = new StringBuilder();
|
if (ids == null || ids.length == 0) {
|
||||||
String[] whereArgs = new String[ids.length];
|
// called with nothing to remove!
|
||||||
|
throw new IllegalArgumentException("input param 'ids' can't be null");
|
||||||
whereClause.append(Downloads.Impl._ID + " IN (");
|
|
||||||
for (int i = 0; i < ids.length; i++) {
|
|
||||||
if (i > 0) {
|
|
||||||
whereClause.append(",");
|
|
||||||
}
|
|
||||||
whereClause.append("?");
|
|
||||||
whereArgs[i] = Long.toString(ids[i]);
|
|
||||||
}
|
}
|
||||||
whereClause.append(")");
|
return mResolver.delete(mBaseUri, getWhereClauseForIds(ids), getWhereArgsForIds(ids));
|
||||||
|
|
||||||
return mResolver.delete(mBaseUri, whereClause.toString(), whereArgs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -828,12 +822,13 @@ public class DownloadManager {
|
|||||||
*/
|
*/
|
||||||
static String getWhereClauseForIds(long[] ids) {
|
static String getWhereClauseForIds(long[] ids) {
|
||||||
StringBuilder whereClause = new StringBuilder();
|
StringBuilder whereClause = new StringBuilder();
|
||||||
whereClause.append(Downloads.Impl._ID + " IN (");
|
whereClause.append("(");
|
||||||
for (int i = 0; i < ids.length; i++) {
|
for (int i = 0; i < ids.length; i++) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
whereClause.append(",");
|
whereClause.append("OR ");
|
||||||
}
|
}
|
||||||
whereClause.append("?");
|
whereClause.append(Downloads.Impl._ID);
|
||||||
|
whereClause.append(" = ? ");
|
||||||
}
|
}
|
||||||
whereClause.append(")");
|
whereClause.append(")");
|
||||||
return whereClause.toString();
|
return whereClause.toString();
|
||||||
|
Reference in New Issue
Block a user