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

Commit 7bb79243 authored by Song Chun Fan's avatar Song Chun Fan Committed by Automerger Merge Worker
Browse files

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

parents e9697e91 2d62797e
Loading
Loading
Loading
Loading
+8 −1
Original line number Original line Diff line number Diff line
@@ -3837,13 +3837,20 @@ final class InstallPackageHelper {
                && !pkgSetting.getPathString().equals(parsedPackage.getPath());
                && !pkgSetting.getPathString().equals(parsedPackage.getPath());
        final boolean newPkgVersionGreater = pkgAlreadyExists
        final boolean newPkgVersionGreater = pkgAlreadyExists
                && parsedPackage.getLongVersionCode() > pkgSetting.getVersionCode();
                && parsedPackage.getLongVersionCode() > pkgSetting.getVersionCode();
        final boolean newSharedUserSetting = pkgAlreadyExists
                && (initialScanRequest.mOldSharedUserSetting
                != initialScanRequest.mSharedUserSetting);
        final boolean isSystemPkgBetter = scanSystemPartition && isSystemPkgUpdated
        final boolean isSystemPkgBetter = scanSystemPartition && isSystemPkgUpdated
                && newPkgChangedPaths && newPkgVersionGreater;
                && newPkgChangedPaths && (newPkgVersionGreater || newSharedUserSetting);
        if (isSystemPkgBetter) {
        if (isSystemPkgBetter) {
            // The version of the application on /system is greater than the version on
            // The version of the application on /system is greater than the version on
            // /data. Switch back to the application on /system.
            // /data. Switch back to the application on /system.
            // It's safe to assume the application on /system will correctly scan. If not,
            // It's safe to assume the application on /system will correctly scan. If not,
            // there won't be a working copy of the application.
            // 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) {
            synchronized (mPm.mLock) {
                // just remove the loaded entries from package lists
                // just remove the loaded entries from package lists
                mPm.mPackages.remove(pkgSetting.getPackageName());
                mPm.mPackages.remove(pkgSetting.getPackageName());