From fb722788492ddc97fb17d19ce102003f47ce70d5 Mon Sep 17 00:00:00 2001 From: Aayush Gupta Date: Tue, 23 Mar 2021 10:34:51 +0530 Subject: [PATCH 1/5] Updater: Change 'Show changelog' into 'Show release notes' Signed-off-by: Aayush Gupta --- res/menu/menu_toolbar.xml | 4 ++-- res/values/strings.xml | 2 +- src/org/lineageos/updater/UpdatesActivity.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/res/menu/menu_toolbar.xml b/res/menu/menu_toolbar.xml index 8b9117ce..b26cf66f 100644 --- a/res/menu/menu_toolbar.xml +++ b/res/menu/menu_toolbar.xml @@ -11,7 +11,7 @@ android:title="@string/menu_preferences" app:showAsAction="never" /> diff --git a/res/values/strings.xml b/res/values/strings.xml index 6bcba24d..c4ce561c 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -74,7 +74,7 @@ Delete Copy URL Export update - Show changelog + Show release notes https://gitlab.e.foundation/e/os/releases/-/releases/v%1$s-pie Prioritize update process diff --git a/src/org/lineageos/updater/UpdatesActivity.java b/src/org/lineageos/updater/UpdatesActivity.java index b9161d09..a89c4605 100644 --- a/src/org/lineageos/updater/UpdatesActivity.java +++ b/src/org/lineageos/updater/UpdatesActivity.java @@ -200,7 +200,7 @@ public class UpdatesActivity extends UpdatesListActivity { showPreferencesDialog(); return true; } - case R.id.menu_show_changelog: { + case R.id.menu_show_release_notes: { Intent openUrl = new Intent(Intent.ACTION_VIEW, Uri.parse(Utils.getChangelogURL(this))); startActivity(openUrl); -- GitLab From 0090a9c10deba4b2410c08b96477ce743f021594 Mon Sep 17 00:00:00 2001 From: Aayush Gupta Date: Tue, 23 Mar 2021 10:59:02 +0530 Subject: [PATCH 2/5] updater: Enable auto deletion of updates by default Signed-off-by: Aayush Gupta --- src/org/lineageos/updater/UpdatesActivity.java | 2 +- src/org/lineageos/updater/controller/ABUpdateInstaller.java | 2 +- src/org/lineageos/updater/misc/Utils.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/org/lineageos/updater/UpdatesActivity.java b/src/org/lineageos/updater/UpdatesActivity.java index a89c4605..95a5a342 100644 --- a/src/org/lineageos/updater/UpdatesActivity.java +++ b/src/org/lineageos/updater/UpdatesActivity.java @@ -419,7 +419,7 @@ public class UpdatesActivity extends UpdatesListActivity { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); autoCheckInterval.setSelection(Utils.getUpdateCheckSetting(this)); - autoDelete.setChecked(prefs.getBoolean(Constants.PREF_AUTO_DELETE_UPDATES, false)); + autoDelete.setChecked(prefs.getBoolean(Constants.PREF_AUTO_DELETE_UPDATES, true)); dataWarning.setChecked(prefs.getBoolean(Constants.PREF_MOBILE_DATA_WARNING, true)); abPerfMode.setChecked(prefs.getBoolean(Constants.PREF_AB_PERF_MODE, false)); diff --git a/src/org/lineageos/updater/controller/ABUpdateInstaller.java b/src/org/lineageos/updater/controller/ABUpdateInstaller.java index b0be2010..4f2069bf 100644 --- a/src/org/lineageos/updater/controller/ABUpdateInstaller.java +++ b/src/org/lineageos/updater/controller/ABUpdateInstaller.java @@ -91,7 +91,7 @@ class ABUpdateInstaller { SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences( mContext); boolean deleteUpdate = pref.getBoolean(Constants.PREF_AUTO_DELETE_UPDATES, - false); + true); if (deleteUpdate) { mUpdaterController.deleteUpdate(mDownloadId); } diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index d8022ac8..82acffc3 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -313,7 +313,7 @@ public class Utils { long prevTimestamp = preferences.getLong(Constants.PREF_INSTALL_OLD_TIMESTAMP, 0); String lastUpdatePath = preferences.getString(Constants.PREF_INSTALL_PACKAGE_PATH, null); boolean reinstalling = preferences.getBoolean(Constants.PREF_INSTALL_AGAIN, false); - boolean deleteUpdates = preferences.getBoolean(Constants.PREF_AUTO_DELETE_UPDATES, false); + boolean deleteUpdates = preferences.getBoolean(Constants.PREF_AUTO_DELETE_UPDATES, true); if ((buildTimestamp != prevTimestamp || reinstalling) && deleteUpdates && lastUpdatePath != null) { File lastUpdate = new File(lastUpdatePath); -- GitLab From 6f52dca60c1932e6e25a29cb2fc4d2e7cc73ce35 Mon Sep 17 00:00:00 2001 From: Aayush Gupta Date: Tue, 23 Mar 2021 15:30:47 +0530 Subject: [PATCH 3/5] updater: Show update's version wherever applicable Currently at most of the places, build version is obtained from BuildInfoUtils.getBuildVersion() method. This method obtains build version from the current running system's property. At /e/, we bump version number on every new OTA. This results in version mismatch in several places in the updater app. Let's get the version from the update itself to show the proper version. Signed-off-by: Aayush Gupta --- src/org/lineageos/updater/UpdatesListAdapter.java | 9 ++------- src/org/lineageos/updater/controller/UpdaterService.java | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/org/lineageos/updater/UpdatesListAdapter.java b/src/org/lineageos/updater/UpdatesListAdapter.java index 0df51d98..87f90d83 100644 --- a/src/org/lineageos/updater/UpdatesListAdapter.java +++ b/src/org/lineageos/updater/UpdatesListAdapter.java @@ -249,12 +249,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter Date: Wed, 24 Mar 2021 14:50:55 +0530 Subject: [PATCH 4/5] updater: Enable auto deletion of updates by default on existing devices as well - This commit should be reverted after a considerable number of OTAs when we are sure that none of the users are on older builds anymore Signed-off-by: Aayush Gupta --- src/org/lineageos/updater/misc/Constants.java | 1 + src/org/lineageos/updater/misc/Utils.java | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/src/org/lineageos/updater/misc/Constants.java b/src/org/lineageos/updater/misc/Constants.java index 6ba705c7..979b0c0a 100644 --- a/src/org/lineageos/updater/misc/Constants.java +++ b/src/org/lineageos/updater/misc/Constants.java @@ -34,6 +34,7 @@ public final class Constants { public static final String PREF_AB_PERF_MODE = "ab_perf_mode"; public static final String PREF_MOBILE_DATA_WARNING = "pref_mobile_data_warning"; public static final String PREF_NEEDS_REBOOT_ID = "needs_reboot_id"; + public static final String PREF_FORCED_AUTO_DELETE_UPDATES = "force_auto_delete_updates"; public static final String UNCRYPT_FILE_EXT = ".uncrypt"; diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index 82acffc3..b97422ad 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -309,6 +309,15 @@ public class Utils { removeUncryptFiles(downloadPath); + // TODO: Remove after a considerable numbers of OTA + boolean forcedDeleteUpdates = preferences.getBoolean(Constants.PREF_FORCED_AUTO_DELETE_UPDATES, true); + if (forcedDeleteUpdates == true) { + preferences.edit() + .putBoolean(Constants.PREF_AUTO_DELETE_UPDATES, true) + .putBoolean(Constants.PREF_FORCED_AUTO_DELETE_UPDATES, false) + .apply(); + } + long buildTimestamp = SystemProperties.getLong(Constants.PROP_BUILD_DATE, 0); long prevTimestamp = preferences.getLong(Constants.PREF_INSTALL_OLD_TIMESTAMP, 0); String lastUpdatePath = preferences.getString(Constants.PREF_INSTALL_PACKAGE_PATH, null); -- GitLab From eebe93a06173bb01913c009af44193a1d88d3eab Mon Sep 17 00:00:00 2001 From: Aayush Gupta Date: Thu, 25 Mar 2021 12:32:31 +0530 Subject: [PATCH 5/5] updater: Rework logic to check for new updates - Use the current system's version against update's version to check for new updates Signed-off-by: Aayush Gupta --- src/org/lineageos/updater/UpdatesActivity.java | 2 +- .../lineageos/updater/UpdatesCheckReceiver.java | 2 +- src/org/lineageos/updater/misc/Utils.java | 17 ++++++----------- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/org/lineageos/updater/UpdatesActivity.java b/src/org/lineageos/updater/UpdatesActivity.java index 95a5a342..e56d02af 100644 --- a/src/org/lineageos/updater/UpdatesActivity.java +++ b/src/org/lineageos/updater/UpdatesActivity.java @@ -294,7 +294,7 @@ public class UpdatesActivity extends UpdatesListActivity { preferences.edit().putLong(Constants.PREF_LAST_UPDATE_CHECK, millis).apply(); updateLastCheckedString(); if (json.exists() && Utils.isUpdateCheckEnabled(this) && - Utils.checkForNewUpdates(json, jsonNew)) { + Utils.checkForNewUpdates(jsonNew)) { UpdatesCheckReceiver.updateRepeatingUpdatesCheck(this); } // In case we set a one-shot check because of a previous failure diff --git a/src/org/lineageos/updater/UpdatesCheckReceiver.java b/src/org/lineageos/updater/UpdatesCheckReceiver.java index d0769cf7..7626f8d3 100644 --- a/src/org/lineageos/updater/UpdatesCheckReceiver.java +++ b/src/org/lineageos/updater/UpdatesCheckReceiver.java @@ -93,7 +93,7 @@ public class UpdatesCheckReceiver extends BroadcastReceiver { @Override public void onSuccess(File destination) { try { - if (json.exists() && Utils.checkForNewUpdates(json, jsonNew)) { + if (json.exists() && Utils.checkForNewUpdates(jsonNew)) { showNotification(context); updateRepeatingUpdatesCheck(context); } diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index b97422ad..c8b4ec97 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -231,24 +231,19 @@ public class Utils { /** * Compares two json formatted updates list files * - * @param oldJson old update list * @param newJson new update list - * @return true if newJson has at least a compatible update not available in oldJson + * @return true if newJson has an update with higher version than the installed system * @throws IOException * @throws JSONException */ - public static boolean checkForNewUpdates(File oldJson, File newJson) + public static boolean checkForNewUpdates(File newJson) throws IOException, JSONException { - List oldList = parseJson(oldJson, true); List newList = parseJson(newJson, true); - Set oldIds = new HashSet<>(); - for (UpdateInfo update : oldList) { - oldIds.add(update.getDownloadId()); - } - // In case of no new updates, the old list should - // have all (if not more) the updates + float currentVersion = Float.parseFloat(BuildInfoUtils.getBuildVersion()); + for (UpdateInfo update : newList) { - if (!oldIds.contains(update.getDownloadId())) { + if (Float.parseFloat(update.getVersion()) > currentVersion) { + Log.d(TAG, "New compatiable update available"); return true; } } -- GitLab