Fix the PMS live computer
Bug: 180050592
The live computer was created before PackageManagerService
mInstantAppResolverConnection was initialized. Unfortunately, the
live computer is used to initialized mInstantAppResolverConnection.
This change rebuilds the live computer after
mInstantAppResolverConnection is finally initialized.
Two additional cleanups are included, related to the use of the live
computer.
1. The ComputerEngineLocked now extends ComputerEngineLive. The
Locked class inherits the overriedes from the Live class, and the
now-redundant overrides in the Locked class are removed.
2. mSnapshotComputer is initialized to null in the constructor for
PackageManager Service. The snapshot should not be used until the
end of the constructor; setting the attribute to null will trigger
an NPE if the snapshot is used improperly.
See the bug description for specific tests. Instant apps are now
launched correctly.
All atests pass 100%.
Test: atest
* FrameworksServicesTests:AppsFilterTest
* FrameworksServicesTests:PackageInstallerSessionTest
* FrameworksServicesTests:PackageManagerServiceTest
* FrameworksServicesTests:PackageManagerSettingsTests
* FrameworksServicesTests:ScanTests
* FrameworksServicesTests:UserSystemPackageInstallerTest
* PackageManagerServiceBootTest
* UserLifecycleTests#startUser
* UserLifecycleTests#stopUser
* UserLifecycleTests#switchUser
* android.appsecurity.cts.EphemeralTest
* android.appsecurity.cts.InstantAppUserTest
Change-Id: Ic7e5a3ae9d661e2a7079d40a0f1a1ca6dc5badf2
This commit is contained in:
@@ -4629,7 +4629,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
* computer engine. This is required because there are no locks taken in
|
||||
* the engine itself.
|
||||
*/
|
||||
private static class ComputerLocked extends ComputerEngine {
|
||||
private static class ComputerLocked extends ComputerEngineLive {
|
||||
private final Object mLock;
|
||||
|
||||
ComputerLocked(Snapshot args) {
|
||||
@@ -4637,16 +4637,6 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
mLock = mService.mLock;
|
||||
}
|
||||
|
||||
protected ComponentName resolveComponentName() {
|
||||
return mService.mResolveComponentName;
|
||||
}
|
||||
protected ActivityInfo instantAppInstallerActivity() {
|
||||
return mService.mInstantAppInstallerActivity;
|
||||
}
|
||||
protected ApplicationInfo androidApplication() {
|
||||
return mService.mAndroidApplication;
|
||||
}
|
||||
|
||||
public @NonNull List<ResolveInfo> queryIntentServicesInternalBody(Intent intent,
|
||||
String resolvedType, int flags, int userId, int callingUid,
|
||||
String instantAppPkgName) {
|
||||
@@ -4776,8 +4766,9 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
}
|
||||
|
||||
|
||||
// Compute read-only functions, based on live data.
|
||||
private final Computer mLiveComputer;
|
||||
// Compute read-only functions, based on live data. This attribute may be modified multiple
|
||||
// times during the PackageManagerService constructor but it should not be modified thereafter.
|
||||
private Computer mLiveComputer;
|
||||
// A lock-free cache for frequently called functions.
|
||||
private volatile Computer mSnapshotComputer;
|
||||
// If true, the snapshot is invalid (stale). The attribute is static since it may be
|
||||
@@ -6395,8 +6386,9 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
// constructor.
|
||||
mSnapshotEnabled = SNAPSHOT_ENABLED;
|
||||
sSnapshotCorked = true;
|
||||
sSnapshotInvalid = true;
|
||||
mLiveComputer = createLiveComputer();
|
||||
mSnapshotComputer = mLiveComputer;
|
||||
mSnapshotComputer = null;
|
||||
registerObserver();
|
||||
|
||||
// CHECKSTYLE:OFF IndentationCheck
|
||||
@@ -7075,6 +7067,10 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
BOOT_TIME_EVENT_DURATION__EVENT__OTA_PACKAGE_MANAGER_INIT_TIME,
|
||||
SystemClock.uptimeMillis() - startTime);
|
||||
}
|
||||
|
||||
// Rebild the live computer since some attributes have been rebuilt.
|
||||
mLiveComputer = createLiveComputer();
|
||||
|
||||
} // synchronized (mLock)
|
||||
} // synchronized (mInstallLock)
|
||||
// CHECKSTYLE:ON IndentationCheck
|
||||
|
||||
Reference in New Issue
Block a user