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

Commit 32a019d4 authored by Christopher Tate's avatar Christopher Tate
Browse files

Implicitly enable system apps when updates installed

If someone explicitly installs an update to a system-bundled package,
we infer that this means they actually want to use the new code.

Bug 7467302

Change-Id: If2dc6f764bafbb3a5c94cbdd32273c030fd784b9
parent 3c09715c
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -8223,6 +8223,24 @@ public class PackageManagerService extends IPackageManager.Stub {
            updatePermissionsLPw(newPackage.packageName, newPackage,
                    UPDATE_PERMISSIONS_REPLACE_PKG | (newPackage.permissions.size() > 0
                            ? UPDATE_PERMISSIONS_ALL : 0));
            // For system-bundled packages, we assume that installing an upgraded version
            // of the package implies that the user actually wants to run that new code,
            // so we enable the package.
            if (isSystemApp(newPackage)) {
                // NB: implicit assumption that system package upgrades apply to all users
                if (DEBUG_INSTALL) {
                    Slog.d(TAG, "Implicitly enabling system package on upgrade: " + pkgName);
                }
                PackageSetting ps = mSettings.mPackages.get(pkgName);
                if (ps != null) {
                    if (res.origUsers != null) {
                        for (int userHandle : res.origUsers) {
                            ps.setEnabled(COMPONENT_ENABLED_STATE_DEFAULT,
                                    userHandle, installerPackageName);
                        }
                    }
                }
            }
            res.name = pkgName;
            res.uid = newPackage.applicationInfo.uid;
            res.pkg = newPackage;