diff options
author | Song Chun Fan <schfan@google.com> | 2022-12-01 15:33:14 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2022-12-01 15:33:14 +0000 |
commit | 2d62797e6a7b80cdf8ee41a63401c3a452fdde68 (patch) | |
tree | d0f321f23de815493b679c275b7c2eae8b8ee4b8 | |
parent | a8e835c4da5dce58546cae4d0090ab9da1806967 (diff) | |
parent | 26222f03ef27746971bd0b47205a52d6e603bff6 (diff) | |
download | base-2d62797e6a7b80cdf8ee41a63401c3a452fdde68.tar.gz |
Merge "[Bugfix]Switch back to the application on /system when UID and path changed"
-rw-r--r-- | services/core/java/com/android/server/pm/InstallPackageHelper.java | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/services/core/java/com/android/server/pm/InstallPackageHelper.java b/services/core/java/com/android/server/pm/InstallPackageHelper.java index 7da5f51bcbc2..3816b07042dc 100644 --- a/services/core/java/com/android/server/pm/InstallPackageHelper.java +++ b/services/core/java/com/android/server/pm/InstallPackageHelper.java @@ -3837,13 +3837,20 @@ final class InstallPackageHelper { && !pkgSetting.getPathString().equals(parsedPackage.getPath()); final boolean newPkgVersionGreater = pkgAlreadyExists && parsedPackage.getLongVersionCode() > pkgSetting.getVersionCode(); + final boolean newSharedUserSetting = pkgAlreadyExists + && (initialScanRequest.mOldSharedUserSetting + != initialScanRequest.mSharedUserSetting); final boolean isSystemPkgBetter = scanSystemPartition && isSystemPkgUpdated - && newPkgChangedPaths && newPkgVersionGreater; + && newPkgChangedPaths && (newPkgVersionGreater || newSharedUserSetting); if (isSystemPkgBetter) { // The version of the application on /system is greater than the version on // /data. Switch back to the application on /system. // It's safe to assume the application on /system will correctly scan. If not, // there won't be a working copy of the application. + // Also, if the sharedUserSetting of the application on /system is different + // from the sharedUserSetting on /data, switch back to the application on /system. + // We should trust the sharedUserSetting on /system, even if the application + // version on /system is smaller than the version on /data. synchronized (mPm.mLock) { // just remove the loaded entries from package lists mPm.mPackages.remove(pkgSetting.getPackageName()); |