summaryrefslogtreecommitdiffstats
path: root/src/com/android/providers
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/providers')
-rw-r--r--src/com/android/providers/downloads/DownloadProvider.java8
-rw-r--r--src/com/android/providers/downloads/DownloadStorageProvider.java30
-rw-r--r--src/com/android/providers/downloads/DownloadThread.java10
-rw-r--r--src/com/android/providers/downloads/StorageUtils.java2
4 files changed, 35 insertions, 15 deletions
diff --git a/src/com/android/providers/downloads/DownloadProvider.java b/src/com/android/providers/downloads/DownloadProvider.java
index b2b2c08d..387c200d 100644
--- a/src/com/android/providers/downloads/DownloadProvider.java
+++ b/src/com/android/providers/downloads/DownloadProvider.java
@@ -42,6 +42,7 @@ import android.database.DatabaseUtils;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
+import android.database.sqlite.SQLiteQueryBuilder;
import android.net.Uri;
import android.os.Binder;
import android.os.ParcelFileDescriptor;
@@ -895,8 +896,6 @@ public final class DownloadProvider extends ContentProvider {
final String selection, final String[] selectionArgs,
final String sort) {
- Helpers.validateSelection(selection, sAppReadableColumnsSet);
-
SQLiteDatabase db = mOpenHelper.getReadableDatabase();
int match = sURIMatcher.match(uri);
@@ -943,7 +942,10 @@ public final class DownloadProvider extends ContentProvider {
logVerboseQueryInfo(projection, selection, selectionArgs, sort, db);
}
- Cursor ret = db.query(DB_TABLE, projection, fullSelection.getSelection(),
+ SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
+ builder.setTables(DB_TABLE);
+ builder.setStrict(true);
+ Cursor ret = builder.query(db, projection, fullSelection.getSelection(),
fullSelection.getParameters(), null, null, sort);
if (ret != null) {
diff --git a/src/com/android/providers/downloads/DownloadStorageProvider.java b/src/com/android/providers/downloads/DownloadStorageProvider.java
index 4ec8e2d1..0bacb88b 100644
--- a/src/com/android/providers/downloads/DownloadStorageProvider.java
+++ b/src/com/android/providers/downloads/DownloadStorageProvider.java
@@ -108,8 +108,8 @@ public class DownloadStorageProvider extends DocumentsProvider {
final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));
final RowBuilder row = result.newRow();
row.add(Root.COLUMN_ROOT_ID, DOC_ID_ROOT);
- row.add(Root.COLUMN_FLAGS,
- Root.FLAG_LOCAL_ONLY | Root.FLAG_SUPPORTS_RECENTS | Root.FLAG_SUPPORTS_CREATE);
+ row.add(Root.COLUMN_FLAGS, Root.FLAG_LOCAL_ONLY | Root.FLAG_SUPPORTS_RECENTS
+ | Root.FLAG_SUPPORTS_CREATE | Root.FLAG_SUPPORTS_SEARCH);
row.add(Root.COLUMN_ICON, R.mipmap.ic_launcher_download);
row.add(Root.COLUMN_TITLE, getContext().getString(R.string.root_downloads));
row.add(Root.COLUMN_DOCUMENT_ID, DOC_ID_ROOT);
@@ -314,6 +314,32 @@ public class DownloadStorageProvider extends DocumentsProvider {
}
@Override
+ public Cursor querySearchDocuments(String rootId, String query, String[] projection)
+ throws FileNotFoundException {
+
+ final DownloadsCursor result =
+ new DownloadsCursor(projection, getContext().getContentResolver());
+
+ // Delegate to real provider
+ final long token = Binder.clearCallingIdentity();
+ Cursor cursor = null;
+ try {
+ cursor = mDm.query(new DownloadManager.Query().setOnlyIncludeVisibleInDownloadsUi(true)
+ .setFilterByString(query));
+ copyNotificationUri(result, cursor);
+ while (cursor.moveToNext()) {
+ includeDownloadFromCursor(result, cursor);
+ }
+ } finally {
+ IoUtils.closeQuietly(cursor);
+ Binder.restoreCallingIdentity(token);
+ }
+
+ result.start();
+ return result;
+ }
+
+ @Override
public ParcelFileDescriptor openDocument(String docId, String mode, CancellationSignal signal)
throws FileNotFoundException {
if (mArchiveHelper.isArchivedDocument(docId)) {
diff --git a/src/com/android/providers/downloads/DownloadThread.java b/src/com/android/providers/downloads/DownloadThread.java
index 33436f57..5b5d9664 100644
--- a/src/com/android/providers/downloads/DownloadThread.java
+++ b/src/com/android/providers/downloads/DownloadThread.java
@@ -902,15 +902,7 @@ public class DownloadThread extends Thread {
}
@Override
- public void onRestrictBackgroundWhitelistChanged(int uid, boolean whitelisted) {
- // caller is NPMS, since we only register with them
- if (uid == mInfo.mUid) {
- mPolicyDirty = true;
- }
- }
-
- @Override
- public void onRestrictBackgroundBlacklistChanged(int uid, boolean blacklisted) {
+ public void onUidPoliciesChanged(int uid, int uidPolicies) {
// caller is NPMS, since we only register with them
if (uid == mInfo.mUid) {
mPolicyDirty = true;
diff --git a/src/com/android/providers/downloads/StorageUtils.java b/src/com/android/providers/downloads/StorageUtils.java
index 3bb57c8e..d7a5c33b 100644
--- a/src/com/android/providers/downloads/StorageUtils.java
+++ b/src/com/android/providers/downloads/StorageUtils.java
@@ -154,7 +154,7 @@ public class StorageUtils {
Collections.sort(files, new Comparator<ConcreteFile>() {
@Override
public int compare(ConcreteFile lhs, ConcreteFile rhs) {
- return (int) (lhs.file.lastModified() - rhs.file.lastModified());
+ return Long.compare(lhs.file.lastModified(), rhs.file.lastModified());
}
});