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

Commit eaf1fa8f authored by LuK1337's avatar LuK1337 Committed by Gabriele M
Browse files

Updater: Add property that allows us to downgrade

Change-Id: I6916639f05c52ae198f0d1656deb23ee5186907f
parent 26a4c7a1
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ public final class Constants {
    public static final String PROP_DEVICE = "ro.cm.device";
    public static final String PROP_NEXT_DEVICE = "ro.updater.next_device";
    public static final String PROP_RELEASE_TYPE = "ro.cm.releasetype";
    public static final String PROP_UPDATER_ALLOW_DOWNGRADING = "cm.updater.allow_downgrading";
    public static final String PROP_UPDATER_URI = "cm.updater.uri";

    public static final String PREF_INSTALL_OLD_TIMESTAMP = "install_old_timestamp";
+4 −2
Original line number Diff line number Diff line
@@ -94,7 +94,8 @@ public class Utils {
    }

    public static boolean isCompatible(UpdateBaseInfo update) {
        if (update.getTimestamp() < SystemProperties.getLong(Constants.PROP_BUILD_DATE, 0)) {
        if (!SystemProperties.getBoolean(Constants.PROP_UPDATER_ALLOW_DOWNGRADING, false) &&
                update.getTimestamp() < SystemProperties.getLong(Constants.PROP_BUILD_DATE, 0)) {
            Log.d(TAG, update.getName() + " is older than current build");
            return false;
        }
@@ -106,7 +107,8 @@ public class Utils {
    }

    public static boolean canInstall(UpdateBaseInfo update) {
        return update.getTimestamp() >= SystemProperties.getLong(Constants.PROP_BUILD_DATE, 0) &&
        return (SystemProperties.getBoolean(Constants.PROP_UPDATER_ALLOW_DOWNGRADING, false) ||
                update.getTimestamp() >= SystemProperties.getLong(Constants.PROP_BUILD_DATE, 0)) &&
                update.getVersion().equalsIgnoreCase(
                        SystemProperties.get(Constants.PROP_BUILD_VERSION));
    }