Don't update if any app has status="noupdate".
Only update if all apps have status="ok" and at least one app doesn't
have noupdate="true".
Bug: 62985600
Test: update_engine_unittests
Change-Id: I4171989e474408cea914e97f408db2ec83a94d8c
(cherry picked from commit d869bd816b8635ed2df5b2b74fdebe393bdcbd90)
diff --git a/omaha_request_action.cc b/omaha_request_action.cc
index 473f138..c3bbf9d 100644
--- a/omaha_request_action.cc
+++ b/omaha_request_action.cc
@@ -950,13 +950,20 @@
output_object->update_exists = false;
for (size_t i = 0; i < parser_data->apps.size(); i++) {
const string& status = parser_data->apps[i].updatecheck_status;
- // Also treat noupdate="true" in postinstall attributes as no update even if
- // updatecheck status says otherwise.
- if (status == "noupdate" ||
- parser_data->apps[i].action_postinstall_attrs["noupdate"] == "true") {
+ if (status == "noupdate") {
+ // Don't update if any app has status="noupdate".
LOG(INFO) << "No update for <app> " << i;
+ output_object->update_exists = false;
+ break;
} else if (status == "ok") {
- output_object->update_exists = true;
+ if (parser_data->apps[i].action_postinstall_attrs["noupdate"] == "true") {
+ // noupdate="true" in postinstall attributes means it's an update to
+ // self, only update if there's at least one app really have update.
+ LOG(INFO) << "Update to self for <app> " << i;
+ } else {
+ LOG(INFO) << "Update for <app> " << i;
+ output_object->update_exists = true;
+ }
} else {
LOG(ERROR) << "Unknown Omaha response status: " << status;
completer->set_code(ErrorCode::kOmahaResponseInvalid);
diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc
index bf2f1a0..9091031 100644
--- a/omaha_request_action_unittest.cc
+++ b/omaha_request_action_unittest.cc
@@ -147,8 +147,11 @@
"\"/></urls><manifest><packages>"
"<package name=\"package3\" size=\"333\" "
"hash_sha256=\"hash3\"/></packages>"
- "<actions><action event=\"postinstall\" "
- "MetadataSize=\"33\" IsDeltaPayload=\"false\"/></actions>"
+ "<actions><action event=\"postinstall\" " +
+ (multi_app_self_update
+ ? "noupdate=\"true\" IsDeltaPayload=\"true\" "
+ : "IsDeltaPayload=\"false\" ") +
+ "MetadataSize=\"33\"/></actions>"
"</manifest></updatecheck></app>"
: "") +
(multi_app_no_update
@@ -191,7 +194,9 @@
// Whether to include more than one app.
bool multi_app = false;
- // Whether to include an additional app with no update.
+ // Whether to include an app with noupdate="true".
+ bool multi_app_self_update = false;
+ // Whether to include an additional app with status="noupdate".
bool multi_app_no_update = false;
// Whether to include more than one package in an app.
bool multi_package = false;
@@ -492,6 +497,40 @@
EXPECT_FALSE(response.update_exists);
}
+TEST_F(OmahaRequestActionTest, MultiAppNoPartialUpdateTest) {
+ OmahaResponse response;
+ fake_update_response_.multi_app_no_update = true;
+ ASSERT_TRUE(TestUpdateCheck(nullptr, // request_params
+ fake_update_response_.GetUpdateResponse(),
+ -1,
+ false, // ping_only
+ ErrorCode::kSuccess,
+ metrics::CheckResult::kNoUpdateAvailable,
+ metrics::CheckReaction::kUnset,
+ metrics::DownloadErrorCode::kUnset,
+ &response,
+ nullptr));
+ EXPECT_FALSE(response.update_exists);
+}
+
+TEST_F(OmahaRequestActionTest, NoSelfUpdateTest) {
+ OmahaResponse response;
+ ASSERT_TRUE(TestUpdateCheck(
+ nullptr, // request_params
+ "<response><app><updatecheck status=\"ok\"><manifest><actions><action "
+ "event=\"postinstall\" noupdate=\"true\"/></actions>"
+ "</manifest></updatecheck></app></response>",
+ -1,
+ false, // ping_only
+ ErrorCode::kSuccess,
+ metrics::CheckResult::kNoUpdateAvailable,
+ metrics::CheckReaction::kUnset,
+ metrics::DownloadErrorCode::kUnset,
+ &response,
+ nullptr));
+ EXPECT_FALSE(response.update_exists);
+}
+
// Test that all the values in the response are parsed in a normal update
// response.
TEST_F(OmahaRequestActionTest, ValidUpdateTest) {
@@ -587,7 +626,8 @@
TEST_F(OmahaRequestActionTest, MultiAppPartialUpdateTest) {
OmahaResponse response;
- fake_update_response_.multi_app_no_update = true;
+ fake_update_response_.multi_app = true;
+ fake_update_response_.multi_app_self_update = true;
ASSERT_TRUE(TestUpdateCheck(nullptr, // request_params
fake_update_response_.GetUpdateResponse(),
-1,
@@ -605,7 +645,11 @@
EXPECT_EQ(fake_update_response_.hash, response.packages[0].hash);
EXPECT_EQ(fake_update_response_.size, response.packages[0].size);
EXPECT_EQ(11u, response.packages[0].metadata_size);
- ASSERT_EQ(1u, response.packages.size());
+ ASSERT_EQ(2u, response.packages.size());
+ EXPECT_EQ(string("hash3"), response.packages[1].hash);
+ EXPECT_EQ(333u, response.packages[1].size);
+ EXPECT_EQ(33u, response.packages[1].metadata_size);
+ EXPECT_EQ(true, response.packages[1].is_delta);
}
TEST_F(OmahaRequestActionTest, MultiAppMultiPackageUpdateTest) {