diff options
author | Adnan Begovic <adnan@cyngn.com> | 2016-05-11 12:43:57 -0700 |
---|---|---|
committer | Adnan Begovic <adnan@cyngn.com> | 2016-05-17 12:12:06 -0700 |
commit | 105c6f5cd30eafd73d82eb25e01765d9ed4e2bfc (patch) | |
tree | c88aec09729d478274231be491df248f1f923101 /services/core | |
parent | a54a47946f98b1d9a434d3889a409a384c80282b (diff) | |
download | frameworks_base-105c6f5cd30eafd73d82eb25e01765d9ed4e2bfc.zip frameworks_base-105c6f5cd30eafd73d82eb25e01765d9ed4e2bfc.tar.gz frameworks_base-105c6f5cd30eafd73d82eb25e01765d9ed4e2bfc.tar.bz2 |
pm: Avoid installing prebundle to other users that were uninstalled by owner.
Otherwise the copied app data (since these are treated similarily to system
packages on user creation) would be purged of the granted permissions in
packages.xml.
Also, it just doesn't make sense from a users perspective.
Change-Id: I9a72eb9a9f0bea9401e90daa86c8fa32e866c380
TICKET: OPO-695
Diffstat (limited to 'services/core')
-rw-r--r-- | services/core/java/com/android/server/pm/PackageManagerService.java | 17 | ||||
-rwxr-xr-x | services/core/java/com/android/server/pm/Settings.java | 33 |
2 files changed, 41 insertions, 9 deletions
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index 068df4b..0e174c3 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -5994,16 +5994,17 @@ public class PackageManagerService extends IPackageManager.Stub { if ((parseFlags & PackageParser.PARSE_IS_PREBUNDLED_DIR) != 0) { synchronized (mPackages) { PackageSetting existingSettings = mSettings.peekPackageLPr(pkg.packageName); - 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 + + if (!mSettings.shouldPrebundledPackageBeInstalledForUserLPr(existingSettings, + user.getIdentifier(), pkg.packageName)) { + // The prebundled app was installed at some point for the owner and isn't + // currently installed for the owner, dont install it for a new user + // OR the prebundled app was installed for the user at some point and isn't + // current installed for the user, so skip reinstalling it throw new PackageManagerException(INSTALL_FAILED_UNINSTALLED_PREBUNDLE, "skip reinstall for " + pkg.packageName); - } else if (!mSettings.shouldPrebundledPackageBeInstalled(mContext.getResources(), - pkg.packageName, mCustomResources)) { + } else if (!mSettings.shouldPrebundledPackageBeInstalledForRegion( + mContext.getResources(), pkg.packageName, mCustomResources)) { // The prebundled app is not needed for the default mobile country code, // skip installing it throw new PackageManagerException(INSTALL_FAILED_REGION_LOCKED_PREBUNDLE, diff --git a/services/core/java/com/android/server/pm/Settings.java b/services/core/java/com/android/server/pm/Settings.java index 502afa0..38478c2 100755 --- a/services/core/java/com/android/server/pm/Settings.java +++ b/services/core/java/com/android/server/pm/Settings.java @@ -2524,7 +2524,7 @@ final class Settings { return mPrebundledPackages.get(userId).contains(packageName); } - boolean shouldPrebundledPackageBeInstalled(Resources res, String packageName, + boolean shouldPrebundledPackageBeInstalledForRegion(Resources res, String packageName, Resources configuredResources) { // Default fallback on lack of bad package if (TextUtils.isEmpty(packageName)) { @@ -2557,6 +2557,37 @@ final class Settings { return !ArrayUtils.contains(prebundledArray, packageName); } + boolean shouldPrebundledPackageBeInstalledForUserLPr(PackageSetting existingSettings, + int userIdentifier, String packageName) { + + // Check if package installed for the user + final boolean isInstalledForUser = (existingSettings != null + && existingSettings.getInstalled(userIdentifier)); + + // Check if package installed for the owner + final boolean isInstalledForOwner = (existingSettings != null + && existingSettings.getInstalled(UserHandle.USER_OWNER)); + + // Check if the user is the owner + final boolean isOwner = userIdentifier == UserHandle.USER_OWNER; + + // If the given user is not the owner, and the prebundle was installed for the owner + // but is no longer installed, and isn't currently installed for the user, + // skip installing it. + if (!isOwner && wasPrebundledPackageInstalledLPr(UserHandle.USER_OWNER, packageName) + && !isInstalledForOwner && !isInstalledForUser) { + return false; + } + + // If the given package was installed for the user and isn't currently, skip reinstalling it + if (wasPrebundledPackageInstalledLPr(userIdentifier, packageName) && + !isInstalledForUser) { + return false; + } + + return true; + } + void writeDisabledSysPackageLPr(XmlSerializer serializer, final PackageSetting pkg) throws java.io.IOException { serializer.startTag(null, "updated-package"); |