Support MATCH_WRITABLE for IS_PENDING AND IS_TRASHED match.

In a filepath operation, pending files and trashed files should only be
visible to
1. App that created it
2. Apps with MANAGE_EXTERNAL_STORAGE permission
3. System Gallery and
4. Legacy apps with WRITE_EXTERNAL_STORAGE
We shouldn't allow any other app to see these files on readdir or modify
or delete these files.

This is achieved by matching database rows that have is_pending or
is_trashed set, and checking if the calling package has write permission
to the database row.

Added new MATCH_* type MATCH_WRITABLE that matches writable database
rows when the given column is set to 1.

Changed default match type for fuse read operations to
MATCH_WRITABLE and default match type for fuse write operations to
MATCH_INCLUDE. Default match type remains unchanged for ContentResolver
operations.

Test: atest packages/providers/MediaProvider
Bug: 148585977
Change-Id: I166cb5bfbfb0a8c7ddf2e74e2ea0a4c99c9a9102
1 file changed