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

Commit 070dd601 authored by maxwen's avatar maxwen Committed by LuK1337
Browse files

fixup! fw/b: Use ro.build.version.incremental to signal OTA upgrades

Squash of:

Author: maxwen <max.weninger@gmail.com>
Date:   Thu Sep 1 16:55:03 2022 +0200
    base: fix pm cache directory invalidate on new builds
    This was before in PackageManagerService.jave like
     final String cacheName = FORCE_PACKAGE_PARSED_CACHE_ENABLED ? "debug"
                    : SystemProperties.digestOf(ro.build.version.incremental);
    Now they switched to PackagePartitions.FINGERPRINT which broke
    the invalidate of the cache for new builds
    also add a missed usage of changed fingerprint in StorageEventHelper.java
    Change-Id: I6cca07659a8e7a4f99ed58761dc727e0e5e20ef8

Change-Id: I6cca07659a8e7a4f99ed58761dc727e0e5e20ef8
parent 8d87e941
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ public class AppWidgetXmlUtil {
        out.attributeInt(null, ATTR_WIDGET_CATEGORY, info.widgetCategory);
        out.attributeInt(null, ATTR_WIDGET_FEATURES, info.widgetFeatures);
        out.attributeInt(null, ATTR_DESCRIPTION_RES, info.descriptionRes);
        out.attribute(null, ATTR_OS_FINGERPRINT, Build.FINGERPRINT);
        out.attribute(null, ATTR_OS_FINGERPRINT, Build.VERSION.INCREMENTAL);
    }

    /**
@@ -104,7 +104,7 @@ public class AppWidgetXmlUtil {
            @NonNull final TypedXmlPullParser parser) {
        Objects.requireNonNull(parser);
        final String fingerprint = parser.getAttributeValue(null, ATTR_OS_FINGERPRINT);
        if (!Build.FINGERPRINT.equals(fingerprint)) {
        if (!Build.VERSION.INCREMENTAL.equals(fingerprint)) {
            return null;
        }
        final AppWidgetProviderInfo info = new AppWidgetProviderInfo();
+2 −3
Original line number Diff line number Diff line
@@ -1321,7 +1321,7 @@ public class PackageManagerServiceUtils {
        // identify cached items. In particular, changing the value of certain
        // feature flags should cause us to invalidate any caches.
        final String cacheName = FORCE_PACKAGE_PARSED_CACHE_ENABLED ? "debug"
                : PackagePartitions.FINGERPRINT;
                : Build.VERSION.INCREMENTAL;

        // Reconcile cache directories, keeping only what we'd actually use.
        for (File cacheDir : FileUtils.listFilesOrEmpty(cacheBaseDir)) {
@@ -1351,8 +1351,6 @@ public class PackageManagerServiceUtils {
        // that starts with "eng." to signify that this is an engineering build and not
        // destined for release.
        if (isUserDebugBuild && incrementalVersion.startsWith("eng.")) {
            Slog.w(TAG, "Wiping cache directory because the system partition changed.");

            // Heuristic: If the /system directory has been modified recently due to an "adb sync"
            // or a regular make, then blow away the cache. Note that mtimes are *NOT* reliable
            // in general and should not be used for production changes. In this specific case,
@@ -1360,6 +1358,7 @@ public class PackageManagerServiceUtils {
            File frameworkDir =
                    new File(Environment.getRootDirectory(), "framework");
            if (cacheDir.lastModified() < frameworkDir.lastModified()) {
                Slog.w(TAG, "Wiping cache directory because the system partition changed.");
                FileUtils.deleteContents(cacheBaseDir);
                cacheDir = FileUtils.createDir(cacheBaseDir, cacheName);
            }
+6 −4
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.content.pm.PackageManager;
import android.content.pm.PackagePartitions;
import android.content.pm.UserInfo;
import android.content.pm.VersionedPackage;
import android.os.Build;
import android.os.Environment;
import android.os.FileUtils;
import android.os.UserHandle;
@@ -166,7 +167,7 @@ public final class StorageEventHelper extends StorageEventListener {
                    Slog.w(TAG, "Failed to scan " + ps.getPath() + ": " + e.getMessage());
                }

                if (!PackagePartitions.FINGERPRINT.equals(ver.fingerprint)) {
                if (!Build.VERSION.INCREMENTAL.equals(ver.fingerprint)) {
                    appDataHelper.clearAppDataLIF(
                            ps.getPkg(), UserHandle.USER_ALL, FLAG_STORAGE_DE | FLAG_STORAGE_CE
                            | FLAG_STORAGE_EXTERNAL | Installer.FLAG_CLEAR_CODE_CACHE_ONLY
@@ -204,10 +205,11 @@ public final class StorageEventHelper extends StorageEventListener {
        }

        synchronized (mPm.mLock) {
            final boolean isUpgrade = !PackagePartitions.FINGERPRINT.equals(ver.fingerprint);
            final boolean isUpgrade = !Build.VERSION.INCREMENTAL.equals(ver.fingerprint);
            if (isUpgrade) {
                logCriticalInfo(Log.INFO, "Build fingerprint changed from " + ver.fingerprint
                        + " to " + PackagePartitions.FINGERPRINT + "; regranting permissions for "
                logCriticalInfo(Log.INFO, "Build incremental version changed from "
                        + ver.fingerprint
                        + " to " + Build.VERSION.INCREMENTAL + "; regranting permissions for "
                        + volumeUuid);
            }
            mPm.mPermissionManager.onStorageVolumeMounted(volumeUuid, isUpgrade);