Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5252d606 authored by Gabriele M's avatar Gabriele M
Browse files

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: lineage.updater.uri must be updated accordingly

Change-Id: Iecfdaf9d422d08a707c7319bafea5befc6b757d2
parent 4fa7ba91
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -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>
+9 −5
Original line number Diff line number Diff line
@@ -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) {