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

Commit 2aff9a0e authored by dhacker29's avatar dhacker29 Committed by Sam Mortimer
Browse files

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
parent ec4050a7
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -57,6 +57,9 @@ public class Build {
    /** The name of the underlying board, like "goldfish". */
    public static final String BOARD = getString("ro.product.board");

    /** The build date */
    public static final String DATE = getString("ro.build.date");

    /**
     * The name of the instruction set (CPU type + ABI convention) of native code.
     *
+4 −4
Original line number Diff line number Diff line
@@ -2538,10 +2538,10 @@ public class PackageManagerService extends IPackageManager.Stub
            File frameworkDir = new File(Environment.getRootDirectory(), "framework");
            final VersionInfo ver = mSettings.getInternalVersion();
            mIsUpgrade = !Build.FINGERPRINT.equals(ver.fingerprint);
            mIsUpgrade = !Build.DATE.equals(ver.fingerprint);
            if (mIsUpgrade) {
                logCriticalInfo(Log.INFO,
                        "Upgrading from " + ver.fingerprint + " to " + Build.FINGERPRINT);
                        "Upgrading from " + ver.fingerprint + " to " + Build.DATE);
            }
            // when upgrading from pre-M, promote system app permissions from install to runtime
@@ -2959,7 +2959,7 @@ public class PackageManagerService extends IPackageManager.Stub
                                        | Installer.FLAG_CLEAR_CODE_CACHE_ONLY);
                    }
                }
                ver.fingerprint = Build.FINGERPRINT;
                ver.fingerprint = Build.DATE;
            }
            checkDefaultBrowser();
@@ -22981,7 +22981,7 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
                    Slog.w(TAG, "Failed to scan " + ps.codePath + ": " + e.getMessage());
                }
                if (!Build.FINGERPRINT.equals(ver.fingerprint)) {
                if (!Build.DATE.equals(ver.fingerprint)) {
                    clearAppDataLIF(ps.pkg, UserHandle.USER_ALL,
                            StorageManager.FLAG_STORAGE_DE | StorageManager.FLAG_STORAGE_CE
                                    | Installer.FLAG_CLEAR_CODE_CACHE_ONLY);
+5 −5
Original line number Diff line number Diff line
@@ -343,7 +343,7 @@ final class Settings {
        public void forceCurrent() {
            sdkVersion = Build.VERSION.SDK_INT;
            databaseVersion = CURRENT_DATABASE_VERSION;
            fingerprint = Build.FINGERPRINT;
            fingerprint = Build.DATE;
        }
    }

@@ -3192,7 +3192,7 @@ final class Settings {
        // 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.DATE.equals(internal.fingerprint)) {
                for (UserInfo user : users) {
                    mRuntimePermissionsPersistence.deleteUserRuntimePermissionsFile(user.id);
                }
@@ -5257,7 +5257,7 @@ final class Settings {
        }

        public void onDefaultRuntimePermissionsGrantedLPr(int userId) {
            mFingerprints.put(userId, Build.FINGERPRINT);
            mFingerprints.put(userId, Build.DATE);
            writePermissionsForUserAsyncLPr(userId);
        }

@@ -5420,7 +5420,7 @@ final class Settings {
                serializer.endDocument();
                destination.finishWrite(out);

                if (Build.FINGERPRINT.equals(fingerprint)) {
                if (Build.DATE.equals(fingerprint)) {
                    mDefaultPermissionsGranted.put(userId, true);
                }
            // Any error while writing is fatal.
@@ -5532,7 +5532,7 @@ final class Settings {
                    case TAG_RUNTIME_PERMISSIONS: {
                        String fingerprint = parser.getAttributeValue(null, ATTR_FINGERPRINT);
                        mFingerprints.put(userId, fingerprint);
                        final boolean defaultsGranted = Build.FINGERPRINT.equals(fingerprint);
                        final boolean defaultsGranted = Build.DATE.equals(fingerprint);
                        mDefaultPermissionsGranted.put(userId, defaultsGranted);
                    } break;