From f6818ee6634adda33aed99f8a106805bb1efa2cd Mon Sep 17 00:00:00 2001 From: Nishith Khanna Date: Fri, 14 Oct 2022 14:50:54 +0530 Subject: [PATCH] Revert "S dont crash when receiving maintenance number" This reverts commit 8f3ba5024e07c5e2a42d5ad730538e3c1b1c9513. --- .../download/HttpURLConnectionClient.java | 6 +----- src/org/lineageos/updater/misc/Utils.java | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/org/lineageos/updater/download/HttpURLConnectionClient.java b/src/org/lineageos/updater/download/HttpURLConnectionClient.java index df6283b5..52c1073a 100644 --- a/src/org/lineageos/updater/download/HttpURLConnectionClient.java +++ b/src/org/lineageos/updater/download/HttpURLConnectionClient.java @@ -16,8 +16,6 @@ package org.lineageos.updater.download; import android.os.SystemClock; -import android.os.SystemProperties; - import android.util.Log; import java.io.File; @@ -34,8 +32,6 @@ import java.util.PriorityQueue; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.lineageos.updater.misc.Constants; - public class HttpURLConnectionClient implements DownloadClient { private final static String TAG = "HttpURLConnectionClient"; @@ -64,7 +60,7 @@ public class HttpURLConnectionClient implements DownloadClient { mClient = (HttpURLConnection) new URL(url).openConnection(); String defaultUserAgent = mClient.getRequestProperty("User-Agent"); - String newUserAgent = defaultUserAgent + " eOS v" + SystemProperties.get(Constants.PROP_BUILD_VERSION); + String newUserAgent = defaultUserAgent + " ota_007_eels"; mClient.setRequestProperty("User-Agent", newUserAgent); mDestination = destination; diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index aca2b04d..8aa0582e 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -274,14 +274,22 @@ public class Utils { public static boolean checkForNewUpdates(File newJson, Context context) throws IOException, JSONException { List newList = parseJson(newJson, true); + final float currentVersion = Float.parseFloat(BuildInfoUtils.getBuildVersion()); + float highestAvailableVersion = currentVersion; for (UpdateInfo update : newList) { - if (isCompatible(update)) { - Log.d(TAG, "New compatible update available"); - updateSystemUpdaterService(context, STATUS_WAITING_DOWNLOAD, highestAvailableVersion); - return true; + float availableversion = Float.parseFloat(update.getVersion()); + if (availableversion > highestAvailableVersion) { + highestAvailableVersion = availableversion; } } - updateSystemUpdaterService(context, STATUS_IDLE, highestAvailableVersion); + + if (highestAvailableVersion > currentVersion) { + updateSystemUpdaterService(context, STATUS_WAITING_DOWNLOAD, highestAvailableVersion); + return true; + } else { + updateSystemUpdaterService(context, STATUS_IDLE, highestAvailableVersion); + return false; + } } /** -- GitLab