summaryrefslogtreecommitdiffstats
path: root/src/com/android/providers/downloads
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@android.com>2016-06-28 10:07:48 -0600
committerJeff Sharkey <jsharkey@google.com>2016-06-28 16:08:40 +0000
commit01dee865054aedb9aa7e90a8ef2c556e19af95e1 (patch)
tree117825efc3760b656d3d5a0ae689922433a6fa6c /src/com/android/providers/downloads
parent3a4a3e7cd5a379e7e757177826ba935f000eb455 (diff)
downloadandroid_packages_providers_DownloadProvider-01dee865054aedb9aa7e90a8ef2c556e19af95e1.tar.gz
android_packages_providers_DownloadProvider-01dee865054aedb9aa7e90a8ef2c556e19af95e1.tar.bz2
android_packages_providers_DownloadProvider-01dee865054aedb9aa7e90a8ef2c556e19af95e1.zip
Clear identity when deleting scanned entry.
When deleting a file from DownloadManager, we also reach over and clean up any scanned MediaStore entries. However, DownloadManager clients may not hold the WRITE_EXTERNAL_STORAGE permission, such as when they downloaded a file into their package-specific directories. The safest fix for now is to clear the calling identity and always clean up the MediaStore entries ourselves, since DownloadProvider always holds the required storage permission. Bug: 29777504 Change-Id: Iea8f5696410010807b118bb56e5b897c53f0e1fe
Diffstat (limited to 'src/com/android/providers/downloads')
-rw-r--r--src/com/android/providers/downloads/DownloadProvider.java9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/com/android/providers/downloads/DownloadProvider.java b/src/com/android/providers/downloads/DownloadProvider.java
index 4b83cacb..d30018f7 100644
--- a/src/com/android/providers/downloads/DownloadProvider.java
+++ b/src/com/android/providers/downloads/DownloadProvider.java
@@ -1229,8 +1229,13 @@ public final class DownloadProvider extends ContentProvider {
final String mediaUri = cursor.getString(2);
if (!TextUtils.isEmpty(mediaUri)) {
- getContext().getContentResolver().delete(Uri.parse(mediaUri), null,
- null);
+ final long token = Binder.clearCallingIdentity();
+ try {
+ getContext().getContentResolver().delete(Uri.parse(mediaUri), null,
+ null);
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
}
}
}