From 2afe19b6849db4f142cb1ac23895fcf89d40a69a Mon Sep 17 00:00:00 2001 From: Alexandre Roux Date: Tue, 18 Aug 2020 16:08:13 +0000 Subject: [PATCH 01/14] Updater: Add gitlab CI Signed-off-by: Aayush Gupta Change-Id: I7d97304db7947b379c430dc8728531ede23132d5 --- .gitlab-ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..f01e7779 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,7 @@ +stages: + - update-from-upstream + +include: + - project: 'e/templates' + ref: master + file: '/gitlab-ci/.gitlab-ci-import-updates-from-upstream.yml' -- GitLab From 0ce630c31398ab90978609a6ab6da2d5136073bf Mon Sep 17 00:00:00 2001 From: TheScarastic Date: Wed, 24 Aug 2022 13:05:29 +0000 Subject: [PATCH 02/14] Updater: Rebrand to /e/ OS Change-Id: Idcf080541eb910c99f9057859d3d777768c7bde2 --- res/values/strings.xml | 6 ++++++ src/org/lineageos/updater/UpdaterReceiver.java | 2 +- src/org/lineageos/updater/UpdatesListAdapter.java | 4 ++-- src/org/lineageos/updater/controller/UpdaterService.java | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index bfb26276..37269d9e 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -157,4 +157,10 @@ Did you know? LineageOS updates are full installation packages. That means you can always install only the latest update, even if you skipped some in between! Thanks for the info! + + + + + /e/OS %1$s + /e/OS %1$s - %2$s diff --git a/src/org/lineageos/updater/UpdaterReceiver.java b/src/org/lineageos/updater/UpdaterReceiver.java index 1fb2c5a0..081b8d97 100644 --- a/src/org/lineageos/updater/UpdaterReceiver.java +++ b/src/org/lineageos/updater/UpdaterReceiver.java @@ -60,7 +60,7 @@ public class UpdaterReceiver extends BroadcastReceiver { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); String buildDate = StringGenerator.getDateLocalizedUTC(context, DateFormat.MEDIUM, preferences.getLong(Constants.PREF_INSTALL_NEW_TIMESTAMP, 0)); - String buildInfo = context.getString(R.string.list_build_version_date, + String buildInfo = context.getString(R.string.list_build_version_date_e, BuildInfoUtils.getBuildVersion(), buildDate); Intent notificationIntent = new Intent(context, UpdatesActivity.class); diff --git a/src/org/lineageos/updater/UpdatesListAdapter.java b/src/org/lineageos/updater/UpdatesListAdapter.java index 6650a783..1b97ce89 100644 --- a/src/org/lineageos/updater/UpdatesListAdapter.java +++ b/src/org/lineageos/updater/UpdatesListAdapter.java @@ -272,7 +272,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter Date: Wed, 24 Aug 2022 13:14:20 +0000 Subject: [PATCH 03/14] Updater: Get /e/ release notes Change-Id: I8345c9f2fc03df2339e157791aea5b8ed787b81f Updater: res: Redirect to proper changelog URL Change-Id: Ia16ba958968d84bb0b0e10e97e4085507d886905 --- res/menu/menu_toolbar.xml | 2 +- res/values/strings.xml | 5 ++++- src/org/lineageos/updater/misc/Constants.java | 1 + src/org/lineageos/updater/misc/Utils.java | 5 ++--- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/res/menu/menu_toolbar.xml b/res/menu/menu_toolbar.xml index 8b9117ce..09df5e68 100644 --- a/res/menu/menu_toolbar.xml +++ b/res/menu/menu_toolbar.xml @@ -12,6 +12,6 @@ app:showAsAction="never" /> diff --git a/res/values/strings.xml b/res/values/strings.xml index 37269d9e..097f644c 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -75,7 +75,7 @@ Copy URL Export update Show changelog - https://download.lineageos.org/%1$s/changes + https://gitlab.e.foundation/e/os/releases/-/releases/v%1$s-s Prioritize update process Update recovery It is impossible to disable Lineage Recovery updates on this device. @@ -163,4 +163,7 @@ /e/OS %1$s /e/OS %1$s - %2$s + + + Show release notes diff --git a/src/org/lineageos/updater/misc/Constants.java b/src/org/lineageos/updater/misc/Constants.java index 6144ed74..0f4f8a78 100644 --- a/src/org/lineageos/updater/misc/Constants.java +++ b/src/org/lineageos/updater/misc/Constants.java @@ -46,6 +46,7 @@ public final class Constants { public static final String PROP_RELEASE_TYPE = "ro.lineage.releasetype"; public static final String PROP_UPDATER_ALLOW_DOWNGRADING = "lineage.updater.allow_downgrading"; public static final String PROP_UPDATER_URI = "lineage.updater.uri"; + public static final String PROP_VERSION = "ro.lineage.version"; public static final String PREF_INSTALL_OLD_TIMESTAMP = "install_old_timestamp"; public static final String PREF_INSTALL_NEW_TIMESTAMP = "install_new_timestamp"; diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index 79ded8f2..f0724945 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -172,9 +172,8 @@ public class Utils { } public static String getChangelogURL(Context context) { - String device = SystemProperties.get(Constants.PROP_NEXT_DEVICE, - SystemProperties.get(Constants.PROP_DEVICE)); - return context.getString(R.string.menu_changelog_url, device); + String buildVersion = SystemProperties.get(Constants.PROP_BUILD_VERSION); + return context.getString(R.string.menu_changelog_url, buildVersion); } public static void triggerUpdate(Context context, String downloadId) { -- GitLab From f9d9ba53393f8c70717a6fb70d2363cc289aea7b Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Wed, 11 Jul 2018 10:16:02 +0200 Subject: [PATCH 04/14] Updater: Change default user-agent Change-Id: Ie5d8624b4fa92012459a7c4e05494a926024bba0 --- .../lineageos/updater/download/HttpURLConnectionClient.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/org/lineageos/updater/download/HttpURLConnectionClient.java b/src/org/lineageos/updater/download/HttpURLConnectionClient.java index b9c4b5dc..a3d54c22 100644 --- a/src/org/lineageos/updater/download/HttpURLConnectionClient.java +++ b/src/org/lineageos/updater/download/HttpURLConnectionClient.java @@ -58,6 +58,11 @@ public class HttpURLConnectionClient implements DownloadClient { DownloadClient.DownloadCallback callback, boolean useDuplicateLinks) throws IOException { mClient = (HttpURLConnection) new URL(url).openConnection(); + + String defaultUserAgent = mClient.getRequestProperty("User-Agent"); + String newUserAgent = defaultUserAgent+" ota_007_eels"; + mClient.setRequestProperty("User-Agent", newUserAgent); + mDestination = destination; mProgressListener = progressListener; mCallback = callback; -- GitLab From d09ab994bd478709c802ea2bce11023bbce5060e Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Mon, 28 Sep 2020 15:46:49 +0000 Subject: [PATCH 05/14] Updater: Update the OTA url Signed-off-by: Aayush Gupta Change-Id: I1d53b83298ff322ce43d6730debf2b93bffd6458 --- 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 097f644c..16d6f216 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -32,7 +32,7 @@ {type} - Build type {incr} - Incremental version --> - https://download.lineageos.org/api/v1/{device}/{type}/{incr} + https://ota.ecloud.global/api/v1/{device}/{type}/{incr} Verification failed Verifying update -- GitLab From de5429cb5dfbbaa4cd20daaebd5f9a4e8b6f9b70 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Thu, 24 Jan 2019 16:29:59 +0000 Subject: [PATCH 06/14] Updater: Allow OTA updates with different version number Signed-off-by: Aayush Gupta Change-Id: I24ee83c5a94f47742f6c9cad23630bc6833cfe81 --- src/org/lineageos/updater/misc/Utils.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index f0724945..3b12a975 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -112,9 +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.getVersion().equalsIgnoreCase( - SystemProperties.get(Constants.PROP_BUILD_VERSION)); + update.getTimestamp() > SystemProperties.getLong(Constants.PROP_BUILD_DATE, 0)); } public static List parseJson(File file, boolean compatibleOnly) -- GitLab From 1fb094c648e5ca95fb022fe1cf545a065980de2e Mon Sep 17 00:00:00 2001 From: Sooraj S Date: Tue, 28 Jul 2020 14:23:25 +0000 Subject: [PATCH 07/14] Updater: Use helper function for parsing version code Fix: Handle use case 1.0 is bigger than 0.9 Semantic versioning Signed-off-by: Alexandre Roux D'Anzi Signed-off-by: Aayush Gupta Change-Id: Id107366ebf38f1e269101b4baeac10f3991fe1bb --- src/org/lineageos/updater/misc/Utils.java | 39 ++++++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index 3b12a975..19c6e92e 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -52,6 +52,8 @@ import java.util.Locale; import java.util.Set; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; +import java.util.regex.Pattern; + public class Utils { @@ -94,12 +96,19 @@ public class Utils { } public static boolean isCompatible(UpdateBaseInfo update) { - if (update.getVersion().compareTo(SystemProperties.get(Constants.PROP_BUILD_VERSION)) < 0) { - Log.d(TAG, update.getName() + " is older than current Android version"); - return false; - } + int[] updateVersionParts = parseSemVer(update.getVersion()); + int updateMajorVersion = updateVersionParts[0]; + int updateMinorVersion = updateVersionParts[1]; + Log.d(TAG, "Update : Major "+updateMajorVersion +" Minor "+ updateMinorVersion ); + + int[] deviceVersionParts = parseSemVer(SystemProperties.get(Constants.PROP_BUILD_VERSION)); + int deviceMajorVersion = deviceVersionParts[0]; + int deviceMinorVersion = deviceVersionParts[1]; + Log.d(TAG, "Device : Major "+ deviceMajorVersion +" Minor "+ deviceMinorVersion ); + + if (!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)) { Log.d(TAG, update.getName() + " is older than/equal to the current build"); return false; } @@ -107,9 +116,29 @@ public class Utils { Log.d(TAG, update.getName() + " has type " + update.getType()); return false; } + if(updateMajorVersion > deviceMajorVersion){ + Log.d(TAG, update.getName() + " is Newer to current Major version"); + return true; + } + if(updateMajorVersion < deviceMajorVersion){ + Log.d(TAG, update.getName() + " is Older to current Major version"); + return false; + } + if(updateMinorVersion < deviceMinorVersion){ + Log.d(TAG, update.getName() + " is Older to current Minor version"); + return false; + } + return true; } + public static int[] parseSemVer(String versionCode) { + String[] versionParts = versionCode.split(Pattern.quote(".")); + int major = Integer.parseInt(versionParts[0]); + int minor = Integer.parseInt(versionParts[1]); + return new int[]{ major, minor }; + } + public static boolean canInstall(UpdateBaseInfo update) { return (SystemProperties.getBoolean(Constants.PROP_UPDATER_ALLOW_DOWNGRADING, false) || update.getTimestamp() > SystemProperties.getLong(Constants.PROP_BUILD_DATE, 0)); -- GitLab From 8187963e8aa73b7cc8cd303e7c89544e217520ac Mon Sep 17 00:00:00 2001 From: Mohit Mali Date: Mon, 15 Feb 2021 15:13:40 +0530 Subject: [PATCH 08/14] Updater: Check updates daily Signed-off-by: Aayush Gupta Change-Id: Iad764a791645bdcaa28ebb01b9426afe4aa68393 --- 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 19c6e92e..c58d3b8f 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -407,7 +407,7 @@ public class Utils { public static int getUpdateCheckSetting(Context context) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); return preferences.getInt(Constants.PREF_AUTO_UPDATES_CHECK_INTERVAL, - Constants.AUTO_UPDATES_CHECK_INTERVAL_WEEKLY); + Constants.AUTO_UPDATES_CHECK_INTERVAL_DAILY); } public static boolean isUpdateCheckEnabled(Context context) { -- GitLab From 5fd0c39a153eb3dabacc9b3eef48dad8a85562a5 Mon Sep 17 00:00:00 2001 From: Aayush Gupta Date: Tue, 23 Mar 2021 10:59:02 +0530 Subject: [PATCH 09/14] Updater: Enable auto deletion of updates by default Signed-off-by: Aayush Gupta Change-Id: Iea43138b6538233b8966db3274ea22c8875a82f8 --- src/org/lineageos/updater/UpdatesActivity.java | 2 +- src/org/lineageos/updater/controller/UpdaterService.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 9c56f0bb..3e5f5f30 100644 --- a/src/org/lineageos/updater/UpdatesActivity.java +++ b/src/org/lineageos/updater/UpdatesActivity.java @@ -491,7 +491,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/UpdaterService.java b/src/org/lineageos/updater/controller/UpdaterService.java index 0142df65..5d799bf9 100644 --- a/src/org/lineageos/updater/controller/UpdaterService.java +++ b/src/org/lineageos/updater/controller/UpdaterService.java @@ -407,7 +407,7 @@ public class UpdaterService extends Service { mNotificationManager.notify(NOTIFICATION_ID, mNotificationBuilder.build()); SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this); - boolean deleteUpdate = pref.getBoolean(Constants.PREF_AUTO_DELETE_UPDATES, false); + boolean deleteUpdate = pref.getBoolean(Constants.PREF_AUTO_DELETE_UPDATES, true); if (deleteUpdate) { mUpdaterController.deleteUpdate(update.getDownloadId()); } diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index c58d3b8f..d617829a 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -306,7 +306,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 1bc6f90bcd6a28ad137fa7f522b29b17c62c16e0 Mon Sep 17 00:00:00 2001 From: Aayush Gupta Date: Thu, 25 Mar 2021 12:32:31 +0530 Subject: [PATCH 10/14] 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 Change-Id: I839033daa355f7faddb4ff641f1ffa59600b7472 --- 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 3e5f5f30..71dc38ed 100644 --- a/src/org/lineageos/updater/UpdatesActivity.java +++ b/src/org/lineageos/updater/UpdatesActivity.java @@ -330,7 +330,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 7fa9cd5c..93dcf943 100644 --- a/src/org/lineageos/updater/UpdatesCheckReceiver.java +++ b/src/org/lineageos/updater/UpdatesCheckReceiver.java @@ -90,7 +90,7 @@ public class UpdatesCheckReceiver extends BroadcastReceiver { @Override public void onSuccess() { 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 d617829a..7afdc9b6 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -226,22 +226,17 @@ 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 */ - 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 From 9a04c98ec6fa59169d386d93c1cc9870d336594b Mon Sep 17 00:00:00 2001 From: Mohit Mali Date: Fri, 2 Apr 2021 18:48:31 +0000 Subject: [PATCH 11/14] Updater: Check in Settings if the device has to fetch updates from the staging OTA server Change-Id: Ice445b0ae4086dfbea91b3a34b7f13c3553282d0 --- res/values/strings.xml | 1 + src/org/lineageos/updater/misc/Utils.java | 31 ++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 16d6f216..a4a7710c 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -33,6 +33,7 @@ {incr} - Incremental version --> https://ota.ecloud.global/api/v1/{device}/{type}/{incr} + https://test.ota.ecloud.global/api/v1/{device}/{type}/{incr} Verification failed Verifying update diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index 7afdc9b6..7150af1a 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -1,5 +1,6 @@ /* * Copyright (C) 2017-2022 The LineageOS Project + * Copyright (C) 2022 ECORP SAS * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,8 +23,10 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageManager; +import android.database.Cursor; import android.net.ConnectivityManager; import android.net.NetworkInfo; +import android.net.Uri; import android.os.SystemProperties; import android.os.storage.StorageManager; import android.preference.PreferenceManager; @@ -58,6 +61,7 @@ import java.util.regex.Pattern; public class Utils { private static final String TAG = "Utils"; + private static final String CONTENT_URI_PATH = "content://custom.setting.Provider.OTA_SERVER/cte"; private Utils() { } @@ -182,7 +186,20 @@ public class Utils { SystemProperties.get(Constants.PROP_DEVICE)); String type = SystemProperties.get(Constants.PROP_RELEASE_TYPE).toLowerCase(Locale.ROOT); - String serverUrl = SystemProperties.get(Constants.PROP_UPDATER_URI); + String serverUrl = ""; + if (retrieveStatus(context) != null) { + if (retrieveStatus(context).equals("true")) { + serverUrl = context.getString(R.string.ota_staging_server_url); + return serverUrl.replace("{device}", device) + .replace("{type}", type) + .replace("{incr}", incrementalVersion); + } else { + serverUrl = SystemProperties.get(Constants.PROP_UPDATER_URI); + } + } else { + serverUrl = SystemProperties.get(Constants.PROP_UPDATER_URI); + } + if (serverUrl.trim().isEmpty()) { serverUrl = context.getString(R.string.updater_server_url); } @@ -192,6 +209,18 @@ public class Utils { .replace("{incr}", incrementalVersion); } + /*get the status from database that ota option is on or off*/ + public static String retrieveStatus(Context context) { + String status = null; + Cursor cursor = context.getContentResolver().query(Uri.parse(CONTENT_URI_PATH), null, "id=?", new String[]{"1"}, "Status"); + if (cursor.moveToFirst()) { + do { + status = cursor.getString(cursor.getColumnIndex("Status")); + } while (cursor.moveToNext()); + } + return status; + } + public static String getUpgradeBlockedURL(Context context) { String device = SystemProperties.get(Constants.PROP_NEXT_DEVICE, SystemProperties.get(Constants.PROP_DEVICE)); -- GitLab From 45a369b4eee493af1d4517b7fe082319ac567ae0 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Thu, 16 Aug 2018 11:29:48 +0200 Subject: [PATCH 12/14] Change displayed version value Change-Id: I28123e3108e795150f1c038de62e379ee2ae0e69 Update database schema Updater: Adapt displayVersion to show proper versioning Change-Id: I9f936bde0a380f0b80fe4382776641082a2b2a12 --- src/org/lineageos/updater/UpdatesActivity.java | 2 +- src/org/lineageos/updater/UpdatesDbHelper.java | 8 +++++++- src/org/lineageos/updater/UpdatesListAdapter.java | 3 ++- src/org/lineageos/updater/misc/BuildInfoUtils.java | 4 ++++ src/org/lineageos/updater/misc/Constants.java | 1 + src/org/lineageos/updater/misc/Utils.java | 5 +++++ src/org/lineageos/updater/model/UpdateBase.java | 11 +++++++++++ src/org/lineageos/updater/model/UpdateBaseInfo.java | 2 ++ 8 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/org/lineageos/updater/UpdatesActivity.java b/src/org/lineageos/updater/UpdatesActivity.java index 71dc38ed..4e916a27 100644 --- a/src/org/lineageos/updater/UpdatesActivity.java +++ b/src/org/lineageos/updater/UpdatesActivity.java @@ -151,7 +151,7 @@ public class UpdatesActivity extends UpdatesListActivity { TextView headerTitle = findViewById(R.id.header_title); headerTitle.setText(getString(R.string.header_title_text, - BuildInfoUtils.getBuildVersion())); + BuildInfoUtils.getDisplayVersion())); updateLastCheckedString(); diff --git a/src/org/lineageos/updater/UpdatesDbHelper.java b/src/org/lineageos/updater/UpdatesDbHelper.java index 6c11a60c..9dadd4b6 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 = 1; + public static final int DATABASE_VERSION = 2; public static final String DATABASE_NAME = "updates.db"; public static class UpdateEntry implements BaseColumns { @@ -41,6 +41,7 @@ public class UpdatesDbHelper extends SQLiteOpenHelper { public static final String COLUMN_NAME_TIMESTAMP = "timestamp"; 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_SIZE = "size"; } @@ -53,6 +54,7 @@ public class UpdatesDbHelper extends SQLiteOpenHelper { UpdateEntry.COLUMN_NAME_TIMESTAMP + " INTEGER," + UpdateEntry.COLUMN_NAME_TYPE + " TEXT," + UpdateEntry.COLUMN_NAME_VERSION + " TEXT," + + UpdateEntry.COLUMN_NAME_DISPLAY_VERSION + " TEXT," + UpdateEntry.COLUMN_NAME_SIZE + " INTEGER)"; private static final String SQL_DELETE_ENTRIES = @@ -89,6 +91,7 @@ public class UpdatesDbHelper extends SQLiteOpenHelper { values.put(UpdateEntry.COLUMN_NAME_TIMESTAMP, update.getTimestamp()); 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_SIZE, update.getFileSize()); } @@ -125,6 +128,7 @@ public class UpdatesDbHelper extends SQLiteOpenHelper { UpdateEntry.COLUMN_NAME_TIMESTAMP, UpdateEntry.COLUMN_NAME_TYPE, UpdateEntry.COLUMN_NAME_VERSION, + UpdateEntry.COLUMN_NAME_DISPLAY_VERSION, UpdateEntry.COLUMN_NAME_STATUS, UpdateEntry.COLUMN_NAME_SIZE, }; @@ -146,6 +150,8 @@ public class UpdatesDbHelper extends SQLiteOpenHelper { update.setType(cursor.getString(index)); index = cursor.getColumnIndex(UpdateEntry.COLUMN_NAME_VERSION); update.setVersion(cursor.getString(index)); + index = cursor.getColumnIndex(UpdateEntry.COLUMN_NAME_DISPLAY_VERSION); + update.setDisplayVersion(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 1b97ce89..c326b558 100644 --- a/src/org/lineageos/updater/UpdatesListAdapter.java +++ b/src/org/lineageos/updater/UpdatesListAdapter.java @@ -274,6 +274,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter Date: Wed, 24 Aug 2022 13:25:31 +0000 Subject: [PATCH 13/14] Updater: Change dialog text Change-Id: Ic9f5d78d9983e6e3c3f743547ea4077c6c520a1f --- res/values/strings.xml | 3 +++ src/org/lineageos/updater/UpdatesListAdapter.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index a4a7710c..7dcb92a9 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -167,4 +167,7 @@ Show release notes + + + /e/OS updates are full installation packages. That means you can always install only the latest update, even if you skipped some in between! diff --git a/src/org/lineageos/updater/UpdatesListAdapter.java b/src/org/lineageos/updater/UpdatesListAdapter.java index c326b558..c4e9b819 100644 --- a/src/org/lineageos/updater/UpdatesListAdapter.java +++ b/src/org/lineageos/updater/UpdatesListAdapter.java @@ -513,7 +513,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter preferences.edit() .putBoolean(Constants.HAS_SEEN_INFO_DIALOG, true) .apply()) -- GitLab From efc97fe78ee4e90437b5126cea45ae50165416a7 Mon Sep 17 00:00:00 2001 From: Aayush Gupta Date: Mon, 23 May 2022 10:26:53 +0530 Subject: [PATCH 14/14] Updater: UpdatesCheckReceiver: Migrate to setExactAndAllowWhileIdle Signed-off-by: Aayush Gupta fixup! Updater: UpdatesCheckReceiver: Migrate to setExactAndAllowWhileIdle This commit partially reverts 99cd083ee69a97042ab8a0e790ee08e6e3aa3a15 (cherry picked from commit 90642329db2c9959d59eee61d8f6ee0e9f011233) --- src/org/lineageos/updater/UpdatesCheckReceiver.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/org/lineageos/updater/UpdatesCheckReceiver.java b/src/org/lineageos/updater/UpdatesCheckReceiver.java index 93dcf943..9cb3d755 100644 --- a/src/org/lineageos/updater/UpdatesCheckReceiver.java +++ b/src/org/lineageos/updater/UpdatesCheckReceiver.java @@ -160,8 +160,8 @@ public class UpdatesCheckReceiver extends BroadcastReceiver { PendingIntent updateCheckIntent = getRepeatingUpdatesCheckIntent(context); AlarmManager alarmMgr = context.getSystemService(AlarmManager.class); - alarmMgr.setRepeating(AlarmManager.RTC, System.currentTimeMillis() + - Utils.getUpdateCheckInterval(context), Utils.getUpdateCheckInterval(context), + alarmMgr.setExactAndAllowWhileIdle(AlarmManager.RTC, + System.currentTimeMillis() + Utils.getUpdateCheckInterval(context), updateCheckIntent); Date nextCheckDate = new Date(System.currentTimeMillis() + @@ -184,7 +184,7 @@ public class UpdatesCheckReceiver extends BroadcastReceiver { long millisToNextCheck = AlarmManager.INTERVAL_HOUR * 2; PendingIntent updateCheckIntent = getUpdatesCheckIntent(context); AlarmManager alarmMgr = context.getSystemService(AlarmManager.class); - alarmMgr.set(AlarmManager.ELAPSED_REALTIME, + alarmMgr.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + millisToNextCheck, updateCheckIntent); -- GitLab