diff options
author | Johan Redestig <johan.redestig@sonymobile.com> | 2014-01-08 16:36:36 +0100 |
---|---|---|
committer | Johan Redestig <johan.redestig@sonymobile.com> | 2014-01-28 13:13:27 +0100 |
commit | b5267f95579e1a51bd0e8128f99ca6f1635d208b (patch) | |
tree | 6f8c6f1f2d2f24322712bfc9fa1bbc70894a3364 /src | |
parent | 83542cf9e01ce8822992d85fbe308ae3b05a5c28 (diff) | |
download | android_packages_providers_MediaProvider-b5267f95579e1a51bd0e8128f99ca6f1635d208b.tar.gz android_packages_providers_MediaProvider-b5267f95579e1a51bd0e8128f99ca6f1635d208b.tar.bz2 android_packages_providers_MediaProvider-b5267f95579e1a51bd0e8128f99ca6f1635d208b.zip |
Allow holders of WRITE_MEDIA_STORAGE to write to secondary external storage
Apps with WRITE_MEDIA_STORAGE can write to the secondary
external storage directly so there is no need to prevent
that through the MediaProvider.
Change-Id: If092fcdf0b90599afdb52a8e6ae4c7ba1090acc4
Diffstat (limited to 'src')
-rwxr-xr-x | src/com/android/providers/media/MediaProvider.java | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/com/android/providers/media/MediaProvider.java b/src/com/android/providers/media/MediaProvider.java index 7e8d6867..89b6938f 100755 --- a/src/com/android/providers/media/MediaProvider.java +++ b/src/com/android/providers/media/MediaProvider.java @@ -19,6 +19,7 @@ package com.android.providers.media; import static android.Manifest.permission.ACCESS_CACHE_FILESYSTEM; import static android.Manifest.permission.READ_EXTERNAL_STORAGE; import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE; +import static android.Manifest.permission.WRITE_MEDIA_STORAGE; import static android.os.ParcelFileDescriptor.MODE_READ_ONLY; import static android.os.ParcelFileDescriptor.MODE_WRITE_ONLY; @@ -4643,15 +4644,25 @@ public class MediaProvider extends ContentProvider { c.enforceCallingOrSelfPermission( ACCESS_CACHE_FILESYSTEM, "Cache path: " + path); } - } else if (isWrite) { - // don't write to non-cache, non-sdcard files. - throw new FileNotFoundException("Can't access " + file); } else if (isSecondaryExternalPath(path)) { // read access is OK with the appropriate permission if (!readGranted) { - c.enforceCallingOrSelfPermission( - READ_EXTERNAL_STORAGE, "External path: " + path); + if (c.checkCallingOrSelfPermission(WRITE_MEDIA_STORAGE) + == PackageManager.PERMISSION_DENIED) { + c.enforceCallingOrSelfPermission( + READ_EXTERNAL_STORAGE, "External path: " + path); + } + } + if (isWrite) { + if (c.checkCallingOrSelfUriPermission(uri, Intent.FLAG_GRANT_WRITE_URI_PERMISSION) + != PackageManager.PERMISSION_GRANTED) { + c.enforceCallingOrSelfPermission( + WRITE_MEDIA_STORAGE, "External path: " + path); + } } + } else if (isWrite) { + // don't write to non-cache, non-sdcard files. + throw new FileNotFoundException("Can't access " + file); } else { checkWorldReadAccess(path); } |