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

Commit 82a138ea authored by Adnan Begovic's avatar Adnan Begovic Committed by Gerrit Code Review
Browse files

pms: Skip reinstall of prebundles correctly per user.

  If you created a new user after uninstalling a few prebundled apps,
  switched to the said user, and rebooted, you would have your uninstalled
  prebundles reinstalled unconditionally.

  This is due to peekPackageLPr's implementation of checking for package
  settings not being per user, while the checks for wasPrebundledPackageInstalledLPr
  and shouldPrebundledPackageBeInstalled are.

  Now, key off of whether any package settings exist,
  is currently installed for the user, and if it was
  ever installed before before attempting the parsing process.

TICKET: CYNGNOS-2709
Change-Id: Ie3e1420cfbaedb9951d55e2a3b868a6fdd5e54c2
parent 5d52a18c
Loading
Loading
Loading
Loading
+11 −7
Original line number Diff line number Diff line
@@ -5854,12 +5854,15 @@ public class PackageManagerService extends IPackageManager.Stub {
                    }
                    synchronized (mPackages) {
                        if (DEBUG_PREBUNDLED_SCAN) Log.d(TAG,
                                "Marking prebundled packages for user " + prebundledUserId);
                                "Marking prebundled package " + pkg.packageName +
                                        " for user " + prebundledUserId);
                        mSettings.markPrebundledPackageInstalledLPr(prebundledUserId,
                                pkg.packageName);
                        // do this for every other user
                        for (UserInfo userInfo : sUserManager.getUsers(true)) {
                            if (userInfo.id == prebundledUserId) continue;
                            if (DEBUG_PREBUNDLED_SCAN) Log.d(TAG,
                                    "Marking for secondary user " + userInfo.id);
                            mSettings.markPrebundledPackageInstalledLPr(userInfo.id,
                                    pkg.packageName);
                        }
@@ -5991,14 +5994,15 @@ public class PackageManagerService extends IPackageManager.Stub {
        if ((parseFlags & PackageParser.PARSE_IS_PREBUNDLED_DIR) != 0) {
            synchronized (mPackages) {
                PackageSetting existingSettings = mSettings.peekPackageLPr(pkg.packageName);
                if (mSettings.wasPrebundledPackageInstalledLPr(user.getIdentifier()
                        , pkg.packageName) && existingSettings == null) {
                    // The prebundled app was installed at some point in time, but now it is
                    // gone.  Assume that the user uninstalled it intentionally: do not reinstall.
                boolean isInstalledForUser = (existingSettings != null
                        && existingSettings.getInstalled(user.getIdentifier()));
                if (mSettings.wasPrebundledPackageInstalledLPr(user.getIdentifier(),
                        pkg.packageName) && !isInstalledForUser) {
                    // The prebundled app was installed at some point for the user and isn't
                    // currently installed for the user, skip reinstalling it
                    throw new PackageManagerException(INSTALL_FAILED_UNINSTALLED_PREBUNDLE,
                            "skip reinstall for " + pkg.packageName);
                } else if (existingSettings == null &&
                        !mSettings.shouldPrebundledPackageBeInstalled(mContext.getResources(),
                } else if (!mSettings.shouldPrebundledPackageBeInstalled(mContext.getResources(),
                                pkg.packageName, mCustomResources)) {
                    // The prebundled app is not needed for the default mobile country code,
                    // skip installing it