Loading push-update.sh +11 −11 Original line number Diff line number Diff line Loading @@ -21,11 +21,11 @@ if ! adb root; then exit 1 fi zip_path_device=$updates_dir/`basename "$zip_path"` if adb shell test -f "$zip_path_device"; then echo "$zip_path_device exists already" exit 1 fi # zip_path_device=$updates_dir/`basename "$zip_path"` # if adb shell test -f "$zip_path_device"; then # echo "$zip_path_device exists already" # exit 1 # fi if [ -n "$2" ]; then status=1 Loading @@ -44,9 +44,9 @@ 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" adb shell chmod 664 "$zip_path_device" # adb push "$zip_path" "$zip_path_device" # adb shell chgrp cache "$zip_path_device" # adb shell chmod 664 "$zip_path_device" # Kill the app before updating the database adb shell "killall org.lineageos.updater 2>/dev/null" Loading @@ -54,9 +54,9 @@ 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, 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)" \ Loading res/values/strings.xml +4 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,10 @@ {type} - Build type {incr} - Incremental version --> <string name="updater_server_url" translatable="false">https://ota.eeo.one/api/v1/{device}/{type}/{incr}</string> <!-- Hardcoded url for test --> <!-- <string name="updater_server_url" translatable="false">https://test.ota.ecloud.global/api/v1/star2lte/test/bb6c8035df</string> --> <string name="updater_server_url" translatable="false">https://test.ota.ecloud.global/api/v1/{device}/{type}/{incr}</string> <string name="verification_failed_notification">Verification failed</string> <string name="verifying_download_notification">Verifying update</string> Loading src/org/lineageos/updater/misc/Utils.java +20 −6 Original line number Diff line number Diff line Loading @@ -40,6 +40,8 @@ import org.lineageos.updater.controller.UpdaterService; import org.lineageos.updater.model.UpdateBaseInfo; import org.lineageos.updater.model.Update; import org.lineageos.updater.model.UpdateInfo; import org.lineageos.updater.UpdatesDbHelper; import java.io.BufferedReader; import java.io.File; Loading Loading @@ -95,15 +97,11 @@ public class Utils { update.setVersion(object.getString("version")); update.setDisplayVersion(object.getString("display_version")); update.setReleaseVersion(object.getString("android_version")); update.setUpgradeSupported(object.getBoolean("is_upgrade_supported")); 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)) { Loading @@ -114,6 +112,22 @@ public class Utils { Log.d(TAG, update.getName() + " has type " + update.getType()); return false; } if (update.getUpgradeSupported()) { Log.d(TAG, " is_upgrade_supported :" + update.getUpgradeSupported()); Log.d(TAG, " Check for newer Android version "); if (!update.getReleaseVersion().equals(SystemProperties.get(Constants.PROP_BUILD_RELEASE_VERSION))) { Log.d(TAG, update.getName() + " android_version :" + update.getReleaseVersion()); // Log.d(TAG, " newer Android version is available"); Version a = new Version(SystemProperties.get(Constants.PROP_BUILD_RELEASE_VERSION)); Version b = new Version(update.getReleaseVersion()); if (b.compareTo(a)==1){ Log.d(TAG, " newer Android version is available"); return true; } Log.d(TAG, " Same or old Android version "); } } return true; } Loading src/org/lineageos/updater/misc/Version.java 0 → 100644 +49 −0 Original line number Diff line number Diff line package org.lineageos.updater.misc; public class Version implements Comparable<Version> { private String version; public final String get() { return this.version; } public Version(String version) { if(version == null) throw new IllegalArgumentException("Version can not be null"); if(!version.matches("[0-9]+(\\.[0-9]+)*")) throw new IllegalArgumentException("Invalid version format"); this.version = version; } @Override public int compareTo(Version that) { if(that == null) return 1; String[] thisParts = this.get().split("\\."); String[] thatParts = that.get().split("\\."); int length = Math.max(thisParts.length, thatParts.length); for(int i = 0; i < length; i++) { int thisPart = i < thisParts.length ? Integer.parseInt(thisParts[i]) : 0; int thatPart = i < thatParts.length ? Integer.parseInt(thatParts[i]) : 0; if(thisPart < thatPart) return -1; if(thisPart > thatPart) return 1; } return 0; } @Override public boolean equals(Object that) { if(this == that) return true; if(that == null) return false; if(this.getClass() != that.getClass()) return false; return this.compareTo((Version) that) == 0; } } No newline at end of file src/org/lineageos/updater/model/UpdateBase.java +12 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ public class UpdateBase implements UpdateBaseInfo { private String mDisplayVersion; private String mReleaseVersion; private long mFileSize; private boolean mUpgradeSupported; public UpdateBase() { } Loading @@ -40,6 +41,7 @@ public class UpdateBase implements UpdateBaseInfo { mDisplayVersion = update.getDisplayVersion(); mReleaseVersion = update.getReleaseVersion(); mFileSize = update.getFileSize(); mUpgradeSupported = update.getUpgradeSupported(); } @Override Loading Loading @@ -122,4 +124,14 @@ public class UpdateBase implements UpdateBaseInfo { public void setFileSize(long fileSize) { mFileSize = fileSize; } @Override public boolean getUpgradeSupported() { return mUpgradeSupported; } public void setUpgradeSupported(boolean upgradeSupported) { mUpgradeSupported = upgradeSupported; } } Loading
push-update.sh +11 −11 Original line number Diff line number Diff line Loading @@ -21,11 +21,11 @@ if ! adb root; then exit 1 fi zip_path_device=$updates_dir/`basename "$zip_path"` if adb shell test -f "$zip_path_device"; then echo "$zip_path_device exists already" exit 1 fi # zip_path_device=$updates_dir/`basename "$zip_path"` # if adb shell test -f "$zip_path_device"; then # echo "$zip_path_device exists already" # exit 1 # fi if [ -n "$2" ]; then status=1 Loading @@ -44,9 +44,9 @@ 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" adb shell chmod 664 "$zip_path_device" # adb push "$zip_path" "$zip_path_device" # adb shell chgrp cache "$zip_path_device" # adb shell chmod 664 "$zip_path_device" # Kill the app before updating the database adb shell "killall org.lineageos.updater 2>/dev/null" Loading @@ -54,9 +54,9 @@ 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, 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)" \ Loading
res/values/strings.xml +4 −1 Original line number Diff line number Diff line Loading @@ -32,7 +32,10 @@ {type} - Build type {incr} - Incremental version --> <string name="updater_server_url" translatable="false">https://ota.eeo.one/api/v1/{device}/{type}/{incr}</string> <!-- Hardcoded url for test --> <!-- <string name="updater_server_url" translatable="false">https://test.ota.ecloud.global/api/v1/star2lte/test/bb6c8035df</string> --> <string name="updater_server_url" translatable="false">https://test.ota.ecloud.global/api/v1/{device}/{type}/{incr}</string> <string name="verification_failed_notification">Verification failed</string> <string name="verifying_download_notification">Verifying update</string> Loading
src/org/lineageos/updater/misc/Utils.java +20 −6 Original line number Diff line number Diff line Loading @@ -40,6 +40,8 @@ import org.lineageos.updater.controller.UpdaterService; import org.lineageos.updater.model.UpdateBaseInfo; import org.lineageos.updater.model.Update; import org.lineageos.updater.model.UpdateInfo; import org.lineageos.updater.UpdatesDbHelper; import java.io.BufferedReader; import java.io.File; Loading Loading @@ -95,15 +97,11 @@ public class Utils { update.setVersion(object.getString("version")); update.setDisplayVersion(object.getString("display_version")); update.setReleaseVersion(object.getString("android_version")); update.setUpgradeSupported(object.getBoolean("is_upgrade_supported")); 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)) { Loading @@ -114,6 +112,22 @@ public class Utils { Log.d(TAG, update.getName() + " has type " + update.getType()); return false; } if (update.getUpgradeSupported()) { Log.d(TAG, " is_upgrade_supported :" + update.getUpgradeSupported()); Log.d(TAG, " Check for newer Android version "); if (!update.getReleaseVersion().equals(SystemProperties.get(Constants.PROP_BUILD_RELEASE_VERSION))) { Log.d(TAG, update.getName() + " android_version :" + update.getReleaseVersion()); // Log.d(TAG, " newer Android version is available"); Version a = new Version(SystemProperties.get(Constants.PROP_BUILD_RELEASE_VERSION)); Version b = new Version(update.getReleaseVersion()); if (b.compareTo(a)==1){ Log.d(TAG, " newer Android version is available"); return true; } Log.d(TAG, " Same or old Android version "); } } return true; } Loading
src/org/lineageos/updater/misc/Version.java 0 → 100644 +49 −0 Original line number Diff line number Diff line package org.lineageos.updater.misc; public class Version implements Comparable<Version> { private String version; public final String get() { return this.version; } public Version(String version) { if(version == null) throw new IllegalArgumentException("Version can not be null"); if(!version.matches("[0-9]+(\\.[0-9]+)*")) throw new IllegalArgumentException("Invalid version format"); this.version = version; } @Override public int compareTo(Version that) { if(that == null) return 1; String[] thisParts = this.get().split("\\."); String[] thatParts = that.get().split("\\."); int length = Math.max(thisParts.length, thatParts.length); for(int i = 0; i < length; i++) { int thisPart = i < thisParts.length ? Integer.parseInt(thisParts[i]) : 0; int thatPart = i < thatParts.length ? Integer.parseInt(thatParts[i]) : 0; if(thisPart < thatPart) return -1; if(thisPart > thatPart) return 1; } return 0; } @Override public boolean equals(Object that) { if(this == that) return true; if(that == null) return false; if(this.getClass() != that.getClass()) return false; return this.compareTo((Version) that) == 0; } } No newline at end of file
src/org/lineageos/updater/model/UpdateBase.java +12 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ public class UpdateBase implements UpdateBaseInfo { private String mDisplayVersion; private String mReleaseVersion; private long mFileSize; private boolean mUpgradeSupported; public UpdateBase() { } Loading @@ -40,6 +41,7 @@ public class UpdateBase implements UpdateBaseInfo { mDisplayVersion = update.getDisplayVersion(); mReleaseVersion = update.getReleaseVersion(); mFileSize = update.getFileSize(); mUpgradeSupported = update.getUpgradeSupported(); } @Override Loading Loading @@ -122,4 +124,14 @@ public class UpdateBase implements UpdateBaseInfo { public void setFileSize(long fileSize) { mFileSize = fileSize; } @Override public boolean getUpgradeSupported() { return mUpgradeSupported; } public void setUpgradeSupported(boolean upgradeSupported) { mUpgradeSupported = upgradeSupported; } }