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

Commit 6b0c8315 authored by Todd Kennedy's avatar Todd Kennedy
Browse files

Partially revert package freezing

On the Nexus Player, upgrading the launcher would cause multiple, simultaneous
processes to be running. In order to prevent this regression, revert the portion
of ag/682591 dealing with package upgrades.

Bug: 21123444
Change-Id: I7a4cf98c7e28fc9893b1c0358d3a98702d94c039
parent 60261137
Loading
Loading
Loading
Loading
+19 −29
Original line number Diff line number Diff line
@@ -323,6 +323,7 @@ public class PackageManagerService extends IPackageManager.Stub {
    static final int SCAN_BOOTING = 1<<8;
    static final int SCAN_TRUSTED_OVERLAY = 1<<9;
    static final int SCAN_DELETE_DATA_ON_FAILURES = 1<<10;
    static final int SCAN_REPLACING = 1<<11;
    static final int SCAN_REQUIRE_KNOWN = 1<<12;
    static final int SCAN_MOVE = 1<<13;
    static final int SCAN_INITIAL = 1<<14;
@@ -7133,6 +7134,14 @@ public class PackageManagerService extends IPackageManager.Stub {
            }
        }
        // Request the ActivityManager to kill the process(only for existing packages)
        // so that we do not end up in a confused state while the user is still using the older
        // version of the application while the new one gets installed.
        if ((scanFlags & SCAN_REPLACING) != 0) {
            killApplication(pkg.applicationInfo.packageName,
                        pkg.applicationInfo.uid, "replace pkg");
        }
        // Also need to kill any apps that are dependent on the library.
        if (clientLibPkgs != null) {
            for (int i=0; i<clientLibPkgs.size(); i++) {
@@ -11770,7 +11779,6 @@ public class PackageManagerService extends IPackageManager.Stub {
        final String pkgName = pkg.packageName;
        final int[] allUsers;
        final boolean[] perUserInstalled;
        final boolean weFroze;
        // First find the old package info and check signatures
        synchronized(mPackages) {
@@ -11800,21 +11808,8 @@ public class PackageManagerService extends IPackageManager.Stub {
            for (int i = 0; i < allUsers.length; i++) {
                perUserInstalled[i] = ps != null ? ps.getInstalled(allUsers[i]) : false;
            }
            // Mark the app as frozen to prevent launching during the upgrade
            // process, and then kill all running instances
            if (!ps.frozen) {
                ps.frozen = true;
                weFroze = true;
            } else {
                weFroze = false;
        }
        }
        // Now that we're guarded by frozen state, kill app during upgrade
        killApplication(pkgName, oldPackage.applicationInfo.uid, "replace pkg");
        try {
        boolean sysPkg = (isSystemApp(oldPackage));
        if (sysPkg) {
            replaceSystemPackageLI(oldPackage, pkg, parseFlags, scanFlags,
@@ -11823,13 +11818,6 @@ public class PackageManagerService extends IPackageManager.Stub {
            replaceNonSystemPackageLI(oldPackage, pkg, parseFlags, scanFlags,
                    user, allUsers, perUserInstalled, installerPackageName, volumeUuid, res);
        }
        } finally {
            // Regardless of success or failure of upgrade steps above, always
            // unfreeze the package if we froze it
            if (weFroze) {
                unfreezePackage(pkgName);
            }
        }
    }
    private void replaceNonSystemPackageLI(PackageParser.Package deletedPackage,
@@ -11958,6 +11946,8 @@ public class PackageManagerService extends IPackageManager.Stub {
            }
        }
        killApplication(packageName, oldPkg.applicationInfo.uid, "replace sys pkg");
        res.removedInfo.uid = oldPkg.applicationInfo.uid;
        res.removedInfo.removedPackage = packageName;
        // Remove existing system package
@@ -12347,7 +12337,7 @@ public class PackageManagerService extends IPackageManager.Stub {
        startIntentFilterVerifications(args.user.getIdentifier(), replace, pkg);
        if (replace) {
            replacePackageLI(pkg, parseFlags, scanFlags, args.user,
            replacePackageLI(pkg, parseFlags, scanFlags | SCAN_REPLACING, args.user,
                    installerPackageName, volumeUuid, res);
        } else {
            installNewPackageLI(pkg, parseFlags, scanFlags | SCAN_DELETE_DATA_ON_FAILURES,