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
This commit is contained in:
Hai Zhang
2021-01-15 14:35:10 -08:00
parent 91464139ff
commit d066c7c933
5 changed files with 77 additions and 71 deletions

View File

@@ -160,7 +160,7 @@ import com.android.server.pm.UserManagerService;
import com.android.server.pm.dex.SystemServerDexLoadReporter;
import com.android.server.policy.PermissionPolicyService;
import com.android.server.policy.PhoneWindowManager;
import com.android.server.policy.role.LegacyRoleStateProviderImpl;
import com.android.server.policy.role.RoleServicePlatformHelperImpl;
import com.android.server.power.PowerManagerService;
import com.android.server.power.ShutdownThread;
import com.android.server.power.ThermalManagerService;
@@ -2033,7 +2033,7 @@ public final class SystemServer implements Dumpable {
// Grants default permissions and defines roles
t.traceBegin("StartRoleManagerService");
mSystemServiceManager.startService(new RoleManagerService(
mSystemContext, new LegacyRoleStateProviderImpl(mSystemContext)));
mSystemContext, new RoleServicePlatformHelperImpl(mSystemContext)));
t.traceEnd();
// We need to always start this service, regardless of whether the