diff --git a/src/org/lineageos/updater/controller/UpdaterService.java b/src/org/lineageos/updater/controller/UpdaterService.java index c0354f92e2835d7f24c73ebe9f10d92c57170024..09f646e11cde66000a64a797791c1044488a9750 100644 --- a/src/org/lineageos/updater/controller/UpdaterService.java +++ b/src/org/lineageos/updater/controller/UpdaterService.java @@ -553,6 +553,6 @@ public class UpdaterService extends Service { } private void notifySystemUpdaterService(int status, UpdateInfo update) { - Utils.updateSystemUpdaterService(this, status, Float.parseFloat(update.getVersion())); + Utils.updateSystemUpdaterService(this, status, update.getVersion()); } } diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index c33bb0813db955552edd618765c567fcda85b0e5..9052e87ac47f6f2c6b9ce1832ba1b8ce8172b50d 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -293,27 +293,32 @@ public class Utils { int[] deviceVersionParts = parseSemVer(SystemProperties.get(Constants.PROP_BUILD_VERSION)); int deviceMajorVersion = deviceVersionParts[0]; int deviceMinorVersion = deviceVersionParts[1]; - final float currentVersion = Float.parseFloat(deviceMajorVersion + "." + deviceMinorVersion); - float highestAvailableVersion = currentVersion; - boolean hasUpdate = false; + int deviceMaintenanceVersion = deviceVersionParts.length > 2 ? deviceVersionParts[2] : 0; + int highestMajorVersion = deviceMajorVersion; + int highestMinorVersion = deviceMinorVersion; + int highestMaintenanceVersion = deviceMaintenanceVersion; + boolean hasUpdate = false; for (UpdateInfo update : newList) { if (isCompatible(update)) { Log.d(TAG, "New compatible update available"); - int[] updateVersionParts = parseSemVer(update.getVersion()); - int updateMajorVersion = updateVersionParts[0]; - int updateMinorVersion = updateVersionParts[1]; + int[] updateVersionParts = parseSemVer(update.getVersion()); + int updateMajorVersion = updateVersionParts[0]; + int updateMinorVersion = updateVersionParts[1]; + int updateMaintenanceVersion = updateVersionParts.length > 2 ? updateVersionParts[2] : 0; float thisUpdate = Float.parseFloat(updateMajorVersion + "." + updateMinorVersion); - if (thisUpdate > highestAvailableVersion) { - highestAvailableVersion = thisUpdate; + if (updateMajorVersion*10000+updateMinorVersion*100+updateMaintenanceVersion >= highestMajorVersion*10000+highestMinorVersion*100+highestMaintenanceVersion) { + highestMajorVersion = updateMajorVersion; + highestMinorVersion = updateMinorVersion; + highestMaintenanceVersion = updateMaintenanceVersion; } hasUpdate = true; } } if (hasUpdate) { - updateSystemUpdaterService(context, STATUS_WAITING_DOWNLOAD, highestAvailableVersion); + updateSystemUpdaterService(context, STATUS_WAITING_DOWNLOAD, highestMajorVersion + "." + highestMinorVersion + (highestMaintenanceVersion > 0 ? "." + highestMaintenanceVersion : "")); return true; } else { - updateSystemUpdaterService(context, STATUS_IDLE, highestAvailableVersion); + updateSystemUpdaterService(context, STATUS_IDLE, highestMajorVersion+"."+highestMinorVersion+(highestMaintenanceVersion > 0 ? "." + highestMaintenanceVersion : "")); return false; } } @@ -500,7 +505,7 @@ public class Utils { return new File(Constants.UPDATE_RECOVERY_EXEC).exists(); } - public static void updateSystemUpdaterService(Context context, int status, float version) { + public static void updateSystemUpdaterService(Context context, int status, String version) { final SystemUpdateManager updateManager = context.getSystemService(SystemUpdateManager.class); final Bundle oldInfo = updateManager.retrieveSystemUpdateInfo(); @@ -509,7 +514,7 @@ public class Utils { if (status != oldStatus) { PersistableBundle infoBundle = new PersistableBundle(); infoBundle.putInt(KEY_STATUS, status); - infoBundle.putString(KEY_TITLE, String.valueOf(version)); + infoBundle.putString(KEY_TITLE, version); updateManager.updateSystemUpdateInfo(infoBundle); } }