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.

Bug: 159995598
Bug: 115619667
Test: Manual. Verified that chat app doesn't crash while attaching image
file.
Test: atest ExternalStorageHostTest#testGrantUriPermission
Test: atest ExternalStorageHostTest#testGrantUriPermission29
Merged-In: Ib0021d3fd34294bb7497c8827e7ee99d4ac64d73
Change-Id: Ib0021d3fd34294bb7497c8827e7ee99d4ac64d73
(cherry picked from commit 8bb104ab39e94a015207555a49d496954e4356f0)
1 file changed