Skip to content

Commit e930cf7

Browse files
author
Gabriele M
committed
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
1 parent 28be10b commit e930cf7

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

res/values/strings.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@
2626
The path is relative to the root of the external storage.-->
2727
<string name="export_path" translatable="false">LineageOS updates/</string>
2828

29-
<string name="conf_update_server_url_def" translatable="false">https://download.lineageos.org/api</string>
29+
<!--
30+
Optional placeholders replaced at runtime:
31+
{device} - Device name
32+
{type} - Build type
33+
{incr} - Incremental version
34+
-->
35+
<string name="updater_server_url" translatable="false">https://download.lineageos.org/api/v1/{device}/{type}/{incr}</string>
3036

3137
<string name="verification_failed_notification">Verification failed</string>
3238
<string name="verifying_download_notification">Verifying update</string>

src/org/lineageos/updater/misc/Utils.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,19 @@ public static List<UpdateInfo> parseJson(File file, boolean compatibleOnly)
144144
}
145145

146146
public static String getServerURL(Context context) {
147-
String serverUrl = SystemProperties.get(Constants.PROP_UPDATER_URI);
148-
if (serverUrl.trim().isEmpty()) {
149-
serverUrl = context.getString(R.string.conf_update_server_url_def);
150-
}
151147
String incrementalVersion = SystemProperties.get(Constants.PROP_BUILD_VERSION_INCREMENTAL);
152148
String device = SystemProperties.get(Constants.PROP_NEXT_DEVICE,
153149
SystemProperties.get(Constants.PROP_DEVICE));
154150
String type = SystemProperties.get(Constants.PROP_RELEASE_TYPE).toLowerCase(Locale.ROOT);
155-
return serverUrl + "/v1/" + device + "/" + type + "/" + incrementalVersion;
151+
152+
String serverUrl = SystemProperties.get(Constants.PROP_UPDATER_URI);
153+
if (serverUrl.trim().isEmpty()) {
154+
serverUrl = context.getString(R.string.updater_server_url);
155+
}
156+
157+
return serverUrl.replace("{device}", device)
158+
.replace("{type}", type)
159+
.replace("{incr}", incrementalVersion);
156160
}
157161

158162
public static String getChangelogURL(Context context) {

0 commit comments

Comments
 (0)