Simplify canAccessMediaFile function

The canAccessMediaFile function can be used to check file access for
both System Gallery Packages and Legacy apps with write permissions.
This refactor abstracts the logic that decides which type of app to
run the check against. It provides a simpler function
check that works for both scenarios.

Bug: 206356546
Test: atest android.scopedstorage.cts.host.ScopedStorageHostTest#testFileManagerCanUpdateOtherAndroidMediaFiles
Change-Id: Iea03a8bb5470657a41879586cc365f4cd8599dae
Merged-In: Iea03a8bb5470657a41879586cc365f4cd8599dae
(cherry picked from commit 89256bec5ced638d73d3e892b6f73dd43655a71b)
1 file changed