Restrict legacy apps to insert files to other private app dirs

We allow legacy apps to insert/update content values such that they can
add private files to MediaStore database. Restrict such apps to
insert/update content in other app's private directories. Add extensive
logic to allow apps with special access (installers, access_mtp,
downloadsprovider) to have same level of access to other app's private
directories.

Retrict System Gallery apps and apps with MANAGE_EXTERNAL_STORAGE
permission to insert private path files.

Bug: 201667614
Test: atest FileUtilsTest
Test: atest CtsScopedStorageHostTest
Test: atest LegacyStorageTest:LegacyStorageHostTest
Change-Id: I52481b24b137790d49845f1a4b00978c63ed183b
Merged-In: I52481b24b137790d49845f1a4b00978c63ed183b
6 files changed