Move computePackageStateHash() implementation into platform.

The computePackageStateHash() implementation needs
PackageManagerInternal.forEachInstalledPackage(),
getApplicationEnabledState(), getEnabledComponents() and
getDisabledComponents() to work, for which we don't have good
alternatives in API. Even if we added those APIs, generating and
iterating over PackageInfo for all packages in the system would surely
drive up CPU and memory usage and regress our performance, and the new
AndroidPackage system APIs isn't ready in S yet. So we can move
computePackageStateHash() implementation into platform. Once we move
role logic into system server, granting default roles may be fast
enough and we may consider the deprecation/removal of this.

This way we can also remove the final dependency we have on
PackageManagerInternal and be ready for modularization.

Bug: 158736025
Test: presubmit
Change-Id: I14119f2e95c861ee3539108748a4912b051b4462
5 files changed