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

Commit 5db18137 authored by Taeksoo Kim's avatar Taeksoo Kim Committed by Todd Kennedy
Browse files

Add a condition and remove resources when skipping post install

This change adds a condition to skip post install when a system package
is removed before update. And remove the update failed package's
resources safely, as they are not valid any more.

Bug: 162757027
Test: compile & verify basic functions working
Change-Id: I5ad778048227b1b0d3890dfc1f1f9bd314aff458
parent 0e2927e7
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -2127,11 +2127,21 @@ public class PackageManagerService extends IPackageManager.Stub
        final boolean update = res.removedInfo != null && res.removedInfo.removedPackage != null;
        final String packageName = res.name;
        final PackageSetting pkgSetting = succeeded ? getPackageSetting(packageName) : null;
        if (succeeded && pkgSetting == null) {
        final boolean removedBeforeUpdate = (pkgSetting == null)
                || (pkgSetting.isSystem() && !pkgSetting.getPathString().equals(res.pkg.getPath()));
        if (succeeded && removedBeforeUpdate) {
            Slog.e(TAG, packageName + " was removed before handlePackagePostInstall "
                    + "could be executed");
            res.returnCode = INSTALL_FAILED_PACKAGE_CHANGED;
            res.returnMsg = "Package was removed before install could complete.";
            // Remove the update failed package's older resources safely now
            InstallArgs args = res.removedInfo != null ? res.removedInfo.args : null;
            if (args != null) {
                synchronized (mInstallLock) {
                    args.doPostDeleteLI(true);
                }
            }
            notifyInstallObserver(res, installObserver);
            return;
        }