Skip to content

Commit

Permalink
Define the entire server URL as resource
Browse files Browse the repository at this point in the history
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: lineage.updater.uri must be updated accordingly

Change-Id: Iecfdaf9d422d08a707c7319bafea5befc6b757d2
  • Loading branch information
Gabriele M committed Apr 5, 2018
1 parent 4fa7ba9 commit 5252d60
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
8 changes: 7 additions & 1 deletion res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@
The path is relative to the root of the external storage.-->
<string name="export_path" translatable="false">LineageOS updates/</string>

<string name="conf_update_server_url_def" translatable="false">https://download.lineageos.org/api</string>
<!--
Optional placeholders replaced at runtime:
{device} - Device name
{type} - Build type
{incr} - Incremental version
-->
<string name="updater_server_url" translatable="false">https://download.lineageos.org/api/v1/{device}/{type}/{incr}</string>

<string name="verification_failed_notification">Verification failed</string>
<string name="verifying_download_notification">Verifying update</string>
Expand Down
14 changes: 9 additions & 5 deletions src/org/lineageos/updater/misc/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,19 @@ public static List<UpdateInfo> parseJson(File file, boolean compatibleOnly)
}

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) {
Expand Down

0 comments on commit 5252d60

Please sign in to comment.