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

Commit 2e3578ca authored by Todd Kennedy's avatar Todd Kennedy Committed by android-build-merger
Browse files

Merge "Remove privilege if a priv_app is removed via OTA" into qt-dev

am: a9786e9a

Change-Id: Ie917424a7f1a27456e4a931aa0b2324db216c95e
parents 29955b5c a9786e9a
Loading
Loading
Loading
Loading
+35 −13
Original line number Original line Diff line number Diff line
@@ -2923,28 +2923,50 @@ public class PackageManagerService extends IPackageManager.Stub
                // Remove disable package settings for updated system apps that were
                // Remove disable package settings for updated system apps that were
                // removed via an OTA. If the update is no longer present, remove the
                // removed via an OTA. If the update is no longer present, remove the
                // app completely. Otherwise, revoke their system privileges.
                // app completely. Otherwise, revoke their system privileges.
                for (String deletedAppName : possiblyDeletedUpdatedSystemApps) {
                for (int i = possiblyDeletedUpdatedSystemApps.size() - 1; i >= 0; --i) {
                    PackageParser.Package deletedPkg = mPackages.get(deletedAppName);
                    final String packageName = possiblyDeletedUpdatedSystemApps.get(i);
                    mSettings.removeDisabledSystemPackageLPw(deletedAppName);
                    final PackageParser.Package pkg = mPackages.get(packageName);
                    final String msg;
                    final String msg;
                    if (deletedPkg == null) {
                    // remove from the disabled system list; do this first so any future
                    // scans of this package are performed without this state
                    mSettings.removeDisabledSystemPackageLPw(packageName);
                    if (pkg == null) {
                        // should have found an update, but, we didn't; remove everything
                        // should have found an update, but, we didn't; remove everything
                        msg = "Updated system package " + deletedAppName
                        msg = "Updated system package " + packageName
                                + " no longer exists; removing its data";
                                + " no longer exists; removing its data";
                        // Actual deletion of code and data will be handled by later
                        // Actual deletion of code and data will be handled by later
                        // reconciliation step
                        // reconciliation step
                    } else {
                    } else {
                        // found an update; revoke system privileges
                        // found an update; revoke system privileges
                        msg = "Updated system package + " + deletedAppName
                        msg = "Updated system package " + packageName
                                + " no longer exists; revoking system privileges";
                                + " no longer exists; rescanning package on data";
                        // NOTE: We don't do anything special if a stub is removed from the
                        // system image. But, if we were [like removing the uncompressed
                        // version from the /data partition], this is where it'd be done.
                        // remove the package from the system and re-scan it without any
                        // special privileges
                        removePackageLI(pkg, true);
                        try {
                            final File codePath = new File(pkg.applicationInfo.getCodePath());
                            scanPackageTracedLI(codePath, 0, scanFlags, 0, null);
                        } catch (PackageManagerException e) {
                            Slog.e(TAG, "Failed to parse updated, ex-system package: "
                                    + e.getMessage());
                        }
                    }
                        // Don't do anything if a stub is removed from the system image. If
                    // one final check. if we still have a package setting [ie. it was
                        // we were to remove the uncompressed version from the /data partition,
                    // previously scanned and known to the system], but, we don't have
                        // this is where it'd be done.
                    // a package [ie. there was an error scanning it from the /data
                    // partition], completely remove the package data.
                    final PackageSetting ps = mSettings.mPackages.get(packageName);
                    if (ps != null && mPackages.get(packageName) == null) {
                        removePackageDataLIF(ps, null, null, 0, false);
                        final PackageSetting deletedPs = mSettings.mPackages.get(deletedAppName);
                        deletedPkg.applicationInfo.flags &= ~ApplicationInfo.FLAG_SYSTEM;
                        deletedPs.pkgFlags &= ~ApplicationInfo.FLAG_SYSTEM;
                    }
                    }
                    logCriticalInfo(Log.WARN, msg);
                    logCriticalInfo(Log.WARN, msg);
                }
                }