Gracefully handle content uris without id in checkUriPermission
Uri grants are allowed only if app has access to corresponding db row.
MediaProvider uri permission check works correctly for uris that
correspond to valid database row. However, for content uris of the
table, we always deny the permission.
Apps might not need this permission grant in most of the scenarios like
picker activities. However, some apps request for uri grant and we
kill the app if the permission is denied.
Changed checkUriPermission to allow uri grants on content uris without
ID if it is non prefix grants (This doesn't grant any extra access). i
If it's a prefix grant request, we always deny the permission grant as
prefix grant may allow apps to give access to all files.
Test: Manual. Verified that chat app doesn't crash while attaching image
Test: atest ExternalStorageHostTest#testGrantUriPermission
Test: atest ExternalStorageHostTest#testGrantUriPermission29
(cherry picked from commit 8bb104ab39e94a015207555a49d496954e4356f0)
1 file changed