diff options
author | LuK1337 <priv.luk@gmail.com> | 2018-06-09 00:10:59 +0200 |
---|---|---|
committer | Gabriele M <moto.falcon.git@gmail.com> | 2018-07-14 18:31:33 +0200 |
commit | 460cb8751030f260474f37b2caf9010b05e73978 (patch) | |
tree | 8e93a933d892dc13135a4a9897db6c6fb4ec7710 | |
parent | 608789ff3675ef02d43f24a53081f5e8c30c829a (diff) | |
download | android_packages_apps_Updater-460cb8751030f260474f37b2caf9010b05e73978.tar.gz android_packages_apps_Updater-460cb8751030f260474f37b2caf9010b05e73978.tar.bz2 android_packages_apps_Updater-460cb8751030f260474f37b2caf9010b05e73978.zip |
Updater: Add property that allows us to downgrade
Change-Id: I6916639f05c52ae198f0d1656deb23ee5186907f
-rw-r--r-- | src/org/lineageos/updater/misc/Constants.java | 1 | ||||
-rw-r--r-- | src/org/lineageos/updater/misc/Utils.java | 6 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/org/lineageos/updater/misc/Constants.java b/src/org/lineageos/updater/misc/Constants.java index 521e4ff..5bc0e8b 100644 --- a/src/org/lineageos/updater/misc/Constants.java +++ b/src/org/lineageos/updater/misc/Constants.java @@ -39,6 +39,7 @@ public final class Constants { public static final String PROP_DEVICE = "ro.lineage.device"; public static final String PROP_NEXT_DEVICE = "ro.updater.next_device"; public static final String PROP_RELEASE_TYPE = "ro.lineage.releasetype"; + public static final String PROP_UPDATER_ALLOW_DOWNGRADING = "lineage.updater.allow_downgrading"; public static final String PROP_UPDATER_URI = "lineage.updater.uri"; public static final String PREF_INSTALL_OLD_TIMESTAMP = "install_old_timestamp"; diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index a053aab..3eb256e 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -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)); } |