From cb92eb8ceac691999be5713132a8c7ffeda5ccaa Mon Sep 17 00:00:00 2001 From: TheScarastic Date: Wed, 24 Aug 2022 13:05:29 +0000 Subject: [PATCH 01/43] 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 7cf04a89..c2886678 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 02/43] 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 011dc8ae..e36c3e3a 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -173,9 +173,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 fbb00bcf4147fd4792ff08b49633ab6b4dbb55e3 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Wed, 11 Jul 2018 10:16:02 +0200 Subject: [PATCH 03/43] 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 aba1eff6f8092652d7976ee00c35264358150d76 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Mon, 28 Sep 2020 15:46:49 +0000 Subject: [PATCH 04/43] 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 003a8e3ed20f03b20da505d3966b9f269949c7d2 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Thu, 24 Jan 2019 16:29:59 +0000 Subject: [PATCH 05/43] 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 e36c3e3a..d662f206 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -113,9 +113,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 1785e95d0c2321449db80c3abd659bba5c434603 Mon Sep 17 00:00:00 2001 From: Sooraj S Date: Tue, 28 Jul 2020 14:23:25 +0000 Subject: [PATCH 06/43] 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 d662f206..4fa9191d 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -53,6 +53,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 { @@ -95,12 +97,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; } @@ -108,9 +117,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 6c8946952ce77170aea76fab207153f034bfdde7 Mon Sep 17 00:00:00 2001 From: Mohit Mali Date: Mon, 15 Feb 2021 15:13:40 +0530 Subject: [PATCH 07/43] 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 4fa9191d..de4c2b6d 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -408,7 +408,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 ed6779004a519e814c994d29394653e6b7397f6b Mon Sep 17 00:00:00 2001 From: Aayush Gupta Date: Tue, 23 Mar 2021 10:59:02 +0530 Subject: [PATCH 08/43] 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 de4c2b6d..4718b422 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -307,7 +307,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 f659dff38a6705e219286cd8a91934e025fb378a Mon Sep 17 00:00:00 2001 From: Aayush Gupta Date: Thu, 25 Mar 2021 12:32:31 +0530 Subject: [PATCH 09/43] 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 9f454239..275b3519 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 4718b422..9ad5868c 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -227,22 +227,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 a1face39d55ecae3144bca8723154fb7030daec0 Mon Sep 17 00:00:00 2001 From: Mohit Mali Date: Fri, 2 Apr 2021 18:48:31 +0000 Subject: [PATCH 10/43] 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 9ad5868c..5fcee7a4 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.util.Log; @@ -59,6 +62,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() { } @@ -183,7 +187,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); } @@ -193,6 +210,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 248499761589fd65af8a789c71aa037bbdebb221 Mon Sep 17 00:00:00 2001 From: Romain Hunault Date: Thu, 16 Aug 2018 11:29:48 +0200 Subject: [PATCH 11/43] 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 c2886678..da01debc 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 12/43] 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 da01debc..4ecf54f3 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 8ba580391a0f6abc5539a6618f3d618c7feb6fc7 Mon Sep 17 00:00:00 2001 From: Aayush Gupta Date: Mon, 23 May 2022 10:26:53 +0530 Subject: [PATCH 13/43] 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 275b3519..1bc3bf3e 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 From 7ce7315694decdfba2458eda678fb155ecce38a3 Mon Sep 17 00:00:00 2001 From: TheScarastic Date: Tue, 20 Sep 2022 12:59:40 +0000 Subject: [PATCH 14/43] Updater: Add support for SystemUpdateManager status --- .../lineageos/updater/UpdatesActivity.java | 2 +- .../updater/UpdatesCheckReceiver.java | 2 +- .../updater/controller/UpdaterService.java | 21 +++++++++ src/org/lineageos/updater/misc/Utils.java | 45 +++++++++++++++---- 4 files changed, 60 insertions(+), 10 deletions(-) diff --git a/src/org/lineageos/updater/UpdatesActivity.java b/src/org/lineageos/updater/UpdatesActivity.java index 4e916a27..8bfd2b9c 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(jsonNew)) { + Utils.checkForNewUpdates(jsonNew, this)) { 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 1bc3bf3e..07beb1a7 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(jsonNew)) { + if (json.exists() && Utils.checkForNewUpdates(jsonNew, context)) { showNotification(context); updateRepeatingUpdatesCheck(context); } diff --git a/src/org/lineageos/updater/controller/UpdaterService.java b/src/org/lineageos/updater/controller/UpdaterService.java index 5d799bf9..c0354f92 100644 --- a/src/org/lineageos/updater/controller/UpdaterService.java +++ b/src/org/lineageos/updater/controller/UpdaterService.java @@ -15,6 +15,10 @@ */ package org.lineageos.updater.controller; +import static android.os.SystemUpdateManager.STATUS_IN_PROGRESS; +import static android.os.SystemUpdateManager.STATUS_WAITING_DOWNLOAD; +import static android.os.SystemUpdateManager.STATUS_WAITING_REBOOT; + import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.PendingIntent; @@ -254,6 +258,7 @@ public class UpdaterService extends Service { private void handleUpdateStatusChange(UpdateInfo update) { switch (update.getStatus()) { case DELETED: { + notifySystemUpdaterService(STATUS_WAITING_DOWNLOAD, update); stopForeground(STOP_FOREGROUND_DETACH); mNotificationBuilder.setOngoing(false); mNotificationManager.cancel(NOTIFICATION_ID); @@ -261,6 +266,7 @@ public class UpdaterService extends Service { break; } case STARTING: { + notifySystemUpdaterService(STATUS_IN_PROGRESS, update); mNotificationBuilder.mActions.clear(); mNotificationBuilder.setProgress(0, 0, true); mNotificationStyle.setSummaryText(null); @@ -276,6 +282,7 @@ public class UpdaterService extends Service { break; } case DOWNLOADING: { + notifySystemUpdaterService(STATUS_IN_PROGRESS, update); String text = getString(R.string.downloading_notification); mNotificationStyle.bigText(text); mNotificationBuilder.setStyle(mNotificationStyle); @@ -290,6 +297,7 @@ public class UpdaterService extends Service { break; } case PAUSED: { + notifySystemUpdaterService(STATUS_WAITING_DOWNLOAD, update); stopForeground(STOP_FOREGROUND_DETACH); // In case we pause before the first progress update mNotificationBuilder.setProgress(100, update.getProgress(), false); @@ -309,6 +317,7 @@ public class UpdaterService extends Service { break; } case PAUSED_ERROR: { + notifySystemUpdaterService(STATUS_WAITING_DOWNLOAD, update); stopForeground(STOP_FOREGROUND_DETACH); int progress = update.getProgress(); // In case we pause before the first progress update @@ -329,6 +338,7 @@ public class UpdaterService extends Service { break; } case VERIFYING: { + notifySystemUpdaterService(STATUS_IN_PROGRESS, update); mNotificationBuilder.setProgress(0, 0, true); mNotificationStyle.setSummaryText(null); mNotificationBuilder.setStyle(mNotificationStyle); @@ -341,6 +351,7 @@ public class UpdaterService extends Service { break; } case VERIFIED: { + notifySystemUpdaterService(STATUS_IN_PROGRESS, update); stopForeground(STOP_FOREGROUND_DETACH); mNotificationBuilder.setStyle(null); mNotificationBuilder.setSmallIcon(R.drawable.ic_system_update); @@ -355,6 +366,7 @@ public class UpdaterService extends Service { break; } case VERIFICATION_FAILED: { + notifySystemUpdaterService(STATUS_WAITING_DOWNLOAD, update); stopForeground(STOP_FOREGROUND_DETACH); mNotificationBuilder.setStyle(null); mNotificationBuilder.setSmallIcon(android.R.drawable.stat_sys_warning); @@ -369,6 +381,7 @@ public class UpdaterService extends Service { break; } case INSTALLING: { + notifySystemUpdaterService(STATUS_IN_PROGRESS, update); mNotificationBuilder.mActions.clear(); mNotificationBuilder.setStyle(mNotificationStyle); mNotificationBuilder.setSmallIcon(R.drawable.ic_system_update); @@ -391,6 +404,7 @@ public class UpdaterService extends Service { break; } case INSTALLED: { + notifySystemUpdaterService(STATUS_WAITING_REBOOT, update); stopForeground(STOP_FOREGROUND_DETACH); mNotificationBuilder.mActions.clear(); mNotificationBuilder.setStyle(null); @@ -416,6 +430,7 @@ public class UpdaterService extends Service { break; } case INSTALLATION_FAILED: { + notifySystemUpdaterService(STATUS_WAITING_DOWNLOAD, update); stopForeground(STOP_FOREGROUND_DETACH); mNotificationBuilder.setStyle(null); mNotificationBuilder.setSmallIcon(android.R.drawable.stat_sys_warning); @@ -430,11 +445,13 @@ public class UpdaterService extends Service { break; } case INSTALLATION_CANCELLED: { + notifySystemUpdaterService(STATUS_WAITING_DOWNLOAD, update); stopForeground(true); tryStopSelf(); break; } case INSTALLATION_SUSPENDED: { + notifySystemUpdaterService(STATUS_WAITING_DOWNLOAD, update); stopForeground(STOP_FOREGROUND_DETACH); // In case we pause before the first progress update mNotificationBuilder.setProgress(100, update.getProgress(), false); @@ -534,4 +551,8 @@ public class UpdaterService extends Service { return PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); } + + private void notifySystemUpdaterService(int status, UpdateInfo update) { + Utils.updateSystemUpdaterService(this, status, Float.parseFloat(update.getVersion())); + } } diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index 581c94f8..0aff9ad8 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -16,6 +16,12 @@ */ package org.lineageos.updater.misc; +import static android.os.SystemUpdateManager.KEY_STATUS; +import static android.os.SystemUpdateManager.KEY_TITLE; +import static android.os.SystemUpdateManager.STATUS_IDLE; +import static android.os.SystemUpdateManager.STATUS_WAITING_DOWNLOAD; +import static android.os.SystemUpdateManager.STATUS_UNKNOWN; + import android.app.AlarmManager; import android.content.ClipData; import android.content.ClipboardManager; @@ -27,7 +33,10 @@ import android.database.Cursor; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.Uri; +import android.os.Bundle; +import android.os.PersistableBundle; import android.os.SystemProperties; +import android.os.SystemUpdateManager; import android.os.storage.StorageManager; import android.util.Log; import android.widget.Toast; @@ -58,7 +67,6 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import java.util.regex.Pattern; - public class Utils { private static final String TAG = "Utils"; @@ -264,18 +272,25 @@ public class Utils { * @param newJson new update list * @return true if newJson has an update with higher version than the installed system */ - public static boolean checkForNewUpdates(File newJson) + public static boolean checkForNewUpdates(File newJson, Context context) throws IOException, JSONException { List newList = parseJson(newJson, true); - float currentVersion = Float.parseFloat(BuildInfoUtils.getBuildVersion()); - + final float currentVersion = Float.parseFloat(BuildInfoUtils.getBuildVersion()); + float highestAvailableVersion = currentVersion; for (UpdateInfo update : newList) { - if (Float.parseFloat(update.getVersion()) > currentVersion) { - Log.d(TAG, "New compatiable update available"); - return true; + float availableversion = Float.parseFloat(update.getVersion()); + if (availableversion > highestAvailableVersion) { + highestAvailableVersion = availableversion; } } - return false; + + if (highestAvailableVersion > currentVersion) { + updateSystemUpdaterService(context, STATUS_WAITING_DOWNLOAD, highestAvailableVersion); + return true; + } else { + updateSystemUpdaterService(context, STATUS_IDLE, highestAvailableVersion); + return false; + } } /** @@ -459,4 +474,18 @@ public class Utils { public static boolean isRecoveryUpdateExecPresent() { return new File(Constants.UPDATE_RECOVERY_EXEC).exists(); } + + public static void updateSystemUpdaterService(Context context, int status, float version) { + final SystemUpdateManager updateManager = context.getSystemService(SystemUpdateManager.class); + + final Bundle oldInfo = updateManager.retrieveSystemUpdateInfo(); + final int oldStatus = oldInfo.getInt(SystemUpdateManager.KEY_STATUS); + + if (status != oldStatus) { + PersistableBundle infoBundle = new PersistableBundle(); + infoBundle.putInt(KEY_STATUS, status); + infoBundle.putString(KEY_TITLE, String.valueOf(version)); + updateManager.updateSystemUpdateInfo(infoBundle); + } + } } -- GitLab From 3b1141a9473035f2fc00e2ebda2a9c8a31017a19 Mon Sep 17 00:00:00 2001 From: Nishith Khanna Date: Wed, 7 Sep 2022 15:05:21 +0530 Subject: [PATCH 15/43] Change current version title to our brand name --- res/values/strings.xml | 3 +++ src/org/lineageos/updater/UpdatesActivity.java | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 7dcb92a9..4610b39d 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -170,4 +170,7 @@ /e/OS updates are full installation packages. That means you can always install only the latest update, even if you skipped some in between! + + + /e/OS\n%1$s diff --git a/src/org/lineageos/updater/UpdatesActivity.java b/src/org/lineageos/updater/UpdatesActivity.java index 8bfd2b9c..1fa79e5b 100644 --- a/src/org/lineageos/updater/UpdatesActivity.java +++ b/src/org/lineageos/updater/UpdatesActivity.java @@ -150,7 +150,7 @@ public class UpdatesActivity extends UpdatesListActivity { } TextView headerTitle = findViewById(R.id.header_title); - headerTitle.setText(getString(R.string.header_title_text, + headerTitle.setText(getString(R.string.header_title_text_e, BuildInfoUtils.getDisplayVersion())); updateLastCheckedString(); -- GitLab From 83130594295a72b913479dc4d278f1e669ff02d9 Mon Sep 17 00:00:00 2001 From: Nishith Khanna Date: Tue, 11 Oct 2022 15:17:06 +0530 Subject: [PATCH 16/43] Theme app according to our palette --- Android.bp | 1 + res/layout/activity_updates.xml | 17 +++++++++++++---- res/values-night/colors.xml | 4 ---- res/values/colors.xml | 6 +++--- res/values/styles.xml | 16 ++++++++++++++++ src/org/lineageos/updater/UpdatesActivity.java | 3 ++- 6 files changed, 35 insertions(+), 12 deletions(-) diff --git a/Android.bp b/Android.bp index da2137fd..baf92c34 100644 --- a/Android.bp +++ b/Android.bp @@ -31,6 +31,7 @@ android_app { "androidx.localbroadcastmanager_localbroadcastmanager", "androidx.preference_preference", "androidx.recyclerview_recyclerview", + "elib", ], platform_apis: true, diff --git a/res/layout/activity_updates.xml b/res/layout/activity_updates.xml index 4651a7e0..b6c3dc64 100644 --- a/res/layout/activity_updates.xml +++ b/res/layout/activity_updates.xml @@ -14,7 +14,7 @@ android:fitsSystemWindows="true" android:outlineAmbientShadowColor="@android:color/transparent" android:outlineSpotShadowColor="@android:color/transparent" - android:background="?android:attr/colorPrimary" + android:background="@color/toolbar_collapsed" android:theme="@style/Theme.CollapsingToolbar.Settings"> + + + android:textSize="30sp" /> diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml index 21b0fdcd..aa2cf345 100644 --- a/res/values-night/colors.xml +++ b/res/values-night/colors.xml @@ -2,9 +2,5 @@ #212121 #1c1c1c - @*android:color/accent_device_default_dark - @*android:color/system_neutral1_800 - @android:color/system_neutral1_700 - #f5f5f5 diff --git a/res/values/colors.xml b/res/values/colors.xml index a7add882..26fa91d8 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -2,9 +2,9 @@ #f5f5f5 #e0e0e0 - @*android:color/accent_device_default_light - @*android:color/system_neutral1_0 - @android:color/system_neutral1_100 + @color/e_accent + @color/e_background_variant + @color/e_action_bar #FF0E0E0F #222222 diff --git a/res/values/styles.xml b/res/values/styles.xml index c3efca45..a71cb33d 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -8,6 +8,9 @@ @bool/theme_is_light @bool/theme_is_light @color/background + @style/Dialog + @style/Snackbar + @style/Switch + + + + + diff --git a/src/org/lineageos/updater/UpdatesActivity.java b/src/org/lineageos/updater/UpdatesActivity.java index 1fa79e5b..d99cb09d 100644 --- a/src/org/lineageos/updater/UpdatesActivity.java +++ b/src/org/lineageos/updater/UpdatesActivity.java @@ -51,6 +51,7 @@ import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.widget.SwitchCompat; import androidx.appcompat.widget.Toolbar; +import androidx.core.content.ContextCompat; import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.preference.PreferenceManager; import androidx.recyclerview.widget.LinearLayoutManager; @@ -440,7 +441,7 @@ public class UpdatesActivity extends UpdatesListActivity { @Override public void showSnackbar(int stringId, int duration) { - Snackbar.make(findViewById(R.id.main_container), stringId, duration).show(); + Snackbar.make(findViewById(R.id.main_container), stringId, duration).setTextColor(ContextCompat.getColor(this, R.color.e_background)).show(); } private void refreshAnimationStart() { -- GitLab From a245b9b25b4a09f91cc3de1f8c7de721b8b00696 Mon Sep 17 00:00:00 2001 From: Alexandre Roux Date: Thu, 13 Oct 2022 14:35:53 +0000 Subject: [PATCH 17/43] S dont crash when receiving maintenance number --- .../download/HttpURLConnectionClient.java | 6 +++- src/org/lineageos/updater/misc/Utils.java | 30 ++++++++++++------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/org/lineageos/updater/download/HttpURLConnectionClient.java b/src/org/lineageos/updater/download/HttpURLConnectionClient.java index a3d54c22..df6283b5 100644 --- a/src/org/lineageos/updater/download/HttpURLConnectionClient.java +++ b/src/org/lineageos/updater/download/HttpURLConnectionClient.java @@ -16,6 +16,8 @@ package org.lineageos.updater.download; import android.os.SystemClock; +import android.os.SystemProperties; + import android.util.Log; import java.io.File; @@ -32,6 +34,8 @@ import java.util.PriorityQueue; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.lineageos.updater.misc.Constants; + public class HttpURLConnectionClient implements DownloadClient { private final static String TAG = "HttpURLConnectionClient"; @@ -60,7 +64,7 @@ public class HttpURLConnectionClient implements DownloadClient { mClient = (HttpURLConnection) new URL(url).openConnection(); String defaultUserAgent = mClient.getRequestProperty("User-Agent"); - String newUserAgent = defaultUserAgent+" ota_007_eels"; + String newUserAgent = defaultUserAgent + " eOS v" + SystemProperties.get(Constants.PROP_BUILD_VERSION); mClient.setRequestProperty("User-Agent", newUserAgent); mDestination = destination; diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index 0aff9ad8..9637be48 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -275,21 +275,31 @@ public class Utils { public static boolean checkForNewUpdates(File newJson, Context context) throws IOException, JSONException { List newList = parseJson(newJson, true); - final float currentVersion = Float.parseFloat(BuildInfoUtils.getBuildVersion()); + int[] deviceVersionParts = parseSemVer(SystemProperties.get(Constants.PROP_BUILD_VERSION)); + int deviceMajorVersion = deviceVersionParts[0]; + int deviceMinorVersion = deviceVersionParts[1]; + final float currentVersion = Float.parseFloat(deviceMajorVersion + "." + deviceMinorVersion); float highestAvailableVersion = currentVersion; + boolean hasUpdate = false; for (UpdateInfo update : newList) { - float availableversion = Float.parseFloat(update.getVersion()); - if (availableversion > highestAvailableVersion) { - highestAvailableVersion = availableversion; + if (isCompatible(update)) { + Log.d(TAG, "New compatible update available"); + int[] updateVersionParts = parseSemVer(update.getVersion()); + int updateMajorVersion = updateVersionParts[0]; + int updateMinorVersion = updateVersionParts[1]; + float thisUpdate = Float.parseFloat(updateMajorVersion + "." + updateMinorVersion); + if (thisUpdate > highestAvailableVersion) { + highestAvailableVersion = thisUpdate; + } + hasUpdate = true; } } - - if (highestAvailableVersion > currentVersion) { - updateSystemUpdaterService(context, STATUS_WAITING_DOWNLOAD, highestAvailableVersion); - return true; + if (hasUpdate) { + updateSystemUpdaterService(context, STATUS_WAITING_DOWNLOAD, highestAvailableVersion); + return true; } else { - updateSystemUpdaterService(context, STATUS_IDLE, highestAvailableVersion); - return false; + updateSystemUpdaterService(context, STATUS_IDLE, highestAvailableVersion); + return false; } } -- GitLab From d588bb99fafbebf0f90738c08fff562c74b20508 Mon Sep 17 00:00:00 2001 From: althafvly Date: Tue, 25 Oct 2022 10:47:07 +0530 Subject: [PATCH 18/43] Updater: add missing SCHEDULE_EXACT_ALARM permission --- AndroidManifest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index cc485f7a..92acabd9 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -10,6 +10,7 @@ + -- GitLab From a0712f4cf5119e26289b3da2bf6150e4e769fe6f Mon Sep 17 00:00:00 2001 From: althafvly Date: Tue, 25 Oct 2022 11:15:06 +0530 Subject: [PATCH 19/43] Updater: Update network utils for newer android --- src/org/lineageos/updater/misc/Utils.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index 9637be48..e4823801 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -31,7 +31,8 @@ import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.database.Cursor; import android.net.ConnectivityManager; -import android.net.NetworkInfo; +import android.net.Network; +import android.net.NetworkCapabilities; import android.net.Uri; import android.os.Bundle; import android.os.PersistableBundle; @@ -255,15 +256,19 @@ public class Utils { public static boolean isNetworkAvailable(Context context) { ConnectivityManager cm = context.getSystemService(ConnectivityManager.class); - NetworkInfo info = cm.getActiveNetworkInfo(); - return !(info == null || !info.isConnected() || !info.isAvailable()); + Network activeNetwork = cm.getActiveNetwork(); + NetworkCapabilities networkCapabilities = cm.getNetworkCapabilities(activeNetwork); + return networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) + || networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) + || networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR); } public static boolean isOnWifiOrEthernet(Context context) { ConnectivityManager cm = context.getSystemService(ConnectivityManager.class); - NetworkInfo info = cm.getActiveNetworkInfo(); - return (info != null && (info.getType() == ConnectivityManager.TYPE_ETHERNET - || info.getType() == ConnectivityManager.TYPE_WIFI)); + Network activeNetwork = cm.getActiveNetwork(); + NetworkCapabilities networkCapabilities = cm.getNetworkCapabilities(activeNetwork); + return networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) + || networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET); } /** -- GitLab From 8d9a01e02423a79b6c3ca034c7887e9dad28842e Mon Sep 17 00:00:00 2001 From: althafvly Date: Mon, 31 Oct 2022 14:14:35 +0530 Subject: [PATCH 20/43] Updater: Fix NullPointerException on startup update check. Change-Id: I960db2adf1b10e104ab7f0002548dccc529a8ada --- src/org/lineageos/updater/misc/Utils.java | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index e4823801..c33bb081 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -258,17 +258,27 @@ public class Utils { ConnectivityManager cm = context.getSystemService(ConnectivityManager.class); Network activeNetwork = cm.getActiveNetwork(); NetworkCapabilities networkCapabilities = cm.getNetworkCapabilities(activeNetwork); - return networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) - || networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) - || networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR); + if (networkCapabilities != null + && networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) + && networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)) { + return networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) + || networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET) + || networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR); + } + return false; } public static boolean isOnWifiOrEthernet(Context context) { ConnectivityManager cm = context.getSystemService(ConnectivityManager.class); Network activeNetwork = cm.getActiveNetwork(); NetworkCapabilities networkCapabilities = cm.getNetworkCapabilities(activeNetwork); - return networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) - || networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET); + if (networkCapabilities != null + && networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) + && networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_VALIDATED)) { + return networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) + || networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_ETHERNET); + } + return false; } /** -- GitLab From 393c2174e1d3e3b3031102318c968468433f32f5 Mon Sep 17 00:00:00 2001 From: Nishith Khanna Date: Tue, 8 Nov 2022 17:36:30 +0530 Subject: [PATCH 21/43] Improvements in system page --- res/layout/activity_updates.xml | 31 +++++++++++++++---- res/values-en-rAU/strings.xml | 2 +- res/values-en-rCA/strings.xml | 2 +- res/values-en-rGB/strings.xml | 2 +- res/values-en-rIN/strings.xml | 2 +- res/values/strings.xml | 4 ++- .../lineageos/updater/UpdatesActivity.java | 8 ++--- 7 files changed, 36 insertions(+), 15 deletions(-) diff --git a/res/layout/activity_updates.xml b/res/layout/activity_updates.xml index b6c3dc64..3b956f56 100644 --- a/res/layout/activity_updates.xml +++ b/res/layout/activity_updates.xml @@ -115,12 +115,31 @@ android:textColor="?android:textColorSecondary" /> - + android:orientation="vertical" + app:layout_behavior="@string/appbar_scrolling_view_behavior"> + + + + + diff --git a/res/values-en-rAU/strings.xml b/res/values-en-rAU/strings.xml index 8628a36c..ad3cc423 100644 --- a/res/values-en-rAU/strings.xml +++ b/res/values-en-rAU/strings.xml @@ -70,7 +70,7 @@ %1$s of %2$s %1$s of %2$s (%3$s) Verifying update - No new updates found. To manually check for new updates, use the Refresh button. + You are running the latest /e/OS version. To manually check for updates, use the Refresh button. Download Pause Resume diff --git a/res/values-en-rCA/strings.xml b/res/values-en-rCA/strings.xml index 2e2611c0..84f9102d 100644 --- a/res/values-en-rCA/strings.xml +++ b/res/values-en-rCA/strings.xml @@ -70,7 +70,7 @@ %1$s of %2$s %1$s of %2$s (%3$s) Verifying update - No new updates found. To manually check for new updates, use the Refresh button. + You are running the latest /e/OS version. To manually check for updates, use the Refresh button. Download Pause Resume diff --git a/res/values-en-rGB/strings.xml b/res/values-en-rGB/strings.xml index ea66ddec..9e63df1f 100644 --- a/res/values-en-rGB/strings.xml +++ b/res/values-en-rGB/strings.xml @@ -70,7 +70,7 @@ %1$s of %2$s %1$s of %2$s (%3$s) Verifying update - No new updates found. To manually check for new updates, use the Refresh button. + You are running the latest /e/OS version. To manually check for updates, use the Refresh button. Download Pause Resume diff --git a/res/values-en-rIN/strings.xml b/res/values-en-rIN/strings.xml index ea66ddec..9e63df1f 100644 --- a/res/values-en-rIN/strings.xml +++ b/res/values-en-rIN/strings.xml @@ -70,7 +70,7 @@ %1$s of %2$s %1$s of %2$s (%3$s) Verifying update - No new updates found. To manually check for new updates, use the Refresh button. + You are running the latest /e/OS version. To manually check for updates, use the Refresh button. Download Pause Resume diff --git a/res/values/strings.xml b/res/values/strings.xml index 4610b39d..ac7427af 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -100,7 +100,7 @@ %1$s of %2$s %1$s of %2$s (%3$s) Verifying update - No new updates found. To manually check for new updates, use the Refresh button. + You are running the latest /e/OS version. To manually check for updates, use the Refresh button. Download Pause @@ -173,4 +173,6 @@ /e/OS\n%1$s + + Available updates: diff --git a/src/org/lineageos/updater/UpdatesActivity.java b/src/org/lineageos/updater/UpdatesActivity.java index d99cb09d..b27afc35 100644 --- a/src/org/lineageos/updater/UpdatesActivity.java +++ b/src/org/lineageos/updater/UpdatesActivity.java @@ -296,10 +296,10 @@ public class UpdatesActivity extends UpdatesListActivity { List sortedUpdates = controller.getUpdates(); if (sortedUpdates.isEmpty()) { findViewById(R.id.no_new_updates_view).setVisibility(View.VISIBLE); - findViewById(R.id.recycler_view).setVisibility(View.GONE); + findViewById(R.id.content).setVisibility(View.GONE); } else { findViewById(R.id.no_new_updates_view).setVisibility(View.GONE); - findViewById(R.id.recycler_view).setVisibility(View.VISIBLE); + findViewById(R.id.content).setVisibility(View.VISIBLE); sortedUpdates.sort((u1, u2) -> Long.compare(u2.getTimestamp(), u1.getTimestamp())); for (UpdateInfo update : sortedUpdates) { updateIds.add(update.getDownloadId()); @@ -455,7 +455,7 @@ public class UpdatesActivity extends UpdatesListActivity { mRefreshIconView.setEnabled(false); } } else { - findViewById(R.id.recycler_view).setVisibility(View.GONE); + findViewById(R.id.content).setVisibility(View.GONE); findViewById(R.id.no_new_updates_view).setVisibility(View.GONE); findViewById(R.id.refresh_progress).setVisibility(View.VISIBLE); } @@ -470,7 +470,7 @@ public class UpdatesActivity extends UpdatesListActivity { } else { findViewById(R.id.refresh_progress).setVisibility(View.GONE); if (mAdapter.getItemCount() > 0) { - findViewById(R.id.recycler_view).setVisibility(View.VISIBLE); + findViewById(R.id.content).setVisibility(View.VISIBLE); } else { findViewById(R.id.no_new_updates_view).setVisibility(View.VISIBLE); } -- GitLab From 2b2656945b898ea3e3cc1422e95ad049d3825ca1 Mon Sep 17 00:00:00 2001 From: althafvly Date: Mon, 7 Nov 2022 14:45:44 +0530 Subject: [PATCH 22/43] Updater: add additional intervals for debug Change-Id: Iddbb5da58cc5a8d7caca627a6747ccd8fe791c3c --- res/layout/preferences_dialog.xml | 3 +-- res/values/arrays.xml | 6 ++++++ res/values/strings.xml | 3 +++ .../lineageos/updater/UpdatesActivity.java | 20 +++++++++++++++++++ src/org/lineageos/updater/misc/Constants.java | 3 +++ src/org/lineageos/updater/misc/Utils.java | 13 ++++++++++++ 6 files changed, 46 insertions(+), 2 deletions(-) diff --git a/res/layout/preferences_dialog.xml b/res/layout/preferences_dialog.xml index c586f44e..2537dccb 100644 --- a/res/layout/preferences_dialog.xml +++ b/res/layout/preferences_dialog.xml @@ -25,8 +25,7 @@ android:id="@+id/preferences_auto_updates_check_interval" android:layout_width="0dp" android:layout_height="wrap_content" - android:layout_weight="1" - android:entries="@array/menu_auto_updates_check_interval_entries" /> + android:layout_weight="1" /> @string/menu_auto_updates_check_interval_weekly @string/menu_auto_updates_check_interval_monthly + + + @string/menu_auto_updates_check_interval_5_minutes + @string/menu_auto_updates_check_interval_10_minutes + @string/menu_auto_updates_check_interval_30_minutes + diff --git a/res/values/strings.xml b/res/values/strings.xml index ac7427af..a11e7439 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -67,6 +67,9 @@ Refresh Preferences Auto updates check + Every 5 minutes + Every 10 minutes + Every 30 minutes Once a day Once a week Once a month diff --git a/src/org/lineageos/updater/UpdatesActivity.java b/src/org/lineageos/updater/UpdatesActivity.java index b27afc35..408aff15 100644 --- a/src/org/lineageos/updater/UpdatesActivity.java +++ b/src/org/lineageos/updater/UpdatesActivity.java @@ -41,6 +41,7 @@ import android.view.View; import android.view.animation.Animation; import android.view.animation.LinearInterpolator; import android.view.animation.RotateAnimation; +import android.widget.ArrayAdapter; import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; @@ -75,6 +76,7 @@ import org.lineageos.updater.model.UpdateInfo; import java.io.File; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.UUID; @@ -491,7 +493,25 @@ public class UpdatesActivity extends UpdatesListActivity { } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); + + List intervalList = new ArrayList<>(Arrays.asList(getResources().getStringArray( + R.array.menu_auto_updates_check_interval_entries))); + + if (Utils.isDevModeOn(this)) { + // Add additional intervals while enabling developer options is on + intervalList.addAll(Arrays.asList(getResources().getStringArray( + R.array.menu_auto_updates_check_interval_entries_dev))); + } else if (Utils.getUpdateCheckSetting(this) > 3) { + prefs.edit().putInt(Constants.PREF_AUTO_UPDATES_CHECK_INTERVAL, + Constants.AUTO_UPDATES_CHECK_INTERVAL_DAILY).apply(); + } + + ArrayAdapter adapter = new ArrayAdapter<>(this, + android.R.layout.simple_list_item_1, intervalList); + adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + autoCheckInterval.setAdapter(adapter); autoCheckInterval.setSelection(Utils.getUpdateCheckSetting(this)); + 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/misc/Constants.java b/src/org/lineageos/updater/misc/Constants.java index 96c0b015..0aff4ce5 100644 --- a/src/org/lineageos/updater/misc/Constants.java +++ b/src/org/lineageos/updater/misc/Constants.java @@ -27,6 +27,9 @@ public final class Constants { public static final int AUTO_UPDATES_CHECK_INTERVAL_DAILY = 1; public static final int AUTO_UPDATES_CHECK_INTERVAL_WEEKLY = 2; public static final int AUTO_UPDATES_CHECK_INTERVAL_MONTHLY = 3; + public static final int AUTO_UPDATES_CHECK_INTERVAL_5_MINUTES = 4; + public static final int AUTO_UPDATES_CHECK_INTERVAL_10_MINUTES = 5; + public static final int AUTO_UPDATES_CHECK_INTERVAL_30_MINUTES = 6; public static final String PREF_LAST_UPDATE_CHECK = "last_update_check"; public static final String PREF_AUTO_UPDATES_CHECK_INTERVAL = "auto_updates_check_interval"; diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index c33bb081..ec40230f 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -39,6 +39,7 @@ import android.os.PersistableBundle; import android.os.SystemProperties; import android.os.SystemUpdateManager; import android.os.storage.StorageManager; +import android.provider.Settings; import android.util.Log; import android.widget.Toast; @@ -456,6 +457,12 @@ public class Utils { return isAB; } + public static boolean isDevModeOn(Context context) { + int devOptions = Settings.Secure.getInt(context.getContentResolver(), + Settings.Global.DEVELOPMENT_SETTINGS_ENABLED , 0); + return devOptions == 1; + } + public static boolean hasTouchscreen(Context context) { return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN); } @@ -486,6 +493,12 @@ public class Utils { public static long getUpdateCheckInterval(Context context) { switch (Utils.getUpdateCheckSetting(context)) { + case Constants.AUTO_UPDATES_CHECK_INTERVAL_5_MINUTES: + return AlarmManager.INTERVAL_FIFTEEN_MINUTES / 3; + case Constants.AUTO_UPDATES_CHECK_INTERVAL_10_MINUTES: + return AlarmManager.INTERVAL_HALF_HOUR / 3; + case Constants.AUTO_UPDATES_CHECK_INTERVAL_30_MINUTES: + return AlarmManager.INTERVAL_HALF_HOUR; case Constants.AUTO_UPDATES_CHECK_INTERVAL_DAILY: return AlarmManager.INTERVAL_DAY; case Constants.AUTO_UPDATES_CHECK_INTERVAL_WEEKLY: -- GitLab From 17c0a9c7b3e2a7c2b68b78b3e64c813708b15b2f Mon Sep 17 00:00:00 2001 From: Alexandre Roux Date: Fri, 18 Nov 2022 08:09:44 +0000 Subject: [PATCH 23/43] S was still crashing with maintenance number: fix --- .../updater/controller/UpdaterService.java | 2 +- src/org/lineageos/updater/misc/Utils.java | 29 +++++++++++-------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/org/lineageos/updater/controller/UpdaterService.java b/src/org/lineageos/updater/controller/UpdaterService.java index c0354f92..09f646e1 100644 --- a/src/org/lineageos/updater/controller/UpdaterService.java +++ b/src/org/lineageos/updater/controller/UpdaterService.java @@ -553,6 +553,6 @@ public class UpdaterService extends Service { } private void notifySystemUpdaterService(int status, UpdateInfo update) { - Utils.updateSystemUpdaterService(this, status, Float.parseFloat(update.getVersion())); + Utils.updateSystemUpdaterService(this, status, update.getVersion()); } } diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index ec40230f..0a614ac7 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -294,27 +294,32 @@ public class Utils { int[] deviceVersionParts = parseSemVer(SystemProperties.get(Constants.PROP_BUILD_VERSION)); int deviceMajorVersion = deviceVersionParts[0]; int deviceMinorVersion = deviceVersionParts[1]; - final float currentVersion = Float.parseFloat(deviceMajorVersion + "." + deviceMinorVersion); - float highestAvailableVersion = currentVersion; - boolean hasUpdate = false; + int deviceMaintenanceVersion = deviceVersionParts.length > 2 ? deviceVersionParts[2] : 0; + int highestMajorVersion = deviceMajorVersion; + int highestMinorVersion = deviceMinorVersion; + int highestMaintenanceVersion = deviceMaintenanceVersion; + boolean hasUpdate = false; for (UpdateInfo update : newList) { if (isCompatible(update)) { Log.d(TAG, "New compatible update available"); - int[] updateVersionParts = parseSemVer(update.getVersion()); - int updateMajorVersion = updateVersionParts[0]; - int updateMinorVersion = updateVersionParts[1]; + int[] updateVersionParts = parseSemVer(update.getVersion()); + int updateMajorVersion = updateVersionParts[0]; + int updateMinorVersion = updateVersionParts[1]; + int updateMaintenanceVersion = updateVersionParts.length > 2 ? updateVersionParts[2] : 0; float thisUpdate = Float.parseFloat(updateMajorVersion + "." + updateMinorVersion); - if (thisUpdate > highestAvailableVersion) { - highestAvailableVersion = thisUpdate; + if (updateMajorVersion*10000+updateMinorVersion*100+updateMaintenanceVersion >= highestMajorVersion*10000+highestMinorVersion*100+highestMaintenanceVersion) { + highestMajorVersion = updateMajorVersion; + highestMinorVersion = updateMinorVersion; + highestMaintenanceVersion = updateMaintenanceVersion; } hasUpdate = true; } } if (hasUpdate) { - updateSystemUpdaterService(context, STATUS_WAITING_DOWNLOAD, highestAvailableVersion); + updateSystemUpdaterService(context, STATUS_WAITING_DOWNLOAD, highestMajorVersion + "." + highestMinorVersion + (highestMaintenanceVersion > 0 ? "." + highestMaintenanceVersion : "")); return true; } else { - updateSystemUpdaterService(context, STATUS_IDLE, highestAvailableVersion); + updateSystemUpdaterService(context, STATUS_IDLE, highestMajorVersion+"."+highestMinorVersion+(highestMaintenanceVersion > 0 ? "." + highestMaintenanceVersion : "")); return false; } } @@ -513,7 +518,7 @@ public class Utils { return new File(Constants.UPDATE_RECOVERY_EXEC).exists(); } - public static void updateSystemUpdaterService(Context context, int status, float version) { + public static void updateSystemUpdaterService(Context context, int status, String version) { final SystemUpdateManager updateManager = context.getSystemService(SystemUpdateManager.class); final Bundle oldInfo = updateManager.retrieveSystemUpdateInfo(); @@ -522,7 +527,7 @@ public class Utils { if (status != oldStatus) { PersistableBundle infoBundle = new PersistableBundle(); infoBundle.putInt(KEY_STATUS, status); - infoBundle.putString(KEY_TITLE, String.valueOf(version)); + infoBundle.putString(KEY_TITLE, version); updateManager.updateSystemUpdateInfo(infoBundle); } } -- GitLab From e268ac0903e74dbef2a5f0605392fa165473cb43 Mon Sep 17 00:00:00 2001 From: althafvly Date: Mon, 7 Nov 2022 23:36:49 +0530 Subject: [PATCH 24/43] Updater: Add network ConnectionStateMonitor Change-Id: I54847a54e1cb0bff262deb3e57cae30fcd85b26f Updater: Move ConnectionStateMonitor to kotlin Change-Id: I7e0a1f68b71afe620706813daf76258b0c1682ae Updater: Improve ConnectionStateMonitor behaviour - Keep updater app alive till device back online for network callback. - Remove network callback once the internet is back. - Wait 10 seconds before doing anything when the device is online. Change-Id: I55e631cbf6cec9c19ec13e513a54ceaf10f8b2b9 --- Android.bp | 6 +- build.gradle | 5 +- .../updater/UpdatesCheckReceiver.java | 12 ++- .../updater/controller/UpdaterService.java | 4 +- .../updater/misc/ConnectionStateMonitor.kt | 92 +++++++++++++++++++ src/org/lineageos/updater/misc/Constants.java | 1 + 6 files changed, 115 insertions(+), 5 deletions(-) create mode 100644 src/org/lineageos/updater/misc/ConnectionStateMonitor.kt diff --git a/Android.bp b/Android.bp index baf92c34..ab6588cd 100644 --- a/Android.bp +++ b/Android.bp @@ -20,12 +20,16 @@ android_app { // Include SettingsLib and its dependencies defaults: ["SettingsLibDefaults"], - srcs: ["src/**/*.java"], + srcs: [ + "src/**/*.java", + "src/**/*.kt", + ], resource_dirs: ["res"], static_libs: [ "com.google.android.material_material", "androidx.core_core", + "androidx.core_core-ktx", "androidx.appcompat_appcompat", "androidx.cardview_cardview", "androidx.localbroadcastmanager_localbroadcastmanager", diff --git a/build.gradle b/build.gradle index 3a2eb827..7c5e5a03 100644 --- a/build.gradle +++ b/build.gradle @@ -11,6 +11,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:7.1.1' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10" } } @@ -19,6 +20,7 @@ def keystoreProperties = new Properties() keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) apply plugin: 'com.android.application' +apply plugin: 'org.jetbrains.kotlin.android' android { compileSdkVersion 31 @@ -58,9 +60,10 @@ android { dependencies { compileOnly fileTree(dir: 'system_libs/', include: ['*.jar']) - implementation 'com.google.android.material:material:1.4.0' implementation 'androidx.appcompat:appcompat:1.3.0' implementation 'androidx.cardview:cardview:1.0.0' + implementation 'androidx.core:core-ktx:1.9.0' implementation 'androidx.preference:preference:1.1.0' implementation 'androidx.recyclerview:recyclerview:1.2.1' + implementation 'com.google.android.material:material:1.4.0' } diff --git a/src/org/lineageos/updater/UpdatesCheckReceiver.java b/src/org/lineageos/updater/UpdatesCheckReceiver.java index 07beb1a7..87c6d341 100644 --- a/src/org/lineageos/updater/UpdatesCheckReceiver.java +++ b/src/org/lineageos/updater/UpdatesCheckReceiver.java @@ -31,6 +31,7 @@ import androidx.preference.PreferenceManager; import org.json.JSONException; import org.lineageos.updater.download.DownloadClient; +import org.lineageos.updater.misc.ConnectionStateMonitor; import org.lineageos.updater.misc.Constants; import org.lineageos.updater.misc.Utils; @@ -51,6 +52,9 @@ public class UpdatesCheckReceiver extends BroadcastReceiver { @Override public void onReceive(final Context context, Intent intent) { + final ConnectionStateMonitor cnState = + new ConnectionStateMonitor(context); + if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { Utils.cleanupDownloadsDir(context); } @@ -65,12 +69,16 @@ public class UpdatesCheckReceiver extends BroadcastReceiver { if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { // Set a repeating alarm on boot to check for new updates once per day scheduleRepeatingUpdatesCheck(context); + cnState.setNetworkCallbackActive(false); } if (!Utils.isNetworkAvailable(context)) { - Log.d(TAG, "Network not available, scheduling new check"); - scheduleUpdatesCheck(context); + if (!cnState.isNetworkCallbackActive()) { + cnState.setupNetworkCallback(true); + } return; + } else if (cnState.isNetworkCallbackActive()) { + cnState.setupNetworkCallback(false); } final File json = Utils.getCachedUpdateList(context); diff --git a/src/org/lineageos/updater/controller/UpdaterService.java b/src/org/lineageos/updater/controller/UpdaterService.java index 09f646e1..d13e1680 100644 --- a/src/org/lineageos/updater/controller/UpdaterService.java +++ b/src/org/lineageos/updater/controller/UpdaterService.java @@ -42,6 +42,7 @@ import org.lineageos.updater.R; import org.lineageos.updater.UpdaterReceiver; import org.lineageos.updater.UpdatesActivity; import org.lineageos.updater.misc.BuildInfoUtils; +import org.lineageos.updater.misc.ConnectionStateMonitor; import org.lineageos.updater.misc.Constants; import org.lineageos.updater.misc.StringGenerator; import org.lineageos.updater.misc.Utils; @@ -248,8 +249,9 @@ public class UpdaterService extends Service { } private void tryStopSelf() { + ConnectionStateMonitor cnState = new ConnectionStateMonitor(this); if (!mHasClients && !mUpdaterController.hasActiveDownloads() && - !mUpdaterController.isInstallingUpdate()) { + !mUpdaterController.isInstallingUpdate() && !cnState.isNetworkCallbackActive()) { Log.d(TAG, "Service no longer needed, stopping"); stopSelf(); } diff --git a/src/org/lineageos/updater/misc/ConnectionStateMonitor.kt b/src/org/lineageos/updater/misc/ConnectionStateMonitor.kt new file mode 100644 index 00000000..c8246b1c --- /dev/null +++ b/src/org/lineageos/updater/misc/ConnectionStateMonitor.kt @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2022 MURENA SAS + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.lineageos.updater.misc + +import android.content.Context +import android.content.Intent +import android.content.SharedPreferences +import android.net.ConnectivityManager +import android.net.Network +import android.net.NetworkCapabilities +import android.net.NetworkRequest +import android.os.Handler +import android.os.Looper +import android.util.Log +import androidx.preference.PreferenceManager + +import org.lineageos.updater.UpdatesCheckReceiver + +class ConnectionStateMonitor(private val mContext: Context) : ConnectivityManager.NetworkCallback() { + private val networkRequest: NetworkRequest = NetworkRequest.Builder() + .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR) + .addTransportType(NetworkCapabilities.TRANSPORT_ETHERNET) + .addTransportType(NetworkCapabilities.TRANSPORT_WIFI) + .build() + private val pref: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext) + + fun isNetworkCallbackActive(): Boolean { + return pref.getBoolean(Constants.PREF_NETWORK_CALLBACK_ACTIVE, false) + } + + fun setNetworkCallbackActive(shouldEnable: Boolean) { + pref.edit().putBoolean(Constants.PREF_NETWORK_CALLBACK_ACTIVE, shouldEnable).apply() + } + + fun setupNetworkCallback(shouldEnable: Boolean) { + val connectivityManager: ConnectivityManager = + mContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager + + if (shouldEnable) { + connectivityManager.registerNetworkCallback(networkRequest, this) + } else { + try { + connectivityManager.unregisterNetworkCallback(this) + } catch (e: IllegalArgumentException) { + Log.e(tag, "Network callback was not registered") + } + } + + setNetworkCallbackActive(shouldEnable) + Log.d(tag, "Network callback enabled: $shouldEnable") + } + + private fun startUpdatesCheckReceiver(): Runnable = Runnable { + val broadcastIntent = Intent() + broadcastIntent.setClassName(mContext, UpdatesCheckReceiver::class.java.name) + mContext.sendBroadcast(broadcastIntent) + } + + private fun checkForUpdates() { + // Delay because some phones takes time go online + Handler(Looper.getMainLooper()).postDelayed( + startUpdatesCheckReceiver(), delayExecute) + } + + override fun onAvailable(network: Network) { + Log.d(tag, "Network available") + checkForUpdates() + } + + override fun onLost(network: Network) { + Log.d(tag, "Network not available") + checkForUpdates() + } + + companion object { + private const val tag = "ConnectionStateMonitor" + private const val delayExecute = 10000L // 10 seconds + } +} diff --git a/src/org/lineageos/updater/misc/Constants.java b/src/org/lineageos/updater/misc/Constants.java index 0aff4ce5..6a0f02c3 100644 --- a/src/org/lineageos/updater/misc/Constants.java +++ b/src/org/lineageos/updater/misc/Constants.java @@ -37,6 +37,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_NETWORK_CALLBACK_ACTIVE = "pref_network_callback_active"; public static final String UNCRYPT_FILE_EXT = ".uncrypt"; -- GitLab From 30aa47d2e680d7c16dd8b5398365db3bff380ead Mon Sep 17 00:00:00 2001 From: althafvly Date: Wed, 9 Nov 2022 13:49:47 +0530 Subject: [PATCH 25/43] Updater: Change one-shot check to 15 minutes - It was two hours previously Change-Id: I4fb4ae38805cedecbbd3bc86c930dfb4c3c11cc6 --- src/org/lineageos/updater/UpdatesCheckReceiver.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/lineageos/updater/UpdatesCheckReceiver.java b/src/org/lineageos/updater/UpdatesCheckReceiver.java index 87c6d341..b87366e8 100644 --- a/src/org/lineageos/updater/UpdatesCheckReceiver.java +++ b/src/org/lineageos/updater/UpdatesCheckReceiver.java @@ -189,7 +189,7 @@ public class UpdatesCheckReceiver extends BroadcastReceiver { } public static void scheduleUpdatesCheck(Context context) { - long millisToNextCheck = AlarmManager.INTERVAL_HOUR * 2; + long millisToNextCheck = AlarmManager.INTERVAL_FIFTEEN_MINUTES; PendingIntent updateCheckIntent = getUpdatesCheckIntent(context); AlarmManager alarmMgr = context.getSystemService(AlarmManager.class); alarmMgr.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME, -- GitLab From 3d32ee188bd09d7cbac0779bb11ba1c9a4b8d252 Mon Sep 17 00:00:00 2001 From: althafvly Date: Mon, 7 Nov 2022 13:47:39 +0530 Subject: [PATCH 26/43] Updater: UpdatesCheckReceiver: Make exact alarm work every time Change-Id: Id950e6c4f44a445f78be60416e159045d120152e --- .../updater/UpdatesCheckReceiver.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/org/lineageos/updater/UpdatesCheckReceiver.java b/src/org/lineageos/updater/UpdatesCheckReceiver.java index b87366e8..c7064f00 100644 --- a/src/org/lineageos/updater/UpdatesCheckReceiver.java +++ b/src/org/lineageos/updater/UpdatesCheckReceiver.java @@ -57,6 +57,7 @@ public class UpdatesCheckReceiver extends BroadcastReceiver { if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { Utils.cleanupDownloadsDir(context); + cnState.setNetworkCallbackActive(false); } final SharedPreferences preferences = @@ -66,11 +67,9 @@ public class UpdatesCheckReceiver extends BroadcastReceiver { return; } - if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { - // Set a repeating alarm on boot to check for new updates once per day - scheduleRepeatingUpdatesCheck(context); - cnState.setNetworkCallbackActive(false); - } + // Exact alarms does not support repeating, so update to make it + // work like repeating alarms. To check for update at the exact time. + updateRepeatingUpdatesCheck(context); if (!Utils.isNetworkAvailable(context)) { if (!cnState.isNetworkCallbackActive()) { @@ -168,12 +167,10 @@ public class UpdatesCheckReceiver extends BroadcastReceiver { PendingIntent updateCheckIntent = getRepeatingUpdatesCheckIntent(context); AlarmManager alarmMgr = context.getSystemService(AlarmManager.class); - alarmMgr.setExactAndAllowWhileIdle(AlarmManager.RTC, - System.currentTimeMillis() + Utils.getUpdateCheckInterval(context), - updateCheckIntent); + long nextCheck = System.currentTimeMillis() + Utils.getUpdateCheckInterval(context); + alarmMgr.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, nextCheck, updateCheckIntent); - Date nextCheckDate = new Date(System.currentTimeMillis() + - Utils.getUpdateCheckInterval(context)); + Date nextCheckDate = new Date(nextCheck); Log.d(TAG, "Setting automatic updates check: " + nextCheckDate); } @@ -192,11 +189,11 @@ public class UpdatesCheckReceiver extends BroadcastReceiver { long millisToNextCheck = AlarmManager.INTERVAL_FIFTEEN_MINUTES; PendingIntent updateCheckIntent = getUpdatesCheckIntent(context); AlarmManager alarmMgr = context.getSystemService(AlarmManager.class); + long nextCheck = SystemClock.elapsedRealtime() + millisToNextCheck; alarmMgr.setExactAndAllowWhileIdle(AlarmManager.ELAPSED_REALTIME, - SystemClock.elapsedRealtime() + millisToNextCheck, - updateCheckIntent); + nextCheck, updateCheckIntent); - Date nextCheckDate = new Date(System.currentTimeMillis() + millisToNextCheck); + Date nextCheckDate = new Date(nextCheck); Log.d(TAG, "Setting one-shot updates check: " + nextCheckDate); } -- GitLab From f5caeb9fa3c42b88c6b2bcfa412698f57382fc71 Mon Sep 17 00:00:00 2001 From: althafvly Date: Tue, 22 Nov 2022 16:29:08 +0530 Subject: [PATCH 27/43] Updater: Simplify activity status for cnstate monitor Change-Id: I1a46444c35ce40c967a16cc8a5ae2d099e14d62e --- .../updater/UpdatesCheckReceiver.java | 44 +++++++-- .../updater/controller/UpdaterService.java | 11 ++- .../updater/misc/ConnectionStateMonitor.kt | 89 ++++++++----------- 3 files changed, 79 insertions(+), 65 deletions(-) diff --git a/src/org/lineageos/updater/UpdatesCheckReceiver.java b/src/org/lineageos/updater/UpdatesCheckReceiver.java index c7064f00..d16e9c5b 100644 --- a/src/org/lineageos/updater/UpdatesCheckReceiver.java +++ b/src/org/lineageos/updater/UpdatesCheckReceiver.java @@ -23,6 +23,9 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.net.ConnectivityManager; +import android.net.NetworkCapabilities; +import android.net.NetworkRequest; import android.os.SystemClock; import android.util.Log; @@ -30,6 +33,7 @@ import androidx.core.app.NotificationCompat; import androidx.preference.PreferenceManager; import org.json.JSONException; +import org.lineageos.updater.controller.UpdaterService; import org.lineageos.updater.download.DownloadClient; import org.lineageos.updater.misc.ConnectionStateMonitor; import org.lineageos.updater.misc.Constants; @@ -50,14 +54,19 @@ public class UpdatesCheckReceiver extends BroadcastReceiver { private static final String NEW_UPDATES_NOTIFICATION_CHANNEL = "new_updates_notification_channel"; + private final NetworkRequest networkRequest = new NetworkRequest.Builder() + .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR) + .addTransportType(NetworkCapabilities.TRANSPORT_ETHERNET) + .addTransportType(NetworkCapabilities.TRANSPORT_WIFI) + .build(); + + private ConnectivityManager.NetworkCallback cnState; + private ConnectivityManager connectivityManager; + @Override public void onReceive(final Context context, Intent intent) { - final ConnectionStateMonitor cnState = - new ConnectionStateMonitor(context); - if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { Utils.cleanupDownloadsDir(context); - cnState.setNetworkCallbackActive(false); } final SharedPreferences preferences = @@ -71,13 +80,17 @@ public class UpdatesCheckReceiver extends BroadcastReceiver { // work like repeating alarms. To check for update at the exact time. updateRepeatingUpdatesCheck(context); + cnState = new ConnectionStateMonitor().getInstance(context); + connectivityManager = (ConnectivityManager) + context.getSystemService(Context.CONNECTIVITY_SERVICE); + if (!Utils.isNetworkAvailable(context)) { - if (!cnState.isNetworkCallbackActive()) { - cnState.setupNetworkCallback(true); + if (!UpdaterService.isNetworkCallBackActive()) { + setupNetworkCallback(true); } return; - } else if (cnState.isNetworkCallbackActive()) { - cnState.setupNetworkCallback(false); + } else if (UpdaterService.isNetworkCallBackActive()) { + setupNetworkCallback(false); } final File json = Utils.getCachedUpdateList(context); @@ -129,6 +142,21 @@ public class UpdatesCheckReceiver extends BroadcastReceiver { } } + public void setupNetworkCallback(boolean shouldEnable) { + if (shouldEnable) { + connectivityManager.registerNetworkCallback(networkRequest, cnState); + } else { + try { + connectivityManager.unregisterNetworkCallback(cnState); + } catch (IllegalArgumentException e) { + Log.e(TAG, "Network callback was not registered"); + } + } + + UpdaterService.setNetworkCallBackActive(shouldEnable); + Log.d(TAG, "Network callback enabled: " + shouldEnable); + } + private static void showNotification(Context context) { NotificationManager notificationManager = context.getSystemService( NotificationManager.class); diff --git a/src/org/lineageos/updater/controller/UpdaterService.java b/src/org/lineageos/updater/controller/UpdaterService.java index d13e1680..b71a4f68 100644 --- a/src/org/lineageos/updater/controller/UpdaterService.java +++ b/src/org/lineageos/updater/controller/UpdaterService.java @@ -42,7 +42,6 @@ import org.lineageos.updater.R; import org.lineageos.updater.UpdaterReceiver; import org.lineageos.updater.UpdatesActivity; import org.lineageos.updater.misc.BuildInfoUtils; -import org.lineageos.updater.misc.ConnectionStateMonitor; import org.lineageos.updater.misc.Constants; import org.lineageos.updater.misc.StringGenerator; import org.lineageos.updater.misc.Utils; @@ -75,6 +74,7 @@ public class UpdaterService extends Service { private static final int NOTIFICATION_ID = 10; private final IBinder mBinder = new LocalBinder(); + private static boolean isNetworkCallBackActive = false; private boolean mHasClients; private BroadcastReceiver mBroadcastReceiver; @@ -249,9 +249,8 @@ public class UpdaterService extends Service { } private void tryStopSelf() { - ConnectionStateMonitor cnState = new ConnectionStateMonitor(this); if (!mHasClients && !mUpdaterController.hasActiveDownloads() && - !mUpdaterController.isInstallingUpdate() && !cnState.isNetworkCallbackActive()) { + !mUpdaterController.isInstallingUpdate() && !isNetworkCallBackActive()) { Log.d(TAG, "Service no longer needed, stopping"); stopSelf(); } @@ -475,6 +474,12 @@ public class UpdaterService extends Service { } } + public static void setNetworkCallBackActive(boolean isActive) { + isNetworkCallBackActive = isActive; + } + + public static boolean isNetworkCallBackActive() { return isNetworkCallBackActive; } + private void handleDownloadProgressChange(UpdateInfo update) { int progress = update.getProgress(); mNotificationBuilder.setProgress(100, progress, false); diff --git a/src/org/lineageos/updater/misc/ConnectionStateMonitor.kt b/src/org/lineageos/updater/misc/ConnectionStateMonitor.kt index c8246b1c..583d770c 100644 --- a/src/org/lineageos/updater/misc/ConnectionStateMonitor.kt +++ b/src/org/lineageos/updater/misc/ConnectionStateMonitor.kt @@ -17,76 +17,57 @@ package org.lineageos.updater.misc import android.content.Context import android.content.Intent -import android.content.SharedPreferences import android.net.ConnectivityManager import android.net.Network -import android.net.NetworkCapabilities -import android.net.NetworkRequest import android.os.Handler import android.os.Looper import android.util.Log -import androidx.preference.PreferenceManager - import org.lineageos.updater.UpdatesCheckReceiver -class ConnectionStateMonitor(private val mContext: Context) : ConnectivityManager.NetworkCallback() { - private val networkRequest: NetworkRequest = NetworkRequest.Builder() - .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR) - .addTransportType(NetworkCapabilities.TRANSPORT_ETHERNET) - .addTransportType(NetworkCapabilities.TRANSPORT_WIFI) - .build() - private val pref: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(mContext) - - fun isNetworkCallbackActive(): Boolean { - return pref.getBoolean(Constants.PREF_NETWORK_CALLBACK_ACTIVE, false) - } - - fun setNetworkCallbackActive(shouldEnable: Boolean) { - pref.edit().putBoolean(Constants.PREF_NETWORK_CALLBACK_ACTIVE, shouldEnable).apply() +class ConnectionStateMonitor { + companion object { + private var instance: ConnectivityManager.NetworkCallback? = null } - fun setupNetworkCallback(shouldEnable: Boolean) { - val connectivityManager: ConnectivityManager = - mContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager - - if (shouldEnable) { - connectivityManager.registerNetworkCallback(networkRequest, this) - } else { - try { - connectivityManager.unregisterNetworkCallback(this) - } catch (e: IllegalArgumentException) { - Log.e(tag, "Network callback was not registered") - } + fun getInstance(context: Context): ConnectivityManager.NetworkCallback { + if (instance == null) { + instance = networkCallback(context) } - setNetworkCallbackActive(shouldEnable) - Log.d(tag, "Network callback enabled: $shouldEnable") + return instance!! } - private fun startUpdatesCheckReceiver(): Runnable = Runnable { - val broadcastIntent = Intent() - broadcastIntent.setClassName(mContext, UpdatesCheckReceiver::class.java.name) - mContext.sendBroadcast(broadcastIntent) - } + /** + * API callbacks to determine which status we currently in + * we need the below callbacks: + * - onAvailable: device connected to a network of course + * - onLost: when the connection completely lost + */ + fun networkCallback(context: Context) = object: ConnectivityManager.NetworkCallback() { + private val tag = "ConnectionStateMonitor" + private val delayExecute = 10000L // 10 seconds - private fun checkForUpdates() { - // Delay because some phones takes time go online - Handler(Looper.getMainLooper()).postDelayed( - startUpdatesCheckReceiver(), delayExecute) - } + private fun startUpdatesCheckReceiver(): Runnable = Runnable { + val broadcastIntent = Intent() + broadcastIntent.setClassName(context, UpdatesCheckReceiver::class.java.name) + context.sendBroadcast(broadcastIntent) + } - override fun onAvailable(network: Network) { - Log.d(tag, "Network available") - checkForUpdates() - } + private fun checkForUpdates() { + // Delay because some phones takes time go online + Handler(Looper.getMainLooper()).postDelayed( + startUpdatesCheckReceiver(), delayExecute + ) + } - override fun onLost(network: Network) { - Log.d(tag, "Network not available") - checkForUpdates() - } + override fun onAvailable(network: Network) { + Log.d(tag, "Network available") + checkForUpdates() + } - companion object { - private const val tag = "ConnectionStateMonitor" - private const val delayExecute = 10000L // 10 seconds + override fun onLost(network: Network) { + Log.d(tag, "Network not available") + checkForUpdates() + } } } -- GitLab From 6269d1032767b479a9c70597f466a1d0f2ce43cd Mon Sep 17 00:00:00 2001 From: Nishith Khanna Date: Thu, 24 Nov 2022 13:49:44 +0530 Subject: [PATCH 28/43] Hide the recycler view and available text header by default --- res/layout/activity_updates.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/res/layout/activity_updates.xml b/res/layout/activity_updates.xml index 3b956f56..58408700 100644 --- a/res/layout/activity_updates.xml +++ b/res/layout/activity_updates.xml @@ -119,7 +119,8 @@ android:id="@+id/content" android:layout_width="match_parent" android:layout_height="match_parent" - android:orientation="vertical" + android:orientation="vertical" + android:visibility="gone" app:layout_behavior="@string/appbar_scrolling_view_behavior"> Date: Thu, 24 Nov 2022 16:52:12 +0530 Subject: [PATCH 29/43] Move current version string from layout so that it can be translated --- res/layout/activity_updates.xml | 2 +- res/values/strings.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/res/layout/activity_updates.xml b/res/layout/activity_updates.xml index 58408700..4682c23d 100644 --- a/res/layout/activity_updates.xml +++ b/res/layout/activity_updates.xml @@ -51,7 +51,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingBottom="24dp" - android:text="Current version:" + android:text="@string/current_version" android:textColor="?android:attr/textColorPrimary" android:textSize="16sp" /> diff --git a/res/values/strings.xml b/res/values/strings.xml index a11e7439..091debb9 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -178,4 +178,5 @@ /e/OS\n%1$s Available updates: + Current version: -- GitLab From 6fd7b6c9e832813e4cf91d166ea5afbb893d4488 Mon Sep 17 00:00:00 2001 From: althafvly Date: Tue, 11 Oct 2022 12:33:10 +0530 Subject: [PATCH 30/43] Updater: Allow A/B devices to override update priority - Changing in mid-shipping will/should not change current value. --- res/values/config.xml | 1 + res/values/symbols.xml | 1 + src/org/lineageos/updater/UpdatesActivity.java | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/res/values/config.xml b/res/values/config.xml index 76ab6862..16ab670f 100644 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -16,4 +16,5 @@ --> false + false diff --git a/res/values/symbols.xml b/res/values/symbols.xml index f3dc0ba3..992614c0 100644 --- a/res/values/symbols.xml +++ b/res/values/symbols.xml @@ -16,4 +16,5 @@ --> + diff --git a/src/org/lineageos/updater/UpdatesActivity.java b/src/org/lineageos/updater/UpdatesActivity.java index 408aff15..173452f0 100644 --- a/src/org/lineageos/updater/UpdatesActivity.java +++ b/src/org/lineageos/updater/UpdatesActivity.java @@ -514,7 +514,8 @@ public class UpdatesActivity extends UpdatesListActivity { 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)); + abPerfMode.setChecked(prefs.getBoolean(Constants.PREF_AB_PERF_MODE, + getResources().getBoolean(R.bool.config_prioritizeUpdateProcess))); if (getResources().getBoolean(R.bool.config_hideRecoveryUpdate)) { // Hide the update feature if explicitly requested. -- GitLab From 40c4bc71861a9f4fb6fd93db1b8230781098204d Mon Sep 17 00:00:00 2001 From: merothh Date: Thu, 5 May 2022 09:52:26 +0530 Subject: [PATCH 31/43] Updater: Adapt displayVersion to show proper versioning --- src/org/lineageos/updater/UpdatesListAdapter.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/lineageos/updater/UpdatesListAdapter.java b/src/org/lineageos/updater/UpdatesListAdapter.java index 4ecf54f3..4566b88a 100644 --- a/src/org/lineageos/updater/UpdatesListAdapter.java +++ b/src/org/lineageos/updater/UpdatesListAdapter.java @@ -273,7 +273,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter Date: Thu, 22 Dec 2022 13:35:02 +0530 Subject: [PATCH 32/43] Updater: Check for free space on install Change-Id: Ifb3385c879755dff6686f3f422fa95f80cfc1e99 --- res/values/strings.xml | 2 ++ .../lineageos/updater/UpdatesListAdapter.java | 13 ++++++++++++- src/org/lineageos/updater/misc/Utils.java | 17 +++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 091debb9..00b71278 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -61,6 +61,8 @@ Preliminary update preparation Low battery The battery level is too low, you need at least %1$d%% of the battery to continue, %2$d%% if charging. + Free up space + The update cannot be completed because there is insufficient free space; at least %1$s of free space is required. Please clear your internal storage before proceeding. Reboot diff --git a/src/org/lineageos/updater/UpdatesListAdapter.java b/src/org/lineageos/updater/UpdatesListAdapter.java index 4566b88a..f2f296dc 100644 --- a/src/org/lineageos/updater/UpdatesListAdapter.java +++ b/src/org/lineageos/updater/UpdatesListAdapter.java @@ -454,8 +454,8 @@ public class UpdatesListAdapter extends RecyclerView.Adapter= neededSpace; + if (!hasFreeSpace) { + String message = resources.getString(R.string.dialog_free_space_low_message_pct, + Utils.getFileSize(neededSpace)); + return new AlertDialog.Builder(mActivity) + .setTitle(R.string.dialog_free_space_low_title) + .setMessage(message) + .setPositiveButton(android.R.string.ok, null); + } + String buildDate = StringGenerator.getDateLocalizedUTC(mActivity, DateFormat.MEDIUM, update.getTimestamp()); String buildInfoText = mActivity.getString(R.string.list_build_version_date_e, diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index 0a614ac7..4ea73c14 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -35,7 +35,9 @@ import android.net.Network; import android.net.NetworkCapabilities; import android.net.Uri; import android.os.Bundle; +import android.os.Environment; import android.os.PersistableBundle; +import android.os.StatFs; import android.os.SystemProperties; import android.os.SystemUpdateManager; import android.os.storage.StorageManager; @@ -59,6 +61,7 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; +import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Enumeration; import java.util.HashSet; @@ -159,6 +162,20 @@ public class Utils { return new int[]{ major, minor }; } + public static long availableFreeSpace() { + StatFs stats = new StatFs(Environment.getDataDirectory().getAbsolutePath()); + return stats.getAvailableBlocksLong() * stats.getBlockSizeLong(); + } + + // https://stackoverflow.com/a/28527441 + public static String getFileSize(long size) { + if (size <= 0) + return "0"; + final String[] units = new String[] { "B", "KB", "MB", "GB", "TB" }; + int digitGroups = (int) (Math.log10(size) / Math.log10(1024)); + return new DecimalFormat("#,##0.#").format(size / Math.pow(1024, digitGroups)) + " " + units[digitGroups]; + } + 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 9f376e76a17c0e063aa0eeabacb6a5d1d568cfb7 Mon Sep 17 00:00:00 2001 From: althafvly Date: Wed, 28 Dec 2022 10:22:59 +0530 Subject: [PATCH 33/43] Updater: Cleanup imports Change-Id: If4949ccf2efb19922c160d82f17a5a63a3b5ed75 --- src/org/lineageos/updater/UpdatesActivity.java | 2 +- src/org/lineageos/updater/UpdatesListAdapter.java | 5 ----- src/org/lineageos/updater/controller/UpdateInstaller.java | 2 +- src/org/lineageos/updater/controller/UpdaterService.java | 1 - .../lineageos/updater/download/HttpURLConnectionClient.java | 5 ++--- src/org/lineageos/updater/misc/Utils.java | 5 +---- 6 files changed, 5 insertions(+), 15 deletions(-) diff --git a/src/org/lineageos/updater/UpdatesActivity.java b/src/org/lineageos/updater/UpdatesActivity.java index 173452f0..9f6a4e55 100644 --- a/src/org/lineageos/updater/UpdatesActivity.java +++ b/src/org/lineageos/updater/UpdatesActivity.java @@ -23,9 +23,9 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; -import android.content.res.Configuration; import android.content.ServiceConnection; import android.content.SharedPreferences; +import android.content.res.Configuration; import android.icu.text.DateFormat; import android.net.Uri; import android.os.Build; diff --git a/src/org/lineageos/updater/UpdatesListAdapter.java b/src/org/lineageos/updater/UpdatesListAdapter.java index f2f296dc..04ad0028 100644 --- a/src/org/lineageos/updater/UpdatesListAdapter.java +++ b/src/org/lineageos/updater/UpdatesListAdapter.java @@ -15,12 +15,10 @@ */ package org.lineageos.updater; -import android.app.Activity; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.res.Resources; -import android.net.Uri; import android.os.BatteryManager; import android.os.PowerManager; import android.text.SpannableString; @@ -40,8 +38,6 @@ import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.TextView; -import androidx.activity.result.ActivityResultLauncher; -import androidx.activity.result.contract.ActivityResultContracts; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; import androidx.appcompat.view.ContextThemeWrapper; @@ -55,7 +51,6 @@ import com.google.android.material.snackbar.Snackbar; import org.lineageos.updater.controller.UpdaterController; import org.lineageos.updater.controller.UpdaterService; -import org.lineageos.updater.misc.BuildInfoUtils; import org.lineageos.updater.misc.Constants; import org.lineageos.updater.misc.StringGenerator; import org.lineageos.updater.misc.Utils; diff --git a/src/org/lineageos/updater/controller/UpdateInstaller.java b/src/org/lineageos/updater/controller/UpdateInstaller.java index b111f9f3..720d13ec 100644 --- a/src/org/lineageos/updater/controller/UpdateInstaller.java +++ b/src/org/lineageos/updater/controller/UpdateInstaller.java @@ -31,8 +31,8 @@ import org.lineageos.updater.model.UpdateStatus; import java.io.File; import java.io.IOException; -import java.nio.file.attribute.PosixFilePermission; import java.nio.file.Files; +import java.nio.file.attribute.PosixFilePermission; import java.util.HashSet; import java.util.Set; diff --git a/src/org/lineageos/updater/controller/UpdaterService.java b/src/org/lineageos/updater/controller/UpdaterService.java index b71a4f68..bf013900 100644 --- a/src/org/lineageos/updater/controller/UpdaterService.java +++ b/src/org/lineageos/updater/controller/UpdaterService.java @@ -41,7 +41,6 @@ import androidx.preference.PreferenceManager; import org.lineageos.updater.R; import org.lineageos.updater.UpdaterReceiver; import org.lineageos.updater.UpdatesActivity; -import org.lineageos.updater.misc.BuildInfoUtils; import org.lineageos.updater.misc.Constants; import org.lineageos.updater.misc.StringGenerator; import org.lineageos.updater.misc.Utils; diff --git a/src/org/lineageos/updater/download/HttpURLConnectionClient.java b/src/org/lineageos/updater/download/HttpURLConnectionClient.java index df6283b5..606bef16 100644 --- a/src/org/lineageos/updater/download/HttpURLConnectionClient.java +++ b/src/org/lineageos/updater/download/HttpURLConnectionClient.java @@ -17,9 +17,10 @@ package org.lineageos.updater.download; import android.os.SystemClock; import android.os.SystemProperties; - import android.util.Log; +import org.lineageos.updater.misc.Constants; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -34,8 +35,6 @@ import java.util.PriorityQueue; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.lineageos.updater.misc.Constants; - public class HttpURLConnectionClient implements DownloadClient { private final static String TAG = "HttpURLConnectionClient"; diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index 4ea73c14..7758b8ab 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -20,7 +20,6 @@ import static android.os.SystemUpdateManager.KEY_STATUS; import static android.os.SystemUpdateManager.KEY_TITLE; import static android.os.SystemUpdateManager.STATUS_IDLE; import static android.os.SystemUpdateManager.STATUS_WAITING_DOWNLOAD; -import static android.os.SystemUpdateManager.STATUS_UNKNOWN; import android.app.AlarmManager; import android.content.ClipData; @@ -64,13 +63,11 @@ import java.io.IOException; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Enumeration; -import java.util.HashSet; import java.util.List; import java.util.Locale; -import java.util.Set; +import java.util.regex.Pattern; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; -import java.util.regex.Pattern; public class Utils { -- GitLab From 229d16e7aa3f6404a1494ad210d7aee044057966 Mon Sep 17 00:00:00 2001 From: althafvly Date: Tue, 10 Jan 2023 12:53:07 +0530 Subject: [PATCH 34/43] Updater: Check dev options toggle for test channel Change-Id: Ifecac146e3f637fa589241e513a269f3306764ed --- src/org/lineageos/updater/misc/Utils.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index 7758b8ab..903714a4 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -218,7 +218,7 @@ public class Utils { String serverUrl = ""; if (retrieveStatus(context) != null) { - if (retrieveStatus(context).equals("true")) { + if (retrieveStatus(context).equals("true") && isDevModeOn(context)) { serverUrl = context.getString(R.string.ota_staging_server_url); return serverUrl.replace("{device}", device) .replace("{type}", type) @@ -477,9 +477,8 @@ public class Utils { } public static boolean isDevModeOn(Context context) { - int devOptions = Settings.Secure.getInt(context.getContentResolver(), - Settings.Global.DEVELOPMENT_SETTINGS_ENABLED , 0); - return devOptions == 1; + return Settings.Secure.getInt(context.getContentResolver(), + Settings.Global.DEVELOPMENT_SETTINGS_ENABLED , 0) == 1; } public static boolean hasTouchscreen(Context context) { -- GitLab From 2d944c31de78d7f38aee4f83dd8d33d27f92e7df Mon Sep 17 00:00:00 2001 From: Alexandre Roux Date: Thu, 6 Oct 2022 14:26:28 +0000 Subject: [PATCH 35/43] Updater: hide lower android versions Change-Id: Ic2746aa8507ba770c52c3cdc666b0f03ad533842 Signed-off-by: althafvly --- src/org/lineageos/updater/UpdatesDbHelper.java | 10 ++++++++-- src/org/lineageos/updater/misc/Utils.java | 14 +++++++++++++- src/org/lineageos/updater/model/UpdateBase.java | 10 ++++++++++ .../lineageos/updater/model/UpdateBaseInfo.java | 2 ++ 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/org/lineageos/updater/UpdatesDbHelper.java b/src/org/lineageos/updater/UpdatesDbHelper.java index 9dadd4b6..bf78b829 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 { @@ -43,6 +43,7 @@ public class UpdatesDbHelper extends SQLiteOpenHelper { 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"; + public static final String COLUMN_NAME_ANDROID_VERSION = "android_version"; } private static final String SQL_CREATE_ENTRIES = @@ -55,7 +56,8 @@ public class UpdatesDbHelper extends SQLiteOpenHelper { UpdateEntry.COLUMN_NAME_TYPE + " TEXT," + UpdateEntry.COLUMN_NAME_VERSION + " TEXT," + UpdateEntry.COLUMN_NAME_DISPLAY_VERSION + " TEXT," + - UpdateEntry.COLUMN_NAME_SIZE + " INTEGER)"; + UpdateEntry.COLUMN_NAME_SIZE + " INTEGER," + + UpdateEntry.COLUMN_NAME_ANDROID_VERSION + " TEXT)"; private static final String SQL_DELETE_ENTRIES = "DROP TABLE IF EXISTS " + UpdateEntry.TABLE_NAME; @@ -93,6 +95,7 @@ public class UpdatesDbHelper extends SQLiteOpenHelper { 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()); + values.put(UpdateEntry.COLUMN_NAME_ANDROID_VERSION, update.getAndroidVersion()); } public void removeUpdate(String downloadId) { @@ -131,6 +134,7 @@ public class UpdatesDbHelper extends SQLiteOpenHelper { UpdateEntry.COLUMN_NAME_DISPLAY_VERSION, UpdateEntry.COLUMN_NAME_STATUS, UpdateEntry.COLUMN_NAME_SIZE, + UpdateEntry.COLUMN_NAME_ANDROID_VERSION, }; String sort = UpdateEntry.COLUMN_NAME_TIMESTAMP + " DESC"; Cursor cursor = db.query(UpdateEntry.TABLE_NAME, projection, selection, selectionArgs, @@ -156,6 +160,8 @@ public class UpdatesDbHelper extends SQLiteOpenHelper { update.setPersistentStatus(cursor.getInt(index)); index = cursor.getColumnIndex(UpdateEntry.COLUMN_NAME_SIZE); update.setFileSize(cursor.getLong(index)); + index = cursor.getColumnIndex(UpdateEntry.COLUMN_NAME_ANDROID_VERSION); + update.setAndroidVersion(cursor.getString(index)); updates.add(update); } cursor.close(); diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index 903714a4..f21df4b6 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -22,6 +22,7 @@ import static android.os.SystemUpdateManager.STATUS_IDLE; import static android.os.SystemUpdateManager.STATUS_WAITING_DOWNLOAD; import android.app.AlarmManager; +import android.os.Build; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; @@ -107,6 +108,7 @@ public class Utils { update.setFileSize(object.getLong("size")); update.setDownloadUrl(object.getString("url")); update.setVersion(object.getString("version")); + update.setAndroidVersion(object.getString("android_version")); if (object.has("pre_version") && !object.getString("pre_version").isEmpty()) { update.setDisplayVersion(object.getString("version") + "-" + object.getString("pre_version")); } else { @@ -116,6 +118,17 @@ public class Utils { } public static boolean isCompatible(UpdateBaseInfo update) { + String updateAndroidVersion = update.getAndroidVersion(); + if (!updateAndroidVersion.isEmpty()) { + final int updateOSVersion = Float.valueOf(updateAndroidVersion).intValue(); + final int deviceOSVersion = Float.valueOf(Build.VERSION.RELEASE).intValue(); + if (deviceOSVersion > updateOSVersion) { + Log.d(TAG, "Update : Skipping " + update.getName() + " since the installed version " + + deviceOSVersion + " is newer than update " + updateOSVersion); + return false; + } + } + int[] updateVersionParts = parseSemVer(update.getVersion()); int updateMajorVersion = updateVersionParts[0]; int updateMinorVersion = updateVersionParts[1]; @@ -126,7 +139,6 @@ public class Utils { 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)) { Log.d(TAG, update.getName() + " is older than/equal to the current build"); diff --git a/src/org/lineageos/updater/model/UpdateBase.java b/src/org/lineageos/updater/model/UpdateBase.java index cfa2027e..f1689bce 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() { @@ -111,4 +112,13 @@ public class UpdateBase implements UpdateBaseInfo { public void setFileSize(long fileSize) { mFileSize = fileSize; } + + @Override + public String getAndroidVersion() { + return mAndroidVersion; + } + + public void setAndroidVersion(String androidVersion) { + mAndroidVersion = androidVersion; + } } diff --git a/src/org/lineageos/updater/model/UpdateBaseInfo.java b/src/org/lineageos/updater/model/UpdateBaseInfo.java index 2921e96f..aea17bd8 100644 --- a/src/org/lineageos/updater/model/UpdateBaseInfo.java +++ b/src/org/lineageos/updater/model/UpdateBaseInfo.java @@ -31,4 +31,6 @@ public interface UpdateBaseInfo { String getDownloadUrl(); long getFileSize(); + + String getAndroidVersion(); } -- GitLab From bdbc6387fb4670c1ffcdf3c9baaed0af6f167dbf Mon Sep 17 00:00:00 2001 From: althafvly Date: Thu, 26 Jan 2023 19:24:30 +0530 Subject: [PATCH 36/43] Updater: Check for available space on install/update/resume - Display required space in MB. GB is confusing because its a rounded figure. - Minimum required space update file * 2 - For resume, subtract the downloaded file size. Change-Id: Ia7beb22869374e5885100c0eb72e108275e9ada9 --- res/values/strings.xml | 2 +- .../lineageos/updater/UpdatesListAdapter.java | 61 ++++++++++++++----- 2 files changed, 48 insertions(+), 15 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 00b71278..28c92f44 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -62,7 +62,7 @@ Low battery The battery level is too low, you need at least %1$d%% of the battery to continue, %2$d%% if charging. Free up space - The update cannot be completed because there is insufficient free space; at least %1$s of free space is required. Please clear your internal storage before proceeding. + There is insufficient space available to successfully complete the update. You must free up another %1$s of space in the internal storage before proceeding. Reboot diff --git a/src/org/lineageos/updater/UpdatesListAdapter.java b/src/org/lineageos/updater/UpdatesListAdapter.java index 04ad0028..0894f2aa 100644 --- a/src/org/lineageos/updater/UpdatesListAdapter.java +++ b/src/org/lineageos/updater/UpdatesListAdapter.java @@ -57,8 +57,10 @@ import org.lineageos.updater.misc.Utils; import org.lineageos.updater.model.UpdateInfo; import org.lineageos.updater.model.UpdateStatus; +import java.io.File; import java.io.IOException; import java.text.DateFormat; +import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.List; @@ -307,6 +309,32 @@ public class UpdatesListAdapter extends RecyclerView.Adapter 0 && + updateFile.length() < update.getFileSize()) { + requiredSpace -= updateFile.length(); + } + + if (availableFreeSpace < requiredSpace) { + // Not enough space to download file + double spaceNeeded = (requiredSpace - availableFreeSpace) / (1024.0 * 1024.0); + String message = resources.getString(R.string.dialog_free_space_low_message_pct, + new DecimalFormat("#MB").format(spaceNeeded)); + return new AlertDialog.Builder(mActivity) + .setTitle(R.string.dialog_free_space_low_title) + .setMessage(message) + .setPositiveButton(android.R.string.ok, null); + } + + return null; + } + private void startDownloadWithWarning(final String downloadId) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(mActivity); boolean warn = preferences.getBoolean(Constants.PREF_MOBILE_DATA_WARNING, true); @@ -344,7 +372,15 @@ public class UpdatesListAdapter extends RecyclerView.Adapter startDownloadWithWarning(downloadId) : null; + clickListener = enabled ? view -> { + AlertDialog.Builder freeSpaceDialog = getSpaceDialog( + mUpdaterController.getUpdate(downloadId)); + if (freeSpaceDialog != null) { + freeSpaceDialog.show(); + } else { + startDownloadWithWarning(downloadId); + } + } : null; break; case PAUSE: button.setText(R.string.action_pause); @@ -360,7 +396,12 @@ public class UpdatesListAdapter extends RecyclerView.Adapter { if (canInstall) { - mUpdaterController.resumeDownload(downloadId); + AlertDialog.Builder freeSpaceDialog = getSpaceDialog(update); + if (freeSpaceDialog != null) { + freeSpaceDialog.show(); + } else { + mUpdaterController.resumeDownload(downloadId); + } } else { mActivity.showSnackbar(R.string.snack_update_not_installable, Snackbar.LENGTH_LONG); @@ -376,7 +417,10 @@ public class UpdatesListAdapter extends RecyclerView.Adapter { if (canInstall) { AlertDialog.Builder installDialog = getInstallDialog(downloadId); - if (installDialog != null) { + AlertDialog.Builder freeSpaceDialog = getSpaceDialog(update); + if (freeSpaceDialog != null) { + freeSpaceDialog.show(); + } else if (installDialog != null) { installDialog.show(); } } else { @@ -472,17 +516,6 @@ public class UpdatesListAdapter extends RecyclerView.Adapter= neededSpace; - if (!hasFreeSpace) { - String message = resources.getString(R.string.dialog_free_space_low_message_pct, - Utils.getFileSize(neededSpace)); - return new AlertDialog.Builder(mActivity) - .setTitle(R.string.dialog_free_space_low_title) - .setMessage(message) - .setPositiveButton(android.R.string.ok, null); - } - String buildDate = StringGenerator.getDateLocalizedUTC(mActivity, DateFormat.MEDIUM, update.getTimestamp()); String buildInfoText = mActivity.getString(R.string.list_build_version_date_e, -- GitLab From 3d2c4070a975007ad722352fb3739316ae9d8e01 Mon Sep 17 00:00:00 2001 From: althafvly Date: Thu, 2 Feb 2023 17:22:57 +0530 Subject: [PATCH 37/43] Updater: update freespace dialog string Change-Id: Ifadfd7361ce73e25d9061a22420aaf342ceda585 --- res/values/strings.xml | 2 +- src/org/lineageos/updater/UpdatesListAdapter.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 28c92f44..d908f2e7 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -62,7 +62,7 @@ Low battery The battery level is too low, you need at least %1$d%% of the battery to continue, %2$d%% if charging. Free up space - There is insufficient space available to successfully complete the update. You must free up another %1$s of space in the internal storage before proceeding. + There is not enough space left to proceed with the update: you must free up another %1$s in the internal storage first. Reboot diff --git a/src/org/lineageos/updater/UpdatesListAdapter.java b/src/org/lineageos/updater/UpdatesListAdapter.java index 0894f2aa..8afd1d23 100644 --- a/src/org/lineageos/updater/UpdatesListAdapter.java +++ b/src/org/lineageos/updater/UpdatesListAdapter.java @@ -325,7 +325,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter Date: Thu, 23 Feb 2023 10:08:27 +0530 Subject: [PATCH 38/43] Updater: ignore dialog if space is below 1mb Change-Id: Ife38e01a194ac5fddd92083e92deec8d332341dc --- .../lineageos/updater/UpdatesListAdapter.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/org/lineageos/updater/UpdatesListAdapter.java b/src/org/lineageos/updater/UpdatesListAdapter.java index 8afd1d23..74baedbe 100644 --- a/src/org/lineageos/updater/UpdatesListAdapter.java +++ b/src/org/lineageos/updater/UpdatesListAdapter.java @@ -324,12 +324,16 @@ public class UpdatesListAdapter extends RecyclerView.Adapter= 1) { + String message = resources.getString(R.string.dialog_free_space_low_message_pct, + new DecimalFormat("# MB").format(spaceNeeded)); + return new AlertDialog.Builder(mActivity) + .setTitle(R.string.dialog_free_space_low_title) + .setMessage(message) + .setPositiveButton(android.R.string.ok, null); + } } return null; -- GitLab From e3be0fbba4d66508136e8348524e3223a075e3bb Mon Sep 17 00:00:00 2001 From: althafvly Date: Tue, 7 Feb 2023 17:12:23 +0530 Subject: [PATCH 39/43] Updater: Utils: Move battery level check Change-Id: I94447b33e717bd05f8a93d8a7784c862a07f8c3a --- .../lineageos/updater/UpdatesListAdapter.java | 23 +------------------ src/org/lineageos/updater/misc/Utils.java | 23 ++++++++++++++++++- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/org/lineageos/updater/UpdatesListAdapter.java b/src/org/lineageos/updater/UpdatesListAdapter.java index 74baedbe..0450fb82 100644 --- a/src/org/lineageos/updater/UpdatesListAdapter.java +++ b/src/org/lineageos/updater/UpdatesListAdapter.java @@ -16,10 +16,8 @@ package org.lineageos.updater; import android.content.Intent; -import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.res.Resources; -import android.os.BatteryManager; import android.os.PowerManager; import android.text.SpannableString; import android.text.format.Formatter; @@ -68,10 +66,6 @@ public class UpdatesListAdapter extends RecyclerView.Adapter mDownloadIds; @@ -498,7 +492,7 @@ public class UpdatesListAdapter extends RecyclerView.Adapter= required; - } } diff --git a/src/org/lineageos/updater/misc/Utils.java b/src/org/lineageos/updater/misc/Utils.java index f21df4b6..18eef0d8 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -22,11 +22,11 @@ import static android.os.SystemUpdateManager.STATUS_IDLE; import static android.os.SystemUpdateManager.STATUS_WAITING_DOWNLOAD; import android.app.AlarmManager; -import android.os.Build; import android.content.ClipData; import android.content.ClipboardManager; import android.content.Context; import android.content.Intent; +import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.pm.PackageManager; import android.database.Cursor; @@ -34,6 +34,8 @@ import android.net.ConnectivityManager; import android.net.Network; import android.net.NetworkCapabilities; import android.net.Uri; +import android.os.BatteryManager; +import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.os.PersistableBundle; @@ -72,6 +74,10 @@ import java.util.zip.ZipFile; public class Utils { + private static final int BATTERY_PLUGGED_ANY = BatteryManager.BATTERY_PLUGGED_AC + | BatteryManager.BATTERY_PLUGGED_USB + | BatteryManager.BATTERY_PLUGGED_WIRELESS; + private static final String TAG = "Utils"; private static final String CONTENT_URI_PATH = "content://custom.setting.Provider.OTA_SERVER/cte"; @@ -543,6 +549,21 @@ public class Utils { return new File(Constants.UPDATE_RECOVERY_EXEC).exists(); } + public static boolean isBatteryLevelOk(Context context) { + Intent intent = context.registerReceiver(null, + new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); + if (!intent.getBooleanExtra(BatteryManager.EXTRA_PRESENT, false)) { + return true; + } + int percent = Math.round(100.f * intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 100) / + intent.getIntExtra(BatteryManager.EXTRA_SCALE, 100)); + int plugged = intent.getIntExtra(BatteryManager.EXTRA_PLUGGED, 0); + int required = (plugged & BATTERY_PLUGGED_ANY) != 0 ? + context.getResources().getInteger(R.integer.battery_ok_percentage_charging) : + context.getResources().getInteger(R.integer.battery_ok_percentage_discharging); + return percent >= required; + } + public static void updateSystemUpdaterService(Context context, int status, String version) { final SystemUpdateManager updateManager = context.getSystemService(SystemUpdateManager.class); -- GitLab From 0c6303abb98b0b48f45391023748878835555913 Mon Sep 17 00:00:00 2001 From: althafvly Date: Tue, 7 Feb 2023 17:13:17 +0530 Subject: [PATCH 40/43] Updater: Update A/B devices on one go Change-Id: Iac2a6888b8da6b27c0c9887f32266e8e5b73d9af --- res/values/strings.xml | 2 + .../lineageos/updater/UpdatesListAdapter.java | 9 ++-- .../updater/controller/UpdaterService.java | 43 ++++++++++++++++++- 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index d908f2e7..15d8ba54 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -52,6 +52,7 @@ Pause Resume Suspend + Reboot and install Installing update package Install error @@ -108,6 +109,7 @@ You are running the latest /e/OS version. To manually check for updates, use the Refresh button. Download + Apply update Pause Resume Install diff --git a/src/org/lineageos/updater/UpdatesListAdapter.java b/src/org/lineageos/updater/UpdatesListAdapter.java index 0450fb82..3b78a259 100644 --- a/src/org/lineageos/updater/UpdatesListAdapter.java +++ b/src/org/lineageos/updater/UpdatesListAdapter.java @@ -240,7 +240,8 @@ public class UpdatesListAdapter extends RecyclerView.Adapter { if (checkbox.isChecked()) { preferences.edit() @@ -368,7 +370,8 @@ public class UpdatesListAdapter extends RecyclerView.Adapter { AlertDialog.Builder freeSpaceDialog = getSpaceDialog( diff --git a/src/org/lineageos/updater/controller/UpdaterService.java b/src/org/lineageos/updater/controller/UpdaterService.java index bf013900..c1dec3b6 100644 --- a/src/org/lineageos/updater/controller/UpdaterService.java +++ b/src/org/lineageos/updater/controller/UpdaterService.java @@ -357,12 +357,45 @@ public class UpdaterService extends Service { mNotificationBuilder.setSmallIcon(R.drawable.ic_system_update); mNotificationBuilder.setProgress(0, 0, false); String text = getString(R.string.download_completed_notification); + boolean hasRequiredSpace = Utils.availableFreeSpace() > (update.getFileSize() * 2); + + if (!Utils.canInstall(update) || !Utils.isBatteryLevelOk(this) + || !hasRequiredSpace) { + /* Show notification if any of the below condition didn't met. */ + text = getString(R.string.blocked_update_dialog_title) + ". "; + if (!Utils.isBatteryLevelOk(this)) { + text = text + getString(R.string.dialog_battery_low_title); + } else if (!hasRequiredSpace) { + text = text + getString(R.string.dialog_free_space_low_title); + } else if (!Utils.canInstall(update)) { + text = text + getString(R.string.verification_failed_notification); + } + } else if (!Utils.isABDevice()) { + /* Add action to reboot and install for Non-A/B devices. */ + mNotificationBuilder.mActions.clear(); + mNotificationBuilder.addAction(R.drawable.ic_system_update, + getString(R.string.reboot_install), + getInstallationPendingIntent(update.getDownloadId())); + } + mNotificationBuilder.setContentText(text); mNotificationBuilder.setTicker(text); mNotificationBuilder.setOngoing(false); mNotificationBuilder.setAutoCancel(true); mNotificationManager.notify(NOTIFICATION_ID, mNotificationBuilder.build()); - tryStopSelf(); + + /* Make sure these conditions are met before auto install + - Can install package (Is a newer build or downgrade allowed) + - Battery level (Above 30% if discharging or 20% if charging) + - Free space to install (Double the size of the ota zip) + */ + if (Utils.isABDevice() && Utils.canInstall(update) + && Utils.isBatteryLevelOk(this) && hasRequiredSpace) { + Utils.triggerUpdate(this, update.getDownloadId()); + } else { + tryStopSelf(); + } + break; } case VERIFICATION_FAILED: { @@ -551,6 +584,14 @@ public class UpdaterService extends Service { PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); } + private PendingIntent getInstallationPendingIntent(String downloadId) { + final Intent intent = new Intent(this, UpdaterService.class); + intent.setAction(ACTION_INSTALL_UPDATE); + intent.putExtra(UpdaterService.EXTRA_DOWNLOAD_ID, downloadId); + return PendingIntent.getService(this, 0, intent, + PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE); + } + private PendingIntent getResumeInstallationPendingIntent() { final Intent intent = new Intent(this, UpdaterService.class); intent.setAction(ACTION_INSTALL_RESUME); -- GitLab From 7c0240dba93dde0961c359ec6ab7251a5ee6c3dd Mon Sep 17 00:00:00 2001 From: althafvly Date: Wed, 8 Feb 2023 11:57:45 +0530 Subject: [PATCH 41/43] Updater: check for active notifications before self stop Change-Id: I869ab48a0d518bac3522aab2b8778321612855d1 --- .../updater/controller/UpdaterService.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/org/lineageos/updater/controller/UpdaterService.java b/src/org/lineageos/updater/controller/UpdaterService.java index c1dec3b6..db859e79 100644 --- a/src/org/lineageos/updater/controller/UpdaterService.java +++ b/src/org/lineageos/updater/controller/UpdaterService.java @@ -31,6 +31,7 @@ import android.content.SharedPreferences; import android.os.Binder; import android.os.Bundle; import android.os.IBinder; +import android.service.notification.StatusBarNotification; import android.text.format.Formatter; import android.util.Log; @@ -249,12 +250,28 @@ public class UpdaterService extends Service { private void tryStopSelf() { if (!mHasClients && !mUpdaterController.hasActiveDownloads() && - !mUpdaterController.isInstallingUpdate() && !isNetworkCallBackActive()) { + !mUpdaterController.isInstallingUpdate() && !isNetworkCallBackActive() + && !areNotificationsActive()) { Log.d(TAG, "Service no longer needed, stopping"); stopSelf(); } } + private boolean areNotificationsActive() { + NotificationManager notificationManager = + (NotificationManager) getSystemService(NOTIFICATION_SERVICE); + StatusBarNotification[] notifications = notificationManager.getActiveNotifications(); + if (notifications != null && notifications.length > 0) { + for (StatusBarNotification notification : notifications) { + if (notification.getId() == NOTIFICATION_ID && + notification.getPackageName().equals(getPackageName())) { + return true; + } + } + } + return false; + } + private void handleUpdateStatusChange(UpdateInfo update) { switch (update.getStatus()) { case DELETED: { -- GitLab From b4e06d00624b373e7ddc3ceef56ce50b2707455c Mon Sep 17 00:00:00 2001 From: althafvly Date: Thu, 9 Feb 2023 12:55:25 +0530 Subject: [PATCH 42/43] Updater: change download completed string Change-Id: Icc5409297ff01b58de4eb21dcf6012262324c099 --- 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 15d8ba54..ffac2109 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -40,7 +40,7 @@ Downloading Download paused Download error - Download completed + Update is ready to be installed Starting download Update failed Installation suspended -- GitLab From d6c14c495f633870a68191c8dc35fd1715c4f470 Mon Sep 17 00:00:00 2001 From: Nishith Khanna Date: Wed, 22 Mar 2023 17:56:37 +0530 Subject: [PATCH 43/43] Port translation changes from Android S --- res/values-de/strings.xml | 24 ++++++++++---- res/values-es/strings.xml | 28 ++++++++++++++-- res/values-fr/strings.xml | 36 ++++++++++++++++++--- res/values-it/strings.xml | 68 ++++++++++++++++++++++++--------------- res/values-nl/strings.xml | 20 +++++++++--- res/values-ru/strings.xml | 29 ++++++++++++----- 6 files changed, 154 insertions(+), 51 deletions(-) diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 175187fb..e6dffd67 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -13,10 +13,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ---> - - Updater - Updater +--> + Aktualisierungsprogramm + Aktualisierungsprogramm Überprüfung fehlgeschlagen Update wird geprüft Wird heruntergeladen @@ -70,7 +69,7 @@ %1$s von %2$s %1$s von %2$s (%3$s) Update wird geprüft - Keine neuen Updates gefunden. Um manuell nach neuen Updates zu suchen, verwende die Schaltfläche \"Aktualisieren\". + Auf deinem Telefon läuft die neueste /e/OS-Version. Um manuell nach neuen Aktualisierungen zu suchen, verwende die Schaltfläche „Aktualisieren“. Herunterladen Anhalten Fortsetzen @@ -116,4 +115,17 @@ Schon gewusst? LineageOS-Updates sind vollständige Installationspakete. Das bedeutet, dass du immer nur das neueste Update installieren zu brauchst, auch wenn du zwischendurch welche übersprungen hast! Danke für die Information! - + /e/OS +\n%1$s + /e/OS-Aktualisierungen sind immer vollständige Installationspakete. Das bedeutet, dass du nur die neueste Aktualisierung aufspielen musst, selbst wenn du eine vorherige Aktualisierung vergessen hast. + Versionshinweise anzeigen + /e/OS %1$s - %2$s + /e/OS %1$s + Verfügbare Aktualisierungen: + Aktuelle Version: + Alle 30 Minuten + Alle 10 Minuten + Alle 5 Minuten + Die Aktualisierung kann nicht abgeschlossen werden, weil nicht genug Speicher frei ist. Mindestens %1$s freier interner Speicher ist nötig, bevor du weitermachst. + Platz schaffen + \ No newline at end of file diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index 49b5231f..a7f96880 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -13,8 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ---> - +--> Actualizador Actualizador Verificación fallida @@ -93,4 +92,27 @@ Exportación finalizada Nuevas actualizaciones Descargas en curso - + Versión actual: + Actualizaciones disponibles: + ¡Gracias por la información! + ¿Lo sabías\? + Actualización fallida + + Queda una hora + %dHoras restantes + %dHoras restantes + + Exportación iniciada + Actualizar recovery + Priorizar el proceso de actualización + Nunca + Una vez al mes + Una vez a la semana + Una vez al día + La actualización no puede completarse porque no hay suficiente espacio libre; al menos %1$s de espacio libre. Por favor, borra tu almacenamiento interno antes de proceder. + Liberar espacio + El nivel de la batería es demasiado bajo, necesita al menos %1$d%% de batería para continuar, %2$d%% si se está cargando. + Suspender + Instalación suspendida + Actualización fallida + \ No newline at end of file diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index ca132efe..0f7a69c0 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -13,8 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ---> - +--> Gestionnaire de mise à jour Gestionnaire de mise à jour Échec de la vérification @@ -68,7 +67,7 @@ LineageOS %1$s LineageOS %1$s - %2$s Vérification de la mise à jour en cours - Aucune nouvelle mise à jour trouvée. Pour vérifier manuellement la présence de mises à jour, utiliser le bouton Actualiser. + Vous utilisez actuellement la dernière version de /e/OS. Pour vérifier manuellement la présence de mises à jour, utilisez le bouton Actualiser. Télécharger Mettre en pause Reprendre @@ -108,4 +107,33 @@ Nouvelles mises à jour Téléchargements en cours Échec de la mise à jour - + Version actuelle : + /e/OS +\n%1$s + /e/OS %1$s - %2$s + /e/OS %1$s + Merci pour l\'info ! + Le saviez-vous \? + L\'export a démarré + %1$s de %2$s (%3$s) + %1$s de %2$s + Toutes les 30 minutes + Toutes les 10 minutes + Toutes les 5 minutes + Vous êtes sur le point de passer à la version %1$s. +\n +\nLorsque vous appuierez sur %2$s, votre appareil redémarrera automatiquement en mode récupération pour installer la mise à jour. +\n +\nRemarque : Cette opération nécessite une partition de récupération compatible, sans quoi les mises à jour devront être installées manuellement. + L\'espace disponible n\'est pas suffisant pour installer la mise à jour : merci de libérer au moins %1$s de mémoire interne pour pouvoir continuer. + Libérez de l\'espace + Vous êtes sur le point de passer à la version %1$s. +\n +\nLorsque vous appuierez sur %2$s, l’appareil commencera l\'installation en arrière plan. +\n +\nUne fois celle-ci terminée, il vous sera demandé de redémarrer. + Les mises à jour de LineageOS sont des paquets d\'installation complets. Cela signifie que vous pouvez toujours installer uniquement la dernière mise à jour, même si vous en avez raté quelques unes entre temps ! + Les mises à jour de /e/OS sont des paquets d\'installation complets. Cela signifie que vous pouvez vous contenter d\'installer la dernière mise à jour proposée, même si vous en avez raté quelques unes entre temps ! + Afficher les notes de version + Mises à jour disponibles : + \ No newline at end of file diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index 898a3c78..d8ab07c2 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -13,8 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ---> - +--> Aggiornamenti Aggiornamenti Verifica fallita @@ -31,18 +30,18 @@ Pausa Riprendi Sospendi - Installazione del pacchetto aggiornamento + Installo il pacchetto aggiornato Errore d\'installazione Aggiornamento installato - Finalizzalizzazione del pachetto d\'installazione in corso + Sto completando l\'installazione del pacchetto Preparazione per il primo avvio Preparazione aggiornamento preliminare Batteria scarica Il livello della batteria è troppo basso, è necessario almeno il %1$d%% di batteria per continuare, oppure il %2$d%% se il dispositivo è in carica. - Riavvia + Riavvio Ricarica Preferenze - Ricerca aggiornamenti automaticamente + Verifico aggiornamenti automatici Quotidianamente Settimanalmente Mensilmente @@ -52,25 +51,26 @@ Copia indirizzo URL Esporta aggiornamento Mostra il changelog - Agg. con priorità - Aggiornamento recovery - Impossibile disabilitare l\'aggiornamento di Lineage Recovery su questo dispositivo - Nessun aggiornamento trovato + Aggiorna con priorità + Aggiorna recovery + Impossibile disabilitare gli aggiornamenti di Lineage Recovery su questo dispositivo. + Trovati nuovi aggiornamenti Nessun nuovo aggiornamento trovato - La verifica di aggiornamenti è fallita. Controlla la connessione ad internet e riprova più tardi. - Il download dell\'aggiornamento è fallito. Controlla la connessione ad internet e riprova più tardi. - Verifica dell\'aggiornamento fallita. - Download aggiornamento completato. - Questo aggiornamento non può essere installato sopra la versione corrente. - LineageOS\n%1$s + Controllo degli aggiornamenti non riuscito. Verifica la connessione a Internet e riprova. + Download non riuscito. Verifica la connessione a Internet e riprova. + Verifica dell\'aggiornamento non riuscita. + Download completato. + Questo aggiornamento non può essere installato sulla build attuale. + LineageOS +\n%1$s Android %1$s - Ultima verifica: %1$s (%2$s) + Ultima verifica: %1$s (%2$s) LineageOS %1$s LineageOS %1$s - %2$s %1$s di %2$s %1$s di %2$s (%3$s) Verifica aggiornamento - Nessun nuovo aggiornamento trovato. Per controllare manualmente nuovi aggiornamenti, tocca il pulsante Aggiorna. + Stai usando l\'ultima versione di /e/OS. Per verificare manualmente la presenza di aggiornamenti, utilizza il pulsante Aggiorna. Download Pausa Riprendi @@ -79,41 +79,57 @@ Elimina Annulla Elimina file - Eliminare il file di aggiornamento selezionato? + Elimino il file di aggiornamento selezionato\? Applica aggiornamento Stai per installare %1$s.\n\nSe premi %2$s, il dispositivo verrà riavviato in modalità recovery per installare l\'aggiornamento automaticamente.\n\nNota: questa funzione richiede una recovery compatibile, in caso contrario si dovrà procedere all\'installazione manualmente. Stai per installare %1$s.\n\nSe premi %2$s, il dispositivo inizierà l\'installazione in background.\n\nUna volta completato, ti verrà richiesto di riavviare il dispositivo. - Annullare l\'installazione? + Annullo l\'installazione\? Download URL URL copiato - Esportazione aggiornamento + Esporto aggiornamento Aggiornamento esportato Errore esportazione Esportazione aggiornamento già in corso Esportazione avviata 1 secondo rimanente + %d secondi rimanenti %d secondi rimanenti 1 minuto rimanente + %d minuti rimanenti %d minuti rimanenti 1 ora rimanente + %d ore rimanenti %d ore rimanenti Attenzione - Stai per scaricare un aggiornamento utilizzando i dati mobili, ciò potrebbe comportare un utilizzo elevato di dati. Vuoi procedere? + Stai per scaricare un pacchetto di aggiornamento utilizzando la rete mobile, il che probabilmente causerà un elevato consumo di dati. Vuoi procedere\? Non mostrare di nuovo - Avviso utilizzo dati mobili + Avviso consumo dati su rete Mobile Aggiornamento bloccato - Questo aggiornamento non può essere installato usando l\'app updater. Si prega di leggere %1$s per ulteriori informazioni. + Questo aggiornamento non può essere installato usando l\'app updater. Leggi su %1$s per ulteriori informazioni. Completamento esportazione Nuovi aggiornamenti - Download in corso + Download in essere Aggiornamento fallito Lo sapevi? Gli aggiornamenti di LineageOS sono pacchetti d\'installazione completi. Questo significa che puoi sempre installare solo l\'ultimo aggiornamento, anche se ne hai saltati alcuni in precedenza! Grazie per l\'informazione! - + /e/OS +\n%1$s + Gli aggiornamenti di /e/OS sono pacchetti completi. Ciò significa che puoi sempre installare solo l\'ultimo aggiornamento, anche se ne hai saltati alcuni in mezzo! + Mostra note di rilascio + /e/OS %1$s - %2$s + /e/OS %1$s + Ogni 30 minuti + Ogni 10 minuti + Ogni 5 minuti + Versione attuale: + Agiornamenti disponibili: + Non c\'è spazio sufficiente per procedere con l\'aggiornamento; devi liberare almeno altri %1$s dalla memoria interna. + Libera spazio + \ No newline at end of file diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml index a332ed83..19dbd996 100644 --- a/res/values-nl/strings.xml +++ b/res/values-nl/strings.xml @@ -13,8 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ---> - +--> Updater Updater Verificatie mislukt @@ -70,7 +69,7 @@ %1$s van %2$s %1$s of %2$s (%3$s) Update verifiëren - Geen nieuwe updates gevonden. Gebruik de knop Vernieuwen om handmatig te controleren op nieuwe updates. + Je gebruikt de laatste versie van /e/OS. Gebruik de knop Vernieuwen om handmatig te controleren op nieuwe updates. Downloaden Pauzeren Hervatten @@ -116,4 +115,17 @@ Wist u dat? LineageOS updates zijn volledige installatiepakketten. Dat betekent dat u altijd alleen de nieuwste update hoeft te installeren, zelfs als u een paar updates overslaat! Bedankt voor de informatie! - + Beschikbare updates: + /e/OS +\n%1$s + /e/OS updates zijn volledige installatie pakketten.Dat betekend dat je altijd de laatste update kan installeren, zelfs als je hiermee sommige updates overslaat! + Toon release notes + /e/OS %1$s - %2$s + /e/OS %1$s + Huidige versie: + Elke 30 minuten + Elke 10 minuten + Elke 5 minuten + Er is niet genoeg geheugen vrij om deze update uit te voeren: je moet eerst nog %1$s intern geheugen vrijmaken. + Geheugen vrij maken + \ No newline at end of file diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index c9592bbe..4d86306b 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -13,8 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ---> - +--> Обновления системы Обновления системы Проверка не удалась @@ -62,7 +61,8 @@ Ошибка проверки обновления. Загрузка завершена. Это обновление не может быть установлено поверх текущей сборки. - LineageOS\n%1$s + LineageOS +\n%1$s Android %1$s Поиск обновлений выполнялся %1$s в %2$s LineageOS %1$s @@ -70,7 +70,7 @@ %1$s из %2$s %1$s из %2$s (%3$s) Проверка обновлений - Обновлений не найдено. Чтобы проверить наличие обновлений вручную, используйте кнопку Обновить. + Вы используете последнюю версию /e/OS. Чтобы проверить наличие обновлений вручную, используйте кнопку Обновить. Скачать Приостановить Возобновить @@ -92,19 +92,19 @@ Экспорт уже выполняется Экспорт начат - осталась %d секунда + осталась %d секунда осталось %d секунды осталось %d секунд осталось %d секунд - осталась %d минута + осталась %d минута осталось %d минуты осталось %d минут осталось %d минут - остался %d час + остался %d час осталось %d часа осталось %d часов осталось %d часов @@ -122,4 +122,17 @@ Знаете ли вы? Обновления LineageOS представляют собой полные установочные пакеты. Это означает, что вы всегда можете установить только последнее обновление, даже если вы пропустили некоторые из них! Спасибо за информацию! - + /e/OS +\n%1$s + Обновления /e/OS представляют собой полные установочные пакеты. Это означает, что вы всегда можете установить только последнее обновление, даже если вы пропустили несколько обновлений между ними! + Показать примечания к выпуску + /e/OS %1$s - %2$s + /e/OS %1$s + Каждые 30 минут + Каждые 10 минут + Каждые 5 минут + Текущая версия: + Доступные обновления: + Для продолжения обновления недостаточно места: сначала необходимо освободить еще %1$s во внутреннем хранилище. + Освободить место + \ No newline at end of file -- GitLab