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

Commit e3f6ca45 authored by Sooraj S's avatar Sooraj S 👽
Browse files

Updater: Parse android_version from JSON response

parent 82ef1134
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -38,9 +38,11 @@ zip_name=`basename "$zip_path"`
id=`echo "$zip_name" | sha1sum | cut -d' ' -f1`
version=`echo "$zip_name" | cut -d'-' -f2`
type=`echo "$zip_name" | cut -d'-' -f4`
build_date=`echo "$zip_name" | cut -d'-' -f3 | cut -d'_' -f1`
build_date=`echo "$zip_name" | cut -d'-' -f4 | cut -d'_' -f1`
timestamp=`date --date="$build_date 23:59:59" +%s`
size=`stat -c "%s" "$zip_path"`
display_version=
android_version='10'

adb push "$zip_path" "$zip_path_device"
adb shell chgrp cache "$zip_path_device"
@@ -52,5 +54,13 @@ adb shell "sqlite3 /data/data/org.lineageos.updater/databases/updates.db" \
    "\"INSERT INTO updates (status, path, download_id, timestamp, type, version, size)" \
    "  VALUES ($status, '$zip_path_device', '$id', $timestamp, '$type', '$version', $size)\""

adb shell "sqlite3 /data/data/org.lineageos.updater/databases/updates.db" \
    "\"INSERT INTO updates (status, path, download_id, timestamp, type, version, android_version, size)" \
    "  VALUES ($status, '$zip_path_device', '$id', $timestamp, '$type', '$version', '$android_version', $size)\""

# adb shell "sqlite3 /data/data/org.lineageos.updater/databases/updates.db" \
#     "\"INSERT INTO updates (status, path, download_id, timestamp, type, version, display_version, android_version, size)" \
#     "  VALUES ($status, '$zip_path_device', '$id', $timestamp, '$type', '$version', '$display_version', '$android_version', $size)\""

# Exit root mode
adb unroot
+1 −1
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@
          {type} - Build type
          {incr} - Incremental version
    -->
    <string name="updater_server_url" translatable="false">https://ota.ecloud.global/api/v1/{device}/{type}/{incr}</string>
    <string name="updater_server_url" translatable="false">https://ota.eeo.one/api/v1/{device}/{type}/{incr}</string>

    <string name="verification_failed_notification">Verification failed</string>
    <string name="verifying_download_notification">Verifying update</string>
+4 −0
Original line number Diff line number Diff line
@@ -33,4 +33,8 @@ public final class BuildInfoUtils {
    public static String getDisplayVersion() {
        return SystemProperties.get(Constants.PROP_BUILD_DISPLAY_VERSION);
    }

    public static String getReleaseVersion() {
        return SystemProperties.get(Constants.PROP_BUILD_RELEASE_VERSION);
    }
}
+1 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ public final class Constants {
    public static final String PROP_BUILD_DATE = "ro.build.date.utc";
    public static final String PROP_BUILD_VERSION = "ro.lineage.build.version";
    public static final String PROP_BUILD_DISPLAY_VERSION = "ro.lineage.display.version";
    public static final String PROP_BUILD_RELEASE_VERSION = "ro.build.version.release";
    public static final String PROP_BUILD_VERSION_INCREMENTAL = "ro.build.version.incremental";
    public static final String PROP_DEVICE = "ro.lineage.device";
    public static final String PROP_NEXT_DEVICE = "ro.updater.next_device";
+10 −0
Original line number Diff line number Diff line
@@ -53,6 +53,8 @@ import java.util.Locale;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.regex.Pattern;


public class Utils {

@@ -92,10 +94,17 @@ public class Utils {
        update.setDownloadUrl(object.getString("url"));
        update.setVersion(object.getString("version"));
        update.setDisplayVersion(object.getString("display_version"));
        update.setReleaseVersion(object.getString("android_version"));
        return update;
    }

    public static boolean isCompatible(UpdateBaseInfo update) {
        Log.d(TAG, update.getName() + " android_version :" + update.getReleaseVersion());
        if (!update.getReleaseVersion().equals(SystemProperties.get(Constants.PROP_BUILD_RELEASE_VERSION))) {
            Log.d(TAG, update.getName() + " android_version :" + update.getReleaseVersion());
            return true;
        }
        
        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/equal to the current build");
@@ -105,6 +114,7 @@ public class Utils {
            Log.d(TAG, update.getName() + " has type " + update.getType());
            return false;
        }

        return true;
    }

Loading