Updater: Allow 22.X to 22.X+N OTAs

Change-Id: Ic4f5d94d4040bd744a372d3bb5090aba70e0688f
This commit is contained in:
LuK1337
2024-12-24 11:05:42 +01:00
parent 1d33cc3135
commit a07c2fc48e

View File

@@ -112,11 +112,25 @@ public class Utils {
return true;
}
private static boolean compareVersions(String a, String b) {
try {
int majorA = Integer.parseInt(a.split("\\.")[0]);
int minorA = Integer.parseInt(a.split("\\.")[1]);
int majorB = Integer.parseInt(b.split("\\.")[0]);
int minorB = Integer.parseInt(b.split("\\.")[1]);
return majorA == majorB && minorA >= minorB;
} catch (ArrayIndexOutOfBoundsException | NumberFormatException e) {
return false;
}
}
public static boolean canInstall(UpdateBaseInfo update) {
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));
compareVersions(
update.getVersion(), SystemProperties.get(Constants.PROP_BUILD_VERSION));
}
public static List<UpdateInfo> parseJson(File file, boolean compatibleOnly)