From dd9916429855e1f638aeb4aa42cf351ce84f9680 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Tue, 9 Jul 2019 15:30:46 +0200 Subject: [PATCH 1/8] Block upgrade --- res/values/strings.xml | 2 +- src/org/lineageos/updater/UpdatesDbHelper.java | 9 ++++++++- src/org/lineageos/updater/UpdatesListAdapter.java | 4 ++-- src/org/lineageos/updater/misc/BuildInfoUtils.java | 4 ++++ src/org/lineageos/updater/misc/Constants.java | 1 + src/org/lineageos/updater/misc/Utils.java | 11 ++++++++++- src/org/lineageos/updater/model/UpdateBase.java | 11 +++++++++++ src/org/lineageos/updater/model/UpdateBaseInfo.java | 2 ++ 8 files changed, 39 insertions(+), 5 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 33b0a493..0a8e5541 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -137,5 +137,5 @@ Update blocked This update cannot be installed using the updater app. Please read %1$s for more information. - http://wiki.lineageos.org/upgrading.html + https://gitlab.e.foundation/e/wiki/en/wikis/device/%1$s/upgrade diff --git a/src/org/lineageos/updater/UpdatesDbHelper.java b/src/org/lineageos/updater/UpdatesDbHelper.java index 01e6fc26..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 { @@ -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/UpdatesListAdapter.java b/src/org/lineageos/updater/UpdatesListAdapter.java index dc5b57ed..a5bd463b 100644 --- a/src/org/lineageos/updater/UpdatesListAdapter.java +++ b/src/org/lineageos/updater/UpdatesListAdapter.java @@ -253,7 +253,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter 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) @@ -160,6 +162,13 @@ public class Utils { .replace("{incr}", incrementalVersion); } + public static String getUpgradeBlockedURL(Context context) { + String device = SystemProperties.get(Constants.PROP_NEXT_DEVICE, + SystemProperties.get(Constants.PROP_DEVICE)); + return context.getString(R.string.blocked_update_info_url, device); + } + + public static String getChangelogURL(Context context) { String device = SystemProperties.get(Constants.PROP_NEXT_DEVICE, SystemProperties.get(Constants.PROP_DEVICE)); diff --git a/src/org/lineageos/updater/model/UpdateBase.java b/src/org/lineageos/updater/model/UpdateBase.java index cfa2027e..f31aafe9 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(); } @@ -94,6 +96,15 @@ public class UpdateBase implements UpdateBaseInfo { 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 6f680d4fa5e73442024c0f01a67ea13fd8d020fe Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Wed, 10 Jul 2019 06:24:33 +0000 Subject: [PATCH 2/8] 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 b55ffca3..b8301cb9 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -111,7 +111,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 a01e5846d7c44d4fb312221bff0623a5f0a7ec14 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Thu, 11 Jul 2019 08:19:55 +0000 Subject: [PATCH 3/8] 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 b8301cb9..f800dc3c 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -91,7 +91,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 8ccb3952bb9b0ae5507dcc758c905b32cd3a2a6a Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Mon, 2 Dec 2019 15:44:58 +0100 Subject: [PATCH 4/8] 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 0a8e5541..0f8121d1 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -137,5 +137,5 @@ 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 -- GitLab From 997a62057987b9b4a9f9c2cb4712b9e455fd5bbf Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Mon, 2 Dec 2019 15:45:20 +0100 Subject: [PATCH 5/8] 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 f800dc3c..3de4c803 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -109,6 +109,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 f85ad2ac5e95a458bdccb6d8090f83a2564f10be Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Tue, 3 Dec 2019 11:18:41 +0100 Subject: [PATCH 6/8] 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 3de4c803..2f582dcf 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -92,6 +92,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 From dbd035c569617d8b8b1df4dc06add7793d64db05 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Tue, 3 Dec 2019 11:25:54 +0100 Subject: [PATCH 7/8] Build the module --- .gitlab-ci.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7ec2279a..e9a10b53 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,20 @@ stages: - update-from-upstream + - build + - sign include: - project: 'e/priv/os/build' ref: master file: '/templates/.gitlab-ci-update-from-upstream.yml' + - project: 'e/priv/os/build' + ref: master + file: '/templates/.gitlab-ci-build-module.yml' + +build Updater: + extends: .build-module + variables: + BRANCH_NAME: "v1-nougat" + MODULE_NAME: "Updater" + MODULE_PATH: "packages/apps/Updater" + PRIV_APP: "true" -- GitLab From 62c939d840f86dac58ada391e5feb8f52146e342 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Wed, 4 Dec 2019 11:44:03 +0100 Subject: [PATCH 8/8] Fix syntax issue --- 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 2f582dcf..439c9d87 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -95,7 +95,7 @@ public class Utils { Log.d(TAG, object.toString()); Log.d(TAG, object.getString("android_version")); - Log.d(TAG, update.getAndroidVersion()) + Log.d(TAG, update.getAndroidVersion()); return update; } -- GitLab