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

Commit 22635b87 authored by dhacker29's avatar dhacker29 Committed by Michael Bestas
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 a6719454
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -57,6 +57,12 @@ public class Build {
    /** The name of the underlying board, like "goldfish". */
    /** The name of the underlying board, like "goldfish". */
    public static final String BOARD = getString("ro.product.board");
    public static final String BOARD = getString("ro.product.board");


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

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


@@ -3201,7 +3201,7 @@ final class Settings {
        // on update drop the files before loading them.
        // on update drop the files before loading them.
        if (PackageManagerService.CLEAR_RUNTIME_PERMISSIONS_ON_UPGRADE) {
        if (PackageManagerService.CLEAR_RUNTIME_PERMISSIONS_ON_UPGRADE) {
            final VersionInfo internal = getInternalVersion();
            final VersionInfo internal = getInternalVersion();
            if (!Build.FINGERPRINT.equals(internal.fingerprint)) {
            if (!Build.DATE.equals(internal.fingerprint)) {
                for (UserInfo user : users) {
                for (UserInfo user : users) {
                    mRuntimePermissionsPersistence.deleteUserRuntimePermissionsFile(user.id);
                    mRuntimePermissionsPersistence.deleteUserRuntimePermissionsFile(user.id);
                }
                }
@@ -5269,7 +5269,7 @@ final class Settings {
        }
        }


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


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


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