Revert "Revert "Allow hidden API access from system libraries""

Libraries like RemoteDisplay provide an APK that an app loads into
its process and which accesses internal APIs on the app's behalf,
without exposing the internals to the app. These libraries are
considered part of the platform, but were not exempt from hidden API
checks because they are not loaded with the boot strap class loader.

This patch adds a new flag to DexFile class which the constructor
sets to true of the canonical location of the newly loaded dex file
starts with "${ANDROID_ROOT}/framework/". Hidden API enforcement
then checks this flag when determining whether the caller of
a hidden class member is allowed to access it or not.

This reverts commit 0127b71a2588efcd1a53c192c5c267157878b010.

Previous CL saw two issues:
- buildbots would set non-existent ANDROID_ROOT for host-side builds
- calling realpath on unquickened dex files would overflow the stack

Bug: 64382372
Bug: 76138670
Bug: 76165623
Bug: 76112393
Bug: 76452688
Bug: 76429651
Test: art/test.py --target -r -b -t 674-hiddenapi
Test: SystemUI APCT test
Merged-In: Ie07a088509002593353965d3d24bf7362b643f40
Change-Id: Ie07a088509002593353965d3d24bf7362b643f40
(cherry picked from commit 8e1a7cb303d7c8f763dfb99ae311b820996b1ab4)
13 files changed