From e930cf7f67d10afcd933dec75879426126d8579a Mon Sep 17 00:00:00 2001 From: Gabriele M Date: Thu, 29 Mar 2018 19:28:22 +0200 Subject: [PATCH] Define the entire server URL as resource Currently the URL is only partially customizable, part of it is hard-coded and there's no clear indication of it. Define the entire URL as resource string and use placeholders for runtime variables. Also, invalidate old overrides by changing the name of the resource. Warning: cm.updater.uri must be updated accordingly Change-Id: Iecfdaf9d422d08a707c7319bafea5befc6b757d2 --- res/values/strings.xml | 8 +++++++- src/org/lineageos/updater/misc/Utils.java | 14 +++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index c1fbf30f..479a88d0 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -26,7 +26,13 @@ The path is relative to the root of the external storage.--> LineageOS updates/ - https://download.lineageos.org/api + + https://download.lineageos.org/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 5a6b42bd..6b15e2d4 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -144,15 +144,19 @@ public class Utils { } public static String getServerURL(Context context) { - String serverUrl = SystemProperties.get(Constants.PROP_UPDATER_URI); - if (serverUrl.trim().isEmpty()) { - serverUrl = context.getString(R.string.conf_update_server_url_def); - } String incrementalVersion = SystemProperties.get(Constants.PROP_BUILD_VERSION_INCREMENTAL); String device = SystemProperties.get(Constants.PROP_NEXT_DEVICE, SystemProperties.get(Constants.PROP_DEVICE)); String type = SystemProperties.get(Constants.PROP_RELEASE_TYPE).toLowerCase(Locale.ROOT); - return serverUrl + "/v1/" + device + "/" + type + "/" + incrementalVersion; + + String serverUrl = SystemProperties.get(Constants.PROP_UPDATER_URI); + if (serverUrl.trim().isEmpty()) { + serverUrl = context.getString(R.string.updater_server_url); + } + + return serverUrl.replace("{device}", device) + .replace("{type}", type) + .replace("{incr}", incrementalVersion); } public static String getChangelogURL(Context context) {