Add payload prop to set custom proxy URL
Partners are asking for a way to set custom proxy. This allows partners
to implement custom download logic in their own proxy servers, for
example, networking preferences, download speed throttling, etc.
Test: partner verification
Bug: 235816007
Change-Id: Ia3645e36f677db62b918f3246bcbff82d7e72bc4
diff --git a/aosp/update_attempter_android.cc b/aosp/update_attempter_android.cc
index 9c16329..b95da94 100644
--- a/aosp/update_attempter_android.cc
+++ b/aosp/update_attempter_android.cc
@@ -339,6 +339,12 @@
if (!headers[kPayloadPropertyUserAgent].empty())
fetcher->SetHeader("User-Agent", headers[kPayloadPropertyUserAgent]);
+ if (!headers[kPayloadPropertyNetworkProxy].empty()) {
+ LOG(INFO) << "Using proxy url from payload headers: "
+ << headers[kPayloadPropertyNetworkProxy];
+ fetcher->SetProxies({headers[kPayloadPropertyNetworkProxy]});
+ }
+
BuildUpdateActions(fetcher);
SetStatusAndNotify(UpdateStatus::UPDATE_AVAILABLE);
diff --git a/common/constants.h b/common/constants.h
index 53c5bba..b862549 100644
--- a/common/constants.h
+++ b/common/constants.h
@@ -172,6 +172,10 @@
// This can be used to zero-rate OTA traffic by sending it over the correct
// network.
static constexpr const auto& kPayloadPropertyNetworkId = "NETWORK_ID";
+
+// Proxy URL to use for downloading OTA. This will be forwarded to libcurl
+static constexpr const auto& kPayloadPropertyNetworkProxy = "NETWORK_PROXY";
+
// Set "SWITCH_SLOT_ON_REBOOT=0" to skip marking the updated partitions active.
// The default is 1 (always switch slot if update succeeded).
static constexpr const auto& kPayloadPropertySwitchSlotOnReboot =