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

Commit b7ae9d7a 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

Change-Id: If0eb969ba509981f9209ffa37a949d9042ef4c2a
parent 7148db43
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -132,7 +132,7 @@ public final class SystemUpdateInfo implements Parcelable {
        out.startTag(null, tag);
        out.attributeLong(null, ATTR_RECEIVED_TIME, mReceivedTime);
        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);
    }

@@ -141,7 +141,7 @@ public final class SystemUpdateInfo implements Parcelable {
    public static SystemUpdateInfo readFromXml(TypedXmlPullParser parser) {
        // If an OTA has been applied (build fingerprint has changed), discard stale info.
        final String buildFingerprint = parser.getAttributeValue(null, ATTR_ORIGINAL_BUILD );
        if (!Build.FINGERPRINT.equals(buildFingerprint)) {
        if (!Build.VERSION.INCREMENTAL.equals(buildFingerprint)) {
            return null;
        }
        try {
+1 −1
Original line number Diff line number Diff line
@@ -678,7 +678,7 @@ class UserController implements Handler.Callback {
        // purposefully block sending BOOT_COMPLETED until after all
        // PRE_BOOT receivers are finished to avoid ANR'ing apps
        final UserInfo info = getUserInfo(userId);
        if (!Objects.equals(info.lastLoggedInFingerprint, Build.FINGERPRINT)
        if (!Objects.equals(info.lastLoggedInFingerprint, Build.VERSION.INCREMENTAL)
                || SystemProperties.getBoolean("persist.pm.mock-upgrade", false)) {
            // Suppress double notifications for managed profiles that
            // were unlocked automatically as part of their parent user
+13 −11
Original line number Diff line number Diff line
@@ -6766,7 +6766,7 @@ public class PackageManagerService extends IPackageManager.Stub
        }
        PackageManagerService m = new PackageManagerService(injector, onlyCore, factoryTest,
                Build.FINGERPRINT, Build.IS_ENG, Build.IS_USERDEBUG, Build.VERSION.SDK_INT,
                Build.VERSION.INCREMENTAL, Build.IS_ENG, Build.IS_USERDEBUG, Build.VERSION.SDK_INT,
                Build.VERSION.INCREMENTAL);
        t.traceEnd(); // "create package manager"
@@ -7255,7 +7255,7 @@ public class PackageManagerService extends IPackageManager.Stub
                    !buildFingerprint.equals(ver.fingerprint);
            if (mIsUpgrade) {
                PackageManagerServiceUtils.logCriticalInfo(Log.INFO,
                        "Upgrading from " + ver.fingerprint + " to " + Build.FINGERPRINT);
                        "Upgrading from " + ver.fingerprint + " to " + Build.VERSION.INCREMENTAL);
            }
            // when upgrading from pre-M, promote system app permissions from install to runtime
@@ -7643,8 +7643,9 @@ public class PackageManagerService extends IPackageManager.Stub
            // allow...  it would be nice to have some better way to handle
            // this situation.
            if (mIsUpgrade) {
                Slog.i(TAG, "Build fingerprint changed from " + ver.fingerprint + " to "
                        + Build.FINGERPRINT + "; regranting permissions for internal storage");
                Slog.i(TAG, "Build incremental version changed from " + ver.fingerprint + " to "
                        + Build.VERSION.INCREMENTAL +
                        "; regranting permissions for internal storage");
            }
            mPermissionManager.onStorageVolumeMounted(
                    StorageManager.UUID_PRIVATE_INTERNAL, mIsUpgrade);
@@ -7716,7 +7717,7 @@ public class PackageManagerService extends IPackageManager.Stub
            // across OTAs and are used to drive profile verification (post OTA) and
            // profile compilation (without waiting to collect a fresh set of profiles).
            if (mIsUpgrade && !mOnlyCore) {
                Slog.i(TAG, "Build fingerprint changed; clearing code caches");
                Slog.i(TAG, "Build incremental version changed; clearing code caches");
                for (int i = 0; i < packageSettings.size(); i++) {
                    final PackageSetting ps = packageSettings.valueAt(i);
                    if (Objects.equals(StorageManager.UUID_PRIVATE_INTERNAL, ps.volumeUuid)) {
@@ -7727,7 +7728,7 @@ public class PackageManagerService extends IPackageManager.Stub
                                        | Installer.FLAG_CLEAR_APP_DATA_KEEP_ART_PROFILES);
                    }
                }
                ver.fingerprint = Build.FINGERPRINT;
                ver.fingerprint = Build.VERSION.INCREMENTAL;
            }
            // Legacy existing (installed before Q) non-system apps to hide
@@ -8141,7 +8142,7 @@ public class PackageManagerService extends IPackageManager.Stub
        // 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"
                : SystemProperties.digestOf("ro.build.fingerprint");
                : SystemProperties.digestOf("ro.build.version.incremental");
        // Reconcile cache directories, keeping only what we'd actually use.
        for (File cacheDir : FileUtils.listFilesOrEmpty(cacheBaseDir)) {
@@ -25382,7 +25383,7 @@ public class PackageManagerService extends IPackageManager.Stub
                    Slog.w(TAG, "Failed to scan " + ps.getPath() + ": " + e.getMessage());
                }
                if (!Build.FINGERPRINT.equals(ver.fingerprint)) {
                if (!Build.VERSION.INCREMENTAL.equals(ver.fingerprint)) {
                    clearAppDataLIF(ps.pkg, UserHandle.USER_ALL, FLAG_STORAGE_DE | FLAG_STORAGE_CE
                            | FLAG_STORAGE_EXTERNAL | Installer.FLAG_CLEAR_CODE_CACHE_ONLY
                            | Installer.FLAG_CLEAR_APP_DATA_KEEP_ART_PROFILES);
@@ -25415,10 +25416,11 @@ public class PackageManagerService extends IPackageManager.Stub
        }
        synchronized (mLock) {
            final boolean isUpgrade = !Build.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 " + Build.FINGERPRINT + "; regranting permissions for "
                logCriticalInfo(Log.INFO, "Build incremental version changed from "
                        + ver.fingerprint
                        + " to " + Build.VERSION.INCREMENTAL + "; regranting permissions for "
                        + volumeUuid);
            }
            mPermissionManager.onStorageVolumeMounted(volumeUuid, isUpgrade);
+3 −3
Original line number Diff line number Diff line
@@ -433,7 +433,7 @@ public final class Settings implements Watchable, Snappable {
        public void forceCurrent() {
            sdkVersion = Build.VERSION.SDK_INT;
            databaseVersion = CURRENT_DATABASE_VERSION;
            fingerprint = Build.FINGERPRINT;
            fingerprint = Build.VERSION.INCREMENTAL;
        }
    }

@@ -2972,7 +2972,7 @@ public final class Settings implements Watchable, Snappable {
        // on update drop the files before loading them.
        if (PackageManagerService.CLEAR_RUNTIME_PERMISSIONS_ON_UPGRADE) {
            final VersionInfo internal = getInternalVersion();
            if (!Build.FINGERPRINT.equals(internal.fingerprint)) {
            if (!Build.VERSION.INCREMENTAL.equals(internal.fingerprint)) {
                for (UserInfo user : users) {
                    mRuntimePermissionsPersistence.deleteUserRuntimePermissionsFile(user.id);
                }
@@ -5346,7 +5346,7 @@ public final class Settings implements Watchable, Snappable {
        }

        private String getExtendedFingerprint(long version) {
            return Build.FINGERPRINT + "?pc_version=" + version;
            return Build.VERSION.INCREMENTAL + "?pc_version=" + version;
        }

        public void writeStateForUserAsyncLPr(int userId) {
+1 −1
Original line number Diff line number Diff line
@@ -5225,7 +5225,7 @@ public class ShortcutService extends IShortcutService.Stub {

    // Injection point.
    String injectBuildFingerprint() {
        return Build.FINGERPRINT;
        return Build.VERSION.INCREMENTAL;
    }

    final void wtf(String message) {
Loading