summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2013-09-26 14:30:47 -0700
committerJeff Sharkey <jsharkey@android.com>2013-09-26 14:36:35 -0700
commitafaf53bd2b1322167b6f31eda941e38335c4a952 (patch)
tree1365d79e163582cde8e18471b90c393a6df5825a
parent776e4f7991c4f5637f9a945ed9190a26ff295446 (diff)
downloadandroid_packages_providers_DownloadProvider-afaf53bd2b1322167b6f31eda941e38335c4a952.zip
android_packages_providers_DownloadProvider-afaf53bd2b1322167b6f31eda941e38335c4a952.tar.gz
android_packages_providers_DownloadProvider-afaf53bd2b1322167b6f31eda941e38335c4a952.tar.bz2
Revoke grants when downloads are deleted.
When deleting downloads, revoke any Uri permission grants, which removes from getPersistedUriPermissions(). Bug: 10928851 Change-Id: I3e90c4071385832dcb3e0cf9ca3fdccafbe30037
-rw-r--r--src/com/android/providers/downloads/DownloadProvider.java13
-rw-r--r--src/com/android/providers/downloads/DownloadStorageProvider.java7
2 files changed, 20 insertions, 0 deletions
diff --git a/src/com/android/providers/downloads/DownloadProvider.java b/src/com/android/providers/downloads/DownloadProvider.java
index 999134f..cb3dc18 100644
--- a/src/com/android/providers/downloads/DownloadProvider.java
+++ b/src/com/android/providers/downloads/DownloadProvider.java
@@ -1162,6 +1162,19 @@ public final class DownloadProvider extends ContentProvider {
case ALL_DOWNLOADS_ID:
SqlSelection selection = getWhereClause(uri, where, whereArgs, match);
deleteRequestHeaders(db, selection.getSelection(), selection.getParameters());
+
+ final Cursor cursor = db.query(DB_TABLE, new String[] {
+ Downloads.Impl._ID }, selection.getSelection(), selection.getParameters(),
+ null, null, null);
+ try {
+ while (cursor.moveToNext()) {
+ final long id = cursor.getLong(0);
+ DownloadStorageProvider.onDownloadProviderDelete(getContext(), id);
+ }
+ } finally {
+ IoUtils.closeQuietly(cursor);
+ }
+
count = db.delete(DB_TABLE, selection.getSelection(), selection.getParameters());
break;
diff --git a/src/com/android/providers/downloads/DownloadStorageProvider.java b/src/com/android/providers/downloads/DownloadStorageProvider.java
index d982f2a..1b7b691 100644
--- a/src/com/android/providers/downloads/DownloadStorageProvider.java
+++ b/src/com/android/providers/downloads/DownloadStorageProvider.java
@@ -25,6 +25,7 @@ import android.database.Cursor;
import android.database.MatrixCursor;
import android.database.MatrixCursor.RowBuilder;
import android.graphics.Point;
+import android.net.Uri;
import android.os.Binder;
import android.os.CancellationSignal;
import android.os.Environment;
@@ -47,6 +48,7 @@ import java.io.IOException;
* contents.
*/
public class DownloadStorageProvider extends DocumentsProvider {
+ private static final String AUTHORITY = Constants.STORAGE_AUTHORITY;
private static final String DOC_ID_ROOT = Constants.STORAGE_ROOT_ID;
private static final String[] DEFAULT_ROOT_PROJECTION = new String[] {
@@ -82,6 +84,11 @@ public class DownloadStorageProvider extends DocumentsProvider {
result.setNotificationUri(getContext().getContentResolver(), cursor.getNotificationUri());
}
+ static void onDownloadProviderDelete(Context context, long id) {
+ final Uri uri = DocumentsContract.buildDocumentUri(AUTHORITY, Long.toString(id));
+ context.revokeUriPermission(uri, ~0);
+ }
+
@Override
public Cursor queryRoots(String[] projection) throws FileNotFoundException {
final MatrixCursor result = new MatrixCursor(resolveRootProjection(projection));