Run appsFilter.systemReady() last

This change moves the appsFilter systemReady call to the end of the PMS
systemReady method to avoid it acquiring the package lock on a
background thread as the lock is required by several other blocks in the
method.

Before: MakePackageMangerServiceReady timing was 300-500ms, most of that
time spent setting up preferred activities as it waited for mLock to
become available
After: MakePackageManagerSerivceReady timing is ~130ms.

Test: atest AppEnumerationTests
Fixes: 162347084
Fixes: 163613646
Change-Id: Iac2948fb2ad66e45161627f637f039a5f4faf88c
This commit is contained in:
Patrick Baumann
2020-08-28 04:35:47 +00:00
parent 5be7e28816
commit 112a64a6dd

View File

@@ -21558,8 +21558,6 @@ public class PackageManagerService extends IPackageManager.Stub
.getUriFor(Secure.INSTANT_APPS_ENABLED), false, co, UserHandle.USER_ALL);
co.onChange(true);
mAppsFilter.onSystemReady();
// Disable any carrier apps. We do this very early in boot to prevent the apps from being
// disabled after already being started.
CarrierAppUtils.disableCarrierAppsUntilPrivileged(
@@ -21708,6 +21706,9 @@ public class PackageManagerService extends IPackageManager.Stub
mInstallerService.restoreAndApplyStagedSessionIfNeeded();
mExistingPackages = null;
// We'll do this last as it builds its cache while holding mLock via callback.
mAppsFilter.onSystemReady();
}
public void waitForAppDataPrepared() {