Add API for apps to query whether they have All Files Access

This is a fix in response to developers' feedback on DP1.
Add Environment API that enables apps to check whether they have All
Files Access special app access. The API encapsulates the actual
mechanics of the check, which are as follows:
    * First check MANAGE_EXTERNAL_STORAGE app-op,
      if it's allowed, return true. If it's denied (ignored or errored),
      return false.
    * If the mode is default, then check for MANAGE_EXTERNAL_STORAGE
      permission, if it's GRANTED (not just declared), then return true,
      else return false.

Also add test.

Test: atest EnvironmentTest # not CTS
Fix: 150115615
Merged-In: I0574827c22960bf8f074313d983f289be7142149
Change-Id: I0574827c22960bf8f074313d983f289be7142149
3 files changed