Add 2 compat flags to strictly enable/disable scoped storage

* DEFAULT_SCOPED_STORAGE is the (soft) Scoped Storage policy that we have
by default on (with exceptions to opt out of Scoped Storage).

* FORCE_ENABLED_SCOPED_STORAGE is the (hard) Scoped Storage policy that
forces an app into Scoped Storage (regardless of any way to opt out)
and currently not applicable to any targetsdk.

Different flag combinations:

* Set both the flags to strictly enable scoped storage.

* Unset both the flags to stricly disable scoped storage.

* OP_LEGACY_STORAGE appop precedes any other combination of the flags.
This would be the initial state for all target sdk (as
FORCE_ENABLED_SCOPED_STORAGE is not set).

Bug: 132649864
Bug: 149924527

Test: atest RestrictedPermissionsTest
Test: atest RestrictedStoragePermissionTest
Test: atest RestrictedStoragePermissionSharedUidTest
Test: atest MediaProviderTests:com.android.providers.media.scan.ModernMediaScannerTest
Test: atest MediaProviderTests:com.android.providers.media.MediaProviderTest
Test: atest com.android.providers.media.MediaDocumentsProviderTest

Test: File APIs legacy vs non-legacy app behavior
      * Sample app targeting R and no `preserveLegacyExternalStorage` in Manifest
        is not able to create test.pdf in DCIM (due to scoped storage restrictions)
      * `adb shell am compat disable DEFAULT_SCOPED_STORAGE <pkg_name>`
      or turn the flag off from Settings UI
      Settings-> App Compatibility->(Select app)-> unset DEFAULT_SCOPED_STORAGE
      * Able to create test.pdf in DCIM (hence opt out of scoped storage)
      * Try different combinations of the flag to test other workflows

Test: MediaProvider APIs legacy vs non-legacy app behavior
      * Sample test app targeting R and no `preserveLegacyExternalStorage` in Manifest
      calls query() API for DCIM which does not show test.pdf
      * `adb shell am compat disable DEFAULT_SCOPED_STORAGE <pkg_name>`
      or turn the flag off from Settings UI
      * Sample test app targeting R calls query() API for DCIM as is
      able to read test.pdf file
      * Try different combinations of the flag to test other workflows

Merged-In: Iad2d361ad801ac2d2999d224f9bc06fbf6129619
Change-Id: Iad2d361ad801ac2d2999d224f9bc06fbf6129619
(cherry picked from commit f491007a9a0bef2792d2a2fc18df0fb0758e34b4)
5 files changed