Release mPackages lock earlier
We cannot hold mPackages when calling into generatePackageDexopts().
This method takes Package Manager's mInstallLock. By holding mPackages,
we have lock inversion and hilarity ensues.
Change-Id: Ia11a158677051e3511702f38cde6780e75b256fb
Fixes: 30927731
(cherry picked from commit a8d4f48997)
This commit is contained in:
committed by
Andreas Gampe
parent
3f95d0bb6a
commit
94f9be2ee2
@@ -93,17 +93,19 @@ public class OtaDexoptService extends IOtaDexopt.Stub {
|
|||||||
if (mDexoptCommands != null) {
|
if (mDexoptCommands != null) {
|
||||||
throw new IllegalStateException("already called prepare()");
|
throw new IllegalStateException("already called prepare()");
|
||||||
}
|
}
|
||||||
|
final List<PackageParser.Package> important;
|
||||||
|
final List<PackageParser.Package> others;
|
||||||
synchronized (mPackageManagerService.mPackages) {
|
synchronized (mPackageManagerService.mPackages) {
|
||||||
// Important: the packages we need to run with ab-ota compiler-reason.
|
// Important: the packages we need to run with ab-ota compiler-reason.
|
||||||
List<PackageParser.Package> important = PackageManagerServiceUtils.getPackagesForDexopt(
|
important = PackageManagerServiceUtils.getPackagesForDexopt(
|
||||||
mPackageManagerService.mPackages.values(), mPackageManagerService);
|
mPackageManagerService.mPackages.values(), mPackageManagerService);
|
||||||
// Others: we should optimize this with the (first-)boot compiler-reason.
|
// Others: we should optimize this with the (first-)boot compiler-reason.
|
||||||
List<PackageParser.Package> others =
|
others = new ArrayList<>(mPackageManagerService.mPackages.values());
|
||||||
new ArrayList<>(mPackageManagerService.mPackages.values());
|
|
||||||
others.removeAll(important);
|
others.removeAll(important);
|
||||||
|
|
||||||
// Pre-size the array list by over-allocating by a factor of 1.5.
|
// Pre-size the array list by over-allocating by a factor of 1.5.
|
||||||
mDexoptCommands = new ArrayList<>(3 * mPackageManagerService.mPackages.size() / 2);
|
mDexoptCommands = new ArrayList<>(3 * mPackageManagerService.mPackages.size() / 2);
|
||||||
|
}
|
||||||
|
|
||||||
for (PackageParser.Package p : important) {
|
for (PackageParser.Package p : important) {
|
||||||
// Make sure that core apps are optimized according to their own "reason".
|
// Make sure that core apps are optimized according to their own "reason".
|
||||||
@@ -125,7 +127,6 @@ public class OtaDexoptService extends IOtaDexopt.Stub {
|
|||||||
mDexoptCommands.addAll(
|
mDexoptCommands.addAll(
|
||||||
generatePackageDexopts(p, PackageManagerService.REASON_FIRST_BOOT));
|
generatePackageDexopts(p, PackageManagerService.REASON_FIRST_BOOT));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
completeSize = mDexoptCommands.size();
|
completeSize = mDexoptCommands.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user