From 762a8038e7eaae252e479718b2ba8422c866c2bb Mon Sep 17 00:00:00 2001 From: merothh Date: Wed, 29 Sep 2021 17:05:25 +0530 Subject: [PATCH 1/6] Updater: Parse & store android_version to db * Bump the DATABASE_VERSION to 3 as well --- src/org/lineageos/updater/UpdatesDbHelper.java | 9 ++++++++- src/org/lineageos/updater/misc/Utils.java | 1 + src/org/lineageos/updater/model/UpdateBase.java | 11 +++++++++++ src/org/lineageos/updater/model/UpdateBaseInfo.java | 2 ++ 4 files changed, 22 insertions(+), 1 deletion(-) 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/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index 4d7d4ec5..2a9d6a79 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.setAndroidVersion(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..8f9b5190 100644 --- a/src/org/lineageos/updater/model/UpdateBase.java +++ b/src/org/lineageos/updater/model/UpdateBase.java @@ -23,6 +23,7 @@ public class UpdateBase implements UpdateBaseInfo { private long mTimestamp; private String mType; private String mVersion; + private String mAndroidVersion; private String mDisplayVersion; private long mFileSize; @@ -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 64435af1cf9de13441bdd994b77ff6c6453fdaa2 Mon Sep 17 00:00:00 2001 From: merothh Date: Wed, 29 Sep 2021 19:15:29 +0530 Subject: [PATCH 2/6] Updater: Modify install AlertDialog strings if android_version changes --- res/values/strings.xml | 4 ++ .../lineageos/updater/UpdatesListAdapter.java | 38 +++++++++++++------ 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 31f1bf59..779427fc 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -112,6 +112,10 @@ You are about to upgrade to %1$s.\n\nIf you press %2$s, the device will restart itself in recovery mode to install the update.\n\nNote: This feature requires a compatible Recovery or updates will need to be installed manually. You are about to upgrade to %1$s.\n\nIf you press %2$s, the device will begin installing in the background.\n\nOnce completed, you will be prompted to reboot. + Version Upgrade! + You are about to upgrade to %1$s, based on Android %2$s\n\nRemember: It is always recommended to backup your data before upgrades.\n\nIf you press %3$s, the device will restart itself into recovery mode to install the update. + You are about to upgrade to %1$s, based on Android %2$s.\n\nRemember: It is always recommended to backup your data before upgrades.\n\nIf you press %3$s, the device will begin installing in the background.\n\nOnce completed, you will be prompted to reboot. + Cancel the installation? Download URL diff --git a/src/org/lineageos/updater/UpdatesListAdapter.java b/src/org/lineageos/updater/UpdatesListAdapter.java index 0df51d98..19c1c7a0 100644 --- a/src/org/lineageos/updater/UpdatesListAdapter.java +++ b/src/org/lineageos/updater/UpdatesListAdapter.java @@ -447,26 +447,42 @@ public class UpdatesListAdapter extends RecyclerView.Adapter Utils.triggerUpdate(mActivity, downloadId)) .setNegativeButton(android.R.string.cancel, null); -- GitLab From 59a83cbe43938546da91c903582d9a03292491e3 Mon Sep 17 00:00:00 2001 From: merothh Date: Thu, 30 Sep 2021 17:43:46 +0530 Subject: [PATCH 3/6] Updater: Drop message about needing a compatible recovery --- 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 779427fc..7f8600e6 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -109,7 +109,7 @@ Delete the selected update file? Apply update - You are about to upgrade to %1$s.\n\nIf you press %2$s, the device will restart itself in recovery mode to install the update.\n\nNote: This feature requires a compatible Recovery or updates will need to be installed manually. + You are about to upgrade to %1$s.\n\nIf you press %2$s, the device will restart itself in recovery mode to install the update. You are about to upgrade to %1$s.\n\nIf you press %2$s, the device will begin installing in the background.\n\nOnce completed, you will be prompted to reboot. Version Upgrade! -- GitLab From b00665a023eb890039c2a4a96bfb92da82370025 Mon Sep 17 00:00:00 2001 From: merothh Date: Wed, 29 Sep 2021 19:34:14 +0530 Subject: [PATCH 4/6] Updater: Add an upgrade_type TextView --- res/layout/update_item_view.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/res/layout/update_item_view.xml b/res/layout/update_item_view.xml index ddcf3268..f5888895 100644 --- a/res/layout/update_item_view.xml +++ b/res/layout/update_item_view.xml @@ -35,6 +35,18 @@ android:textSize="16sp" tools:text="LineageOS 15.1" /> + + Date: Wed, 29 Sep 2021 20:16:47 +0530 Subject: [PATCH 5/6] Updater: Setup visibility for the upgrade_type TextView --- src/org/lineageos/updater/UpdatesListAdapter.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/org/lineageos/updater/UpdatesListAdapter.java b/src/org/lineageos/updater/UpdatesListAdapter.java index 19c1c7a0..92db20bc 100644 --- a/src/org/lineageos/updater/UpdatesListAdapter.java +++ b/src/org/lineageos/updater/UpdatesListAdapter.java @@ -21,6 +21,7 @@ import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.res.Resources; import android.os.BatteryManager; +import android.os.Build; import android.os.PowerManager; import android.preference.PreferenceManager; import android.support.design.widget.Snackbar; @@ -86,6 +87,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter Date: Thu, 30 Sep 2021 17:52:38 +0200 Subject: [PATCH 6/6] Minor fixes --- res/values/strings.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 7f8600e6..269648df 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -109,12 +109,12 @@ Delete the selected update file? Apply update - You are about to upgrade to %1$s.\n\nIf you press %2$s, the device will restart itself in recovery mode to install the update. - You are about to upgrade to %1$s.\n\nIf you press %2$s, the device will begin installing in the background.\n\nOnce completed, you will be prompted to reboot. + You are about to update to %1$s.\n\nIf you press %2$s, the device will restart itself in recovery mode to install the update. + You are about to update to %1$s.\n\nIf you press %2$s, the device will begin installing in the background.\n\nOnce completed, you will be prompted to reboot. Version Upgrade! - You are about to upgrade to %1$s, based on Android %2$s\n\nRemember: It is always recommended to backup your data before upgrades.\n\nIf you press %3$s, the device will restart itself into recovery mode to install the update. - You are about to upgrade to %1$s, based on Android %2$s.\n\nRemember: It is always recommended to backup your data before upgrades.\n\nIf you press %3$s, the device will begin installing in the background.\n\nOnce completed, you will be prompted to reboot. + You are about to upgrade to %1$s, based on Android %2$s\n\nRemember: it is always recommended to backup your data before upgrades.\n\nIf you press %3$s, the device will restart itself into recovery mode to install the update. + You are about to upgrade to %1$s, based on Android %2$s.\n\nRemember: it is always recommended to backup your data before upgrades.\n\nIf you press %3$s, the device will begin installing in the background.\n\nOnce completed, you will be prompted to reboot. Cancel the installation? -- GitLab