From 8ab87a22697baeeae2ccb6c7db0c9262373fcc31 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Tue, 9 Jul 2019 10:25:57 +0000 Subject: [PATCH 1/9] Block upgrade between android version --- src/org/lineageos/updater/misc/Constants.java | 1 + src/org/lineageos/updater/misc/Utils.java | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/org/lineageos/updater/misc/Constants.java b/src/org/lineageos/updater/misc/Constants.java index 6ba705c7..7aa9e83a 100644 --- a/src/org/lineageos/updater/misc/Constants.java +++ b/src/org/lineageos/updater/misc/Constants.java @@ -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_ANDROID_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"; diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index eb2230c2..f231e57c 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -114,7 +114,9 @@ public class Utils { 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.getTimestamp() > SystemProperties.getLong(Constants.PROP_BUILD_DATE, 0) || + update.getAndroidVersion().equals(SystemProperties.get(Constants.PROP_BUILD_ANDROID_VERSION)); +); } public static List parseJson(File file, boolean compatibleOnly) -- GitLab From e0477e81ba860f78a7754f442d5dcbc3cd457ce5 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Tue, 9 Jul 2019 12:38:22 +0000 Subject: [PATCH 2/9] Load Android version --- src/org/lineageos/updater/UpdatesDbHelper.java | 7 +++++++ src/org/lineageos/updater/misc/BuildInfoUtils.java | 4 ++++ src/org/lineageos/updater/misc/Utils.java | 1 + src/org/lineageos/updater/model/UpdateBase.java | 13 ++++++++++++- src/org/lineageos/updater/model/UpdateBaseInfo.java | 2 ++ 5 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/org/lineageos/updater/UpdatesDbHelper.java b/src/org/lineageos/updater/UpdatesDbHelper.java index 01e6fc26..ecd29ded 100644 --- a/src/org/lineageos/updater/UpdatesDbHelper.java +++ b/src/org/lineageos/updater/UpdatesDbHelper.java @@ -42,6 +42,7 @@ public class UpdatesDbHelper extends SQLiteOpenHelper { public static final String COLUMN_NAME_TYPE = "type"; public static final String COLUMN_NAME_VERSION = "version"; public static final String COLUMN_NAME_DISPLAY_VERSION = "display_version"; + public static final String COLUMN_NAME_ANDROID_VERSION = "android_version"; public static final String COLUMN_NAME_SIZE = "size"; } @@ -55,6 +56,7 @@ public class UpdatesDbHelper extends SQLiteOpenHelper { UpdateEntry.COLUMN_NAME_TYPE + " TEXT," + UpdateEntry.COLUMN_NAME_VERSION + " TEXT," + UpdateEntry.COLUMN_NAME_DISPLAY_VERSION + " TEXT," + + UpdateEntry.COLUMN_NAME_ANDROID_VERSION + " TEXT," + UpdateEntry.COLUMN_NAME_SIZE + " INTEGER)"; private static final String SQL_DELETE_ENTRIES = @@ -87,6 +89,7 @@ public class UpdatesDbHelper extends SQLiteOpenHelper { values.put(UpdateEntry.COLUMN_NAME_TYPE, update.getType()); values.put(UpdateEntry.COLUMN_NAME_VERSION, update.getVersion()); values.put(UpdateEntry.COLUMN_NAME_DISPLAY_VERSION, update.getDisplayVersion()); + values.put(UpdateEntry.COLUMN_NAME_ANDROID_VERSION, update.getAndroidVersion()); values.put(UpdateEntry.COLUMN_NAME_SIZE, update.getFileSize()); return db.insert(UpdateEntry.TABLE_NAME, null, values); } @@ -101,6 +104,7 @@ public class UpdatesDbHelper extends SQLiteOpenHelper { values.put(UpdateEntry.COLUMN_NAME_TYPE, update.getType()); values.put(UpdateEntry.COLUMN_NAME_VERSION, update.getVersion()); values.put(UpdateEntry.COLUMN_NAME_DISPLAY_VERSION, update.getDisplayVersion()); + values.put(UpdateEntry.COLUMN_NAME_ANDROID_VERSION, update.getAndroidVersion()); values.put(UpdateEntry.COLUMN_NAME_SIZE, update.getFileSize()); return db.insertWithOnConflict(UpdateEntry.TABLE_NAME, null, values, conflictAlgorithm); } @@ -166,6 +170,7 @@ public class UpdatesDbHelper extends SQLiteOpenHelper { UpdateEntry.COLUMN_NAME_TYPE, UpdateEntry.COLUMN_NAME_VERSION, UpdateEntry.COLUMN_NAME_DISPLAY_VERSION, + UpdateEntry.COLUMN_NAME_ANDROID_VERSION, UpdateEntry.COLUMN_NAME_STATUS, UpdateEntry.COLUMN_NAME_SIZE, }; @@ -189,6 +194,8 @@ public class UpdatesDbHelper extends SQLiteOpenHelper { update.setVersion(cursor.getString(index)); index = cursor.getColumnIndex(UpdateEntry.COLUMN_NAME_DISPLAY_VERSION); update.setDisplayVersion(cursor.getString(index)); + index = cursor.getColumnIndex(UpdateEntry.COLUMN_NAME_ANDROID_VERSION); + update.setAndroidVersion(cursor.getString(index)); index = cursor.getColumnIndex(UpdateEntry.COLUMN_NAME_STATUS); update.setPersistentStatus(cursor.getInt(index)); index = cursor.getColumnIndex(UpdateEntry.COLUMN_NAME_SIZE); diff --git a/src/org/lineageos/updater/misc/BuildInfoUtils.java b/src/org/lineageos/updater/misc/BuildInfoUtils.java index 6a647faf..37718c4e 100644 --- a/src/org/lineageos/updater/misc/BuildInfoUtils.java +++ b/src/org/lineageos/updater/misc/BuildInfoUtils.java @@ -33,4 +33,8 @@ public final class BuildInfoUtils { public static String getDisplayVersion() { return SystemProperties.get(Constants.PROP_BUILD_DISPLAY_VERSION); } + + public static String getAndroidVersion() { + return SystemProperties.get(Constants.PROP_BUILD_ANDROID_VERSION); + } } diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index f231e57c..6d7c7723 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -92,6 +92,7 @@ public class Utils { update.setDownloadUrl(object.getString("url")); update.setVersion(object.getString("version")); update.setDisplayVersion(object.getString("display_version")); + update.setDisplayVersion(object.getString("android_version")); return update; } diff --git a/src/org/lineageos/updater/model/UpdateBase.java b/src/org/lineageos/updater/model/UpdateBase.java index cfa2027e..4e2b3f56 100644 --- a/src/org/lineageos/updater/model/UpdateBase.java +++ b/src/org/lineageos/updater/model/UpdateBase.java @@ -24,6 +24,7 @@ public class UpdateBase implements UpdateBaseInfo { private String mType; private String mVersion; private String mDisplayVersion; + private String mAndroidVersion; private long mFileSize; public UpdateBase() { @@ -37,6 +38,7 @@ public class UpdateBase implements UpdateBaseInfo { mType = update.getType(); mVersion = update.getVersion(); mDisplayVersion = update.getDisplayVersion(); + mAndroidVersion = update.getAndroidVersion(); mFileSize = update.getFileSize(); } @@ -89,11 +91,20 @@ public class UpdateBase implements UpdateBaseInfo { public String getDisplayVersion() { return mDisplayVersion; } - + public void setDisplayVersion(String displayVersion) { mDisplayVersion = displayVersion; } + @Override + public String getAndroidVersion() { + return mAndroidVersion; + } + + public void setAndroidVersion(String androidVersion) { + mAndroidVersion = androidVersion; + } + @Override public String getDownloadUrl() { return mDownloadUrl; diff --git a/src/org/lineageos/updater/model/UpdateBaseInfo.java b/src/org/lineageos/updater/model/UpdateBaseInfo.java index 2921e96f..a1bfb022 100644 --- a/src/org/lineageos/updater/model/UpdateBaseInfo.java +++ b/src/org/lineageos/updater/model/UpdateBaseInfo.java @@ -28,6 +28,8 @@ public interface UpdateBaseInfo { String getDisplayVersion(); + String getAndroidVersion(); + String getDownloadUrl(); long getFileSize(); -- GitLab From 40605c7a47d4708fd86cbe50fb83b864cb07f43d Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Tue, 9 Jul 2019 12:48:05 +0000 Subject: [PATCH 3/9] Change upgrade documentation URL --- res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index ec352a57..c6401e83 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -144,7 +144,7 @@ Update blocked This update cannot be installed using the updater app. Please read %1$s for more information. - http://wiki.lineageos.org/devices/%1$s/upgrade + https://gitlab.e.foundation/e/wiki/en/wikis/device/%1$s/upgrade Export completion New updates -- GitLab From fe19f00fb4c7aeb88690fc58d71fe2453dfa5e28 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Tue, 9 Jul 2019 15:14:39 +0200 Subject: [PATCH 4/9] Increment DB version --- src/org/lineageos/updater/UpdatesDbHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/lineageos/updater/UpdatesDbHelper.java b/src/org/lineageos/updater/UpdatesDbHelper.java index ecd29ded..cd9fda45 100644 --- a/src/org/lineageos/updater/UpdatesDbHelper.java +++ b/src/org/lineageos/updater/UpdatesDbHelper.java @@ -30,7 +30,7 @@ import java.util.List; public class UpdatesDbHelper extends SQLiteOpenHelper { - public static final int DATABASE_VERSION = 2; + public static final int DATABASE_VERSION = 3; public static final String DATABASE_NAME = "updates.db"; public static class UpdateEntry implements BaseColumns { -- GitLab From 0b15fe2f00474715254c03d396b10ca186dcf5b8 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Tue, 9 Jul 2019 13:22:14 +0000 Subject: [PATCH 5/9] Fix syntax issue --- src/org/lineageos/updater/misc/Utils.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index 6d7c7723..42c86387 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -117,7 +117,6 @@ public class Utils { return (SystemProperties.getBoolean(Constants.PROP_UPDATER_ALLOW_DOWNGRADING, false) || update.getTimestamp() > SystemProperties.getLong(Constants.PROP_BUILD_DATE, 0) || update.getAndroidVersion().equals(SystemProperties.get(Constants.PROP_BUILD_ANDROID_VERSION)); -); } public static List parseJson(File file, boolean compatibleOnly) -- GitLab From 113e113f64fd4c78584ab6969d54cdf729a0341f Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Thu, 11 Jul 2019 08:21:17 +0000 Subject: [PATCH 6/9] Fix display version value --- src/org/lineageos/updater/misc/Utils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index 42c86387..d142b60f 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -92,7 +92,7 @@ public class Utils { update.setDownloadUrl(object.getString("url")); update.setVersion(object.getString("version")); update.setDisplayVersion(object.getString("display_version")); - update.setDisplayVersion(object.getString("android_version")); + update.setAndroidVersion(object.getString("android_version")); return update; } -- GitLab From 539bd6a549175bad0c50f818fcf01967b20ca150 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Mon, 2 Dec 2019 15:44:58 +0100 Subject: [PATCH 7/9] Update URL --- res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index c6401e83..9546b28c 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -144,7 +144,7 @@ Update blocked This update cannot be installed using the updater app. Please read %1$s for more information. - https://gitlab.e.foundation/e/wiki/en/wikis/device/%1$s/upgrade + https://doc.e.foundation/devices/%1$s/upgrade Export completion New updates -- GitLab From 441981877a2feac32335136180719ab5585d80a3 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Mon, 2 Dec 2019 15:45:20 +0100 Subject: [PATCH 8/9] Display in logs the version --- src/org/lineageos/updater/misc/Utils.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index d142b60f..c613753a 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -114,6 +114,12 @@ public class Utils { } public static boolean canInstall(UpdateBaseInfo update) { + + + Log.d(TAG, "System Android version: "+SystemProperties.get(Constants.PROP_BUILD_ANDROID_VERSION)); + Log.d(TAG, "Update Android version: "+update.getAndroidVersion()); + + return (SystemProperties.getBoolean(Constants.PROP_UPDATER_ALLOW_DOWNGRADING, false) || update.getTimestamp() > SystemProperties.getLong(Constants.PROP_BUILD_DATE, 0) || update.getAndroidVersion().equals(SystemProperties.get(Constants.PROP_BUILD_ANDROID_VERSION)); -- GitLab From cecf176226dc2ef75056721ae237b6ec13cf6540 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Tue, 3 Dec 2019 11:18:41 +0100 Subject: [PATCH 9/9] Add more logs --- src/org/lineageos/updater/misc/Utils.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index c613753a..7ff8d29e 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -93,6 +93,11 @@ public class Utils { update.setVersion(object.getString("version")); update.setDisplayVersion(object.getString("display_version")); update.setAndroidVersion(object.getString("android_version")); + + Log.d(TAG, object.toString()); + Log.d(TAG, object.getString("android_version")); + Log.d(TAG, update.getAndroidVersion()) + return update; } -- GitLab