From bd9b5e61dfe81edb606f9c0697712692d3f0f1b2 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 b46378c8..861cbfa3 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -110,7 +110,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 265e0ff23a9b032d361e7df39646ff7c8e30faa0 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 861cbfa3..29fc29e8 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 5447201010484e73bb17ec031a2cd1ca8ea851fa 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 57cefc03..ed22b8bf 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -142,7 +142,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 a291ff1ff2c09143106900b997e9dcad65919433 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Tue, 9 Jul 2019 15:14:07 +0200 Subject: [PATCH 4/9] Update 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 66a0637e94ab9b0101b4cc84b84358eeda71dab7 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Tue, 9 Jul 2019 13:21:22 +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 29fc29e8..0e8dcb2b 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -113,7 +113,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 667d8b4a09e458f89ae0098ed994eaea1f8bcedc Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Wed, 10 Jul 2019 06:23:00 +0000 Subject: [PATCH 6/9] Add forgotten parenthesis --- 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 0e8dcb2b..791b5a3d 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -112,7 +112,7 @@ 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.getAndroidVersion().equals(SystemProperties.get(Constants.PROP_BUILD_ANDROID_VERSION)); + update.getAndroidVersion().equals(SystemProperties.get(Constants.PROP_BUILD_ANDROID_VERSION))); } public static List parseJson(File file, boolean compatibleOnly) -- GitLab From cec0076404cff0bf4d92fe48018f0bc0a2346a2a Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Thu, 11 Jul 2019 08:20:38 +0000 Subject: [PATCH 7/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 791b5a3d..b1f8e6bf 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 805e527c393d6772507e1c729cc0b8205426e5fa Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Mon, 2 Dec 2019 15:44:58 +0100 Subject: [PATCH 8/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 ed22b8bf..911e9d65 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -142,7 +142,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 de1844588f9630e21d80b4e2bf5f4af0cb6ff042 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Mon, 2 Dec 2019 15:45:20 +0100 Subject: [PATCH 9/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 b1f8e6bf..533f3eb6 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -110,6 +110,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