diff --git a/res/values/strings.xml b/res/values/strings.xml index 6bcba24dc511c4fced16c7082b9b5652a5dae1c4..b2c906ad61dd97153400675a89c2697fc858f008 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 d8022ac83cdaca60237cf556a5afdaea0721b446..ae531d4584ccb4ac61b7399bf29ad9fd746336f9 100644 --- a/src/org/lineageos/updater/misc/Utils.java +++ b/src/org/lineageos/updater/misc/Utils.java @@ -1,5 +1,6 @@ /* * Copyright (C) 2017 The LineageOS Project + * Copyright (C) 2021 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.Environment; import android.os.SystemProperties; import android.os.storage.StorageManager; @@ -184,15 +187,39 @@ 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); } - return serverUrl.replace("{device}", device) .replace("{type}", type) .replace("{incr}", incrementalVersion); } + /*retrieve status from database of ota option is on or off*/ + public static String retrieveStatus(Context context) { + String status = null; + Cursor c = context.getContentResolver().query(Uri.parse("content://custom.setting.Provider.OTA_SERVER/cte"), null, "id=?", new String[]{"1"}, "Status"); + if (c.moveToFirst()) { + do { + status = c.getString(c.getColumnIndex("Status")); + } while (c.moveToNext()); + } + return status; + } public static String getUpgradeBlockedURL(Context context) { String device = SystemProperties.get(Constants.PROP_NEXT_DEVICE,