summaryrefslogtreecommitdiffstats
path: root/services/core
diff options
context:
space:
mode:
Diffstat (limited to 'services/core')
-rw-r--r--services/core/java/com/android/server/pm/PackageManagerService.java17
-rwxr-xr-xservices/core/java/com/android/server/pm/Settings.java33
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");