update_engine: Query Omaha with correct version/delta_okay during DLC Installations
When DLC(s) are being installed, the Omaha request to check should pass
a version of "0.0.0.0" instead of the same version as the platform and
the delta_okay should always be false.
During a DLC installation, the "<updatecheck></updatecheck>" is also
skipped for the platform and tests are included for those checks.
This means that dlcservice should be extra cautious in not passing in
DLC(s) that are already installed as update_engine can potentially
overwrite the file that's already in use/installed+mounted.
Example Omaha request for DLC installations:
<?xml version="1.0" encoding="UTF-8"?>
<request requestid="79a08366-3a0a-4d18-a1a7-a01a6ad7c34c" sessionid="" protocol="3.0" updater="ChromeOSUpdateEngine" updaterversion="0.1.0.0" installsource="scheduler" ismachine="1">
<os version="Indy" platform="Chrome OS" sp=""></os>
<app appid="" version="" track="" board="" hardware_class="" delta_okay="false" lang="" fw_version="" ec_version="" installdate="0" >
<event eventtype="54" eventresult="1" previousversion="0.0.0.0"></event>
</app>
<app appid="_dlc_1" version="0.0.0.0" track="" board="" hardware_class="" delta_okay="false" >
<updatecheck></updatecheck>
<event eventtype="54" eventresult="1" previousversion="0.0.0.0"></event>
</app>
<app appid="_dlc_2" version="0.0.0.0" track="" board="" hardware_class="" delta_okay="false" >
<updatecheck></updatecheck>
<event eventtype="54" eventresult="1" previousversion="0.0.0.0"></event>
</app>
</request>
BUG=chromium:1039898
TEST=FEATURES=test emerge-$B update_engine
Change-Id: Ibc1a29449e9244f38deb661d400d3fc569e7478f
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/1992194
Commit-Queue: Jae Hoon Kim <kimjae@chromium.org>
Tested-by: Jae Hoon Kim <kimjae@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
diff --git a/omaha_request_builder_xml.cc b/omaha_request_builder_xml.cc
index 823894e..8439b42 100644
--- a/omaha_request_builder_xml.cc
+++ b/omaha_request_builder_xml.cc
@@ -37,6 +37,7 @@
namespace chromeos_update_engine {
const int kNeverPinged = -1;
+const char kNoVersion[] = "0.0.0.0";
bool XmlEncode(const string& input, string* output) {
if (std::find_if(input.begin(), input.end(), [](const char c) {
@@ -131,7 +132,7 @@
// sent for this new version with a previous updatecheck.
string prev_version;
if (!prefs_->GetString(kPrefsPreviousVersion, &prev_version)) {
- prev_version = "0.0.0.0";
+ prev_version = kNoVersion;
}
// We only store a non-empty previous version value after a successful
// update in the previous boot. After reporting it back to the server,
@@ -142,7 +143,7 @@
"previousversion=\"%s\"></event>\n",
OmahaEvent::kTypeRebootedAfterUpdate,
OmahaEvent::kResultSuccess,
- XmlEncodeWithDefault(prev_version, "0.0.0.0").c_str());
+ XmlEncodeWithDefault(prev_version, kNoVersion).c_str());
LOG_IF(WARNING, !prefs_->SetString(kPrefsPreviousVersion, ""))
<< "Unable to reset the previous version.";
}
@@ -219,11 +220,11 @@
if (params_->ShouldPowerwash()) {
LOG(INFO) << "Passing OS version as 0.0.0.0 as we are set to powerwash "
<< "on downgrading to the version in the more stable channel";
- app_versions = "version=\"0.0.0.0\" from_version=\"" +
- XmlEncodeWithDefault(app_data.version, "0.0.0.0") + "\" ";
+ app_versions = "version=\"" + string(kNoVersion) + "\" from_version=\"" +
+ XmlEncodeWithDefault(app_data.version, kNoVersion) + "\" ";
} else {
app_versions = "version=\"" +
- XmlEncodeWithDefault(app_data.version, "0.0.0.0") + "\" ";
+ XmlEncodeWithDefault(app_data.version, kNoVersion) + "\" ";
}
string download_channel = params_->download_channel();
@@ -234,7 +235,8 @@
XmlEncodeWithDefault(params_->current_channel()) + "\" ";
}
- string delta_okay_str = params_->delta_okay() ? "true" : "false";
+ string delta_okay_str =
+ params_->delta_okay() && !params_->is_install() ? "true" : "false";
// If install_date_days is not set (e.g. its value is -1 ), don't
// include the attribute.
@@ -382,7 +384,7 @@
for (const auto& dlc_module_id : params_->dlc_module_ids()) {
OmahaAppData dlc_module_app = {
.id = params_->GetAppId() + "_" + dlc_module_id,
- .version = params_->app_version(),
+ .version = params_->is_install() ? kNoVersion : params_->app_version(),
.skip_update = false,
.is_dlc = true};
app_xml += GetApp(dlc_module_app);