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

Commit 1b347753 authored by Rhed Jao's avatar Rhed Jao
Browse files

Do not kill apps dependending on static shared lib

There's no need to kill applications dependending on the old
version static shared library when the new version one is
installed.

Bug: 170938517
Test: atest StaticSharedLibsHostTests
Change-Id: Id770e09d4f08e41b31eac57e2d277513b5d42aae
parent 8181f28f
Loading
Loading
Loading
Loading
+13 −8
Original line number Diff line number Diff line
@@ -649,14 +649,19 @@ final class InstallPackageHelper {
            mPm.checkPackageFrozen(pkgName);
        }

        // Also need to kill any apps that are dependent on the library.
        final boolean isReplace =
                reconciledPkg.mPrepareResult != null && reconciledPkg.mPrepareResult.mReplace;
        // Also need to kill any apps that are dependent on the library, except the case of
        // installation of new version static shared library.
        if (clientLibPkgs != null) {
            if (pkg.getStaticSharedLibName() == null || isReplace) {
                for (int i = 0; i < clientLibPkgs.size(); i++) {
                    AndroidPackage clientPkg = clientLibPkgs.get(i);
                    mPm.killApplication(clientPkg.getPackageName(),
                            clientPkg.getUid(), "update lib");
                }
            }
        }

        // writer
        Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "updateSettings");
@@ -676,8 +681,6 @@ final class InstallPackageHelper {
            ksms.addScannedPackageLPw(pkg);

            mPm.mComponentResolver.addAllComponents(pkg, chatty);
            final boolean isReplace =
                    reconciledPkg.mPrepareResult != null && reconciledPkg.mPrepareResult.mReplace;
            mPm.mAppsFilter.addPackage(pkgSetting, isReplace);
            mPm.addAllPackageProperties(pkg);

@@ -3126,10 +3129,12 @@ final class InstallPackageHelper {
                            true, true, pkgList, uidArray, null);
                }
            } else if (!ArrayUtils.isEmpty(res.mLibraryConsumers)) { // if static shared lib
                // No need to kill consumers if it's installation of new version static shared lib.
                final boolean dontKillApp = !update && res.mPkg.getStaticSharedLibName() != null;
                for (int i = 0; i < res.mLibraryConsumers.size(); i++) {
                    AndroidPackage pkg = res.mLibraryConsumers.get(i);
                    // send broadcast that all consumers of the static shared library have changed
                    mPm.sendPackageChangedBroadcast(pkg.getPackageName(), false /* dontKillApp */,
                    mPm.sendPackageChangedBroadcast(pkg.getPackageName(), dontKillApp,
                            new ArrayList<>(Collections.singletonList(pkg.getPackageName())),
                            pkg.getUid(), null);
                }