Merge "[Bugfix]Switch back to the application on /system when UID and path changed" am: 2d62797e6a

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2319751

Change-Id: I4fa6d5f32974887fbc90d5be9f78064c9960cec6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Song Chun Fan
2022-12-01 15:54:16 +00:00
committed by Automerger Merge Worker

View File

@@ -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());