Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b7b45155 authored by Patrick Baumann's avatar Patrick Baumann
Browse files

Moves clear data out of commit

A previous refactor had moved a call to clearAppDataLIF, which makes
calls to installd into a block that was locked on mPackages. This
resulted in PackageManagerService holding the lock while installd
attempted to do the same and making install essentially blocked
indefinitely. To fix this, we moved the call to a post-commit phase
where the mPackages lock has been released.

Test: `atest CtsUiRenderingTestCases` doesn't halt
Change-Id: Ibe735a4351c14ab1428200f2d665aaff01119876
Fixes: 118888402
parent 0a2786cc
Loading
Loading
Loading
Loading
+3 −10
Original line number Diff line number Diff line
@@ -15153,14 +15153,8 @@ public class PackageManagerService extends IPackageManager.Stub
                            pkgList.add(oldPackage.applicationInfo.packageName);
                            sendResourcesChangedBroadcast(false, true, pkgList, uidArray, null);
                        }
                        clearAppDataLIF(pkg, UserHandle.USER_ALL, StorageManager.FLAG_STORAGE_DE
                                | StorageManager.FLAG_STORAGE_CE
                                | Installer.FLAG_CLEAR_CODE_CACHE_ONLY);
                    }
                    // Update the in-memory copy of the previous code paths.
                    PackageSetting ps1 = mSettings.mPackages.get(
                            reconciledPkg.prepareResult.existingPackage.packageName);
@@ -15364,7 +15358,8 @@ public class PackageManagerService extends IPackageManager.Stub
    /**
     * On successful install, executes remaining steps after commit completes and the package lock
     * is released.
     * is released. These are typically more expensive or require calls to installd, which often
     * locks on {@link #mPackages}.
     */
    private void executePostCommitSteps(CommitRequest commitRequest) {
        for (ReconciledPackage reconciledPkg : commitRequest.reconciledPackages.values()) {
@@ -16093,7 +16088,6 @@ public class PackageManagerService extends IPackageManager.Stub
        try {
            final PackageParser.Package existingPackage;
            String renamedPackage = null;
            boolean clearCodeCache = false;
            boolean sysPkg = false;
            String targetVolumeUuid = volumeUuid;
            int targetScanFlags = scanFlags;
@@ -16314,7 +16308,6 @@ public class PackageManagerService extends IPackageManager.Stub
                        Slog.d(TAG, "replaceSystemPackageLI: new=" + pkg
                                + ", old=" + oldPackage);
                    }
                    clearCodeCache = true;
                    res.setReturnCode(PackageManager.INSTALL_SUCCEEDED);
                    pkg.setApplicationInfoFlags(ApplicationInfo.FLAG_UPDATED_SYSTEM_APP,
                            ApplicationInfo.FLAG_UPDATED_SYSTEM_APP);
@@ -16370,7 +16363,7 @@ public class PackageManagerService extends IPackageManager.Stub
            shouldCloseFreezerBeforeReturn = false;
            return new PrepareResult(args.installReason, targetVolumeUuid, installerPackageName,
                    args.user, replace, targetScanFlags, targetParseFlags, existingPackage, pkg,
                    clearCodeCache, sysPkg, renamedPackage, freezer);
                    replace /* clearCodeCache */, sysPkg, renamedPackage, freezer);
        } finally {
            if (shouldCloseFreezerBeforeReturn) {
                freezer.close();