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

Unverified Commit e41bc38e authored by dhacker29's avatar dhacker29 Committed by Michael Bestas
Browse files

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

Squash of:

Author: dhacker29 <dhackerdvm@gmail.com>
Date:   Tue Nov 24 01:53:47 2015 -0500
    Core: Use ro.build.date to signal mIsUpgrade
    M: We use a static fingerprint that is only changed when a new OEM build is released, so
       every flash shows Android is starting instead of upgrading.  This will fix that.
    N: even though we dont have the dexopt sceen on N, this is still needed to delete the
       correct caches, and grant/deny specific runtime permissions like a true oem update
       would do.
       Updated for Nougat By: BeansTown106
    Change-Id: I0e3ed5c8f0351e48944432ae6a0c5194ddeff1fa

Author: Sam Mortimer <sam@mortimer.me.uk>
Date:   Fri Sep 28 13:45:00 2018 -0700
    fw/b UserManagerService: Use ro.build.date to signal upgrades
    *) We changed PackageManagerService to use Build.DATE instead of
       Build.FINGERPRINT to detect upgrade.  Do the same for
       UserManagerService.
    *) Affects generation of preboot intent and app data migration.
    Change-Id: I56887b7ca842afdcf3cf84b27b4c04667cf43307

Author: Wang Han <416810799@qq.com>
Date:   Sat Dec 29 23:33:20 2018 +0800
    ShortcutService: Use ro.build.date to signal package scanning
     * Affects system apps scanning.
    Change-Id: I5f6d6647929f5b5ae7e820b18e95bf5ed2ec8d1c

Author: maxwen <max.weninger@gmail.com>
Date:   Tue Nov 19 01:02:01 2019 +0100
    base: Use ro.build.date to clear cache dirs on update
    instead of using ro.build.fingerprint we explictly need to use ro.build.date
    Change-Id: Ib3e80e58eb8c9a21c108e9f5cd2dbdb7ada8e3a4

Author: maxwen <max.weninger@gmail.com>
Date:   Wed Oct 28 07:07:10 2020 -0400
    One more Build.FINGERPRINT to Build.DATE change
    Change-Id: I13dbf3d7f6587d3fcd6591cc0f861b34b6d5561c

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: If0eb969ba509981f9209ffa37a949d9042ef4c2a
parent 7fbd0ccd
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -133,7 +133,7 @@ public final class SystemUpdateInfo implements Parcelable {
        out.startTag(null, tag);
        out.startTag(null, tag);
        out.attributeLong(null, ATTR_RECEIVED_TIME, mReceivedTime);
        out.attributeLong(null, ATTR_RECEIVED_TIME, mReceivedTime);
        out.attributeInt(null, ATTR_SECURITY_PATCH_STATE, mSecurityPatchState);
        out.attributeInt(null, ATTR_SECURITY_PATCH_STATE, mSecurityPatchState);
        out.attribute(null, ATTR_ORIGINAL_BUILD , Build.FINGERPRINT);
        out.attribute(null, ATTR_ORIGINAL_BUILD , Build.VERSION.INCREMENTAL);
        out.endTag(null, tag);
        out.endTag(null, tag);
    }
    }


@@ -142,7 +142,7 @@ public final class SystemUpdateInfo implements Parcelable {
    public static SystemUpdateInfo readFromXml(TypedXmlPullParser parser) {
    public static SystemUpdateInfo readFromXml(TypedXmlPullParser parser) {
        // If an OTA has been applied (build fingerprint has changed), discard stale info.
        // If an OTA has been applied (build fingerprint has changed), discard stale info.
        final String buildFingerprint = parser.getAttributeValue(null, ATTR_ORIGINAL_BUILD );
        final String buildFingerprint = parser.getAttributeValue(null, ATTR_ORIGINAL_BUILD );
        if (!Build.FINGERPRINT.equals(buildFingerprint)) {
        if (!Build.VERSION.INCREMENTAL.equals(buildFingerprint)) {
            return null;
            return null;
        }
        }
        try {
        try {
+1 −1
Original line number Original line Diff line number Diff line
@@ -131,7 +131,7 @@ public class PackagePartitions {
            final String partitionName = SYSTEM_PARTITIONS.get(i).getName();
            final String partitionName = SYSTEM_PARTITIONS.get(i).getName();
            digestProperties[i] = "ro." + partitionName + ".build.fingerprint";
            digestProperties[i] = "ro." + partitionName + ".build.fingerprint";
        }
        }
        digestProperties[SYSTEM_PARTITIONS.size()] = "ro.build.fingerprint"; // build fingerprint
        digestProperties[SYSTEM_PARTITIONS.size()] = "ro.build.version.incremental";
        return SystemProperties.digestOf(digestProperties);
        return SystemProperties.digestOf(digestProperties);
    }
    }


+2 −2
Original line number Original line Diff line number Diff line
@@ -96,7 +96,7 @@ public class AppWidgetXmlUtil {
        out.attributeInt(null, ATTR_WIDGET_FEATURES, info.widgetFeatures);
        out.attributeInt(null, ATTR_WIDGET_FEATURES, info.widgetFeatures);
        out.attributeInt(null, ATTR_DESCRIPTION_RES, info.descriptionRes);
        out.attributeInt(null, ATTR_DESCRIPTION_RES, info.descriptionRes);
        out.attributeBoolean(null, ATTR_PROVIDER_INHERITANCE, info.isExtendedFromAppWidgetProvider);
        out.attributeBoolean(null, ATTR_PROVIDER_INHERITANCE, info.isExtendedFromAppWidgetProvider);
        out.attribute(null, ATTR_OS_FINGERPRINT, Build.FINGERPRINT);
        out.attribute(null, ATTR_OS_FINGERPRINT, Build.VERSION.INCREMENTAL);
    }
    }


    /**
    /**
@@ -107,7 +107,7 @@ public class AppWidgetXmlUtil {
            @NonNull final TypedXmlPullParser parser) {
            @NonNull final TypedXmlPullParser parser) {
        Objects.requireNonNull(parser);
        Objects.requireNonNull(parser);
        final String fingerprint = parser.getAttributeValue(null, ATTR_OS_FINGERPRINT);
        final String fingerprint = parser.getAttributeValue(null, ATTR_OS_FINGERPRINT);
        if (!Build.FINGERPRINT.equals(fingerprint)) {
        if (!Build.VERSION.INCREMENTAL.equals(fingerprint)) {
            return null;
            return null;
        }
        }
        final AppWidgetProviderInfo info = new AppWidgetProviderInfo();
        final AppWidgetProviderInfo info = new AppWidgetProviderInfo();
+3 −2
Original line number Original line Diff line number Diff line
@@ -2085,7 +2085,8 @@ public class PackageManagerService implements PackageSender, TestUtilityService
            if (mIsUpgrade) {
            if (mIsUpgrade) {
                PackageManagerServiceUtils.logCriticalInfo(Log.INFO,
                PackageManagerServiceUtils.logCriticalInfo(Log.INFO,
                        "Upgrading from " + ver.fingerprint + " (" + ver.buildFingerprint + ") to "
                        "Upgrading from " + ver.fingerprint + " (" + ver.buildFingerprint + ") to "
                                + PackagePartitions.FINGERPRINT + " (" + Build.FINGERPRINT + ")");
                                + PackagePartitions.FINGERPRINT
                                + " (" + Build.VERSION.INCREMENTAL + ")");
            }
            }


            mInitAppsHelper = new InitAppsHelper(this, mApexManager, mInstallPackageHelper,
            mInitAppsHelper = new InitAppsHelper(this, mApexManager, mInstallPackageHelper,
@@ -2254,7 +2255,7 @@ public class PackageManagerService implements PackageSender, TestUtilityService
                                        | Installer.FLAG_CLEAR_APP_DATA_KEEP_ART_PROFILES);
                                        | Installer.FLAG_CLEAR_APP_DATA_KEEP_ART_PROFILES);
                    }
                    }
                }
                }
                ver.buildFingerprint = Build.FINGERPRINT;
                ver.buildFingerprint = Build.VERSION.INCREMENTAL;
                ver.fingerprint = PackagePartitions.FINGERPRINT;
                ver.fingerprint = PackagePartitions.FINGERPRINT;
            }
            }


+1 −2
Original line number Original line Diff line number Diff line
@@ -1475,8 +1475,6 @@ public class PackageManagerServiceUtils {
        // that starts with "eng." to signify that this is an engineering build and not
        // that starts with "eng." to signify that this is an engineering build and not
        // destined for release.
        // destined for release.
        if (isUserDebugBuild && incrementalVersion.startsWith("eng.")) {
        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"
            // 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
            // 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,
            // in general and should not be used for production changes. In this specific case,
@@ -1484,6 +1482,7 @@ public class PackageManagerServiceUtils {
            File frameworkDir =
            File frameworkDir =
                    new File(Environment.getRootDirectory(), "framework");
                    new File(Environment.getRootDirectory(), "framework");
            if (cacheDir.lastModified() < frameworkDir.lastModified()) {
            if (cacheDir.lastModified() < frameworkDir.lastModified()) {
                Slog.w(TAG, "Wiping cache directory because the system partition changed.");
                FileUtils.deleteContents(cacheBaseDir);
                FileUtils.deleteContents(cacheBaseDir);
                cacheDir = FileUtils.createDir(cacheBaseDir, cacheName);
                cacheDir = FileUtils.createDir(cacheBaseDir, cacheName);
            }
            }
Loading