diff options
author | Sen Jiang <senj@google.com> | 2018-03-27 23:14:32 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-03-27 23:14:32 +0000 |
commit | c110fe13846e6fad11fb1981a6260a7310c2888f (patch) | |
tree | 6dfbf21ce5989eba78599de7407a693d33933160 | |
parent | 5bdcbb5d1387d6b429808174d349fea0e69183fd (diff) | |
parent | a2ebc7d45aa091637b2dfba96b382ea1be1ce8f8 (diff) |
Support optional powerwash from Omaha response. am: fe28440d08
am: a2ebc7d45a
Change-Id: I94bd70a593b8a01dd5a4fc322970c157eac7b204
-rw-r--r-- | omaha_request_action.cc | 2 | ||||
-rw-r--r-- | omaha_request_action_unittest.cc | 21 | ||||
-rw-r--r-- | omaha_response.h | 3 | ||||
-rw-r--r-- | omaha_response_handler_action.cc | 2 |
4 files changed, 27 insertions, 1 deletions
diff --git a/omaha_request_action.cc b/omaha_request_action.cc index 1becb8ee..6354641c 100644 --- a/omaha_request_action.cc +++ b/omaha_request_action.cc @@ -76,6 +76,7 @@ static const char* kTagPrompt = "Prompt"; static const char* kTagDisableP2PForDownloading = "DisableP2PForDownloading"; static const char* kTagDisableP2PForSharing = "DisableP2PForSharing"; static const char* kTagPublicKeyRsa = "PublicKeyRsa"; +static const char* kTagPowerwash = "Powerwash"; static const char* kOmahaUpdaterVersion = "0.1.0.0"; @@ -1085,6 +1086,7 @@ bool OmahaRequestAction::ParseParams(OmahaParserData* parser_data, output_object->disable_payload_backoff = ParseBool(attrs[kTagDisablePayloadBackoff]); + output_object->powerwash_required = ParseBool(attrs[kTagPowerwash]); return true; } diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc index 6bc5ba2f..9a01a132 100644 --- a/omaha_request_action_unittest.cc +++ b/omaha_request_action_unittest.cc @@ -143,6 +143,7 @@ struct FakeUpdateResponse { (disable_p2p_for_downloading ? "DisableP2PForDownloading=\"true\" " : "") + (disable_p2p_for_sharing ? "DisableP2PForSharing=\"true\" " : "") + + (powerwash ? "Powerwash=\"true\" " : "") + "/></actions></manifest></updatecheck></app>" + (multi_app ? "<app appid=\"" + app_id2 + "\"" + @@ -190,6 +191,8 @@ struct FakeUpdateResponse { bool disable_p2p_for_downloading = false; bool disable_p2p_for_sharing = false; + bool powerwash = false; + // Omaha cohorts settings. bool include_cohorts = false; string cohort = ""; @@ -558,6 +561,7 @@ TEST_F(OmahaRequestActionTest, ValidUpdateTest) { EXPECT_EQ(true, response.packages[0].is_delta); EXPECT_EQ(fake_update_response_.prompt == "true", response.prompt); EXPECT_EQ(fake_update_response_.deadline, response.deadline); + EXPECT_FALSE(response.powerwash_required); // Omaha cohort attributes are not set in the response, so they should not be // persisted. EXPECT_FALSE(fake_prefs_.Exists(kPrefsOmahaCohort)); @@ -726,6 +730,23 @@ TEST_F(OmahaRequestActionTest, MultiAppMultiPackageUpdateTest) { EXPECT_EQ(false, response.packages[2].is_delta); } +TEST_F(OmahaRequestActionTest, PowerwashTest) { + OmahaResponse response; + fake_update_response_.powerwash = true; + ASSERT_TRUE(TestUpdateCheck(nullptr, // request_params + fake_update_response_.GetUpdateResponse(), + -1, + false, // ping_only + ErrorCode::kSuccess, + metrics::CheckResult::kUpdateAvailable, + metrics::CheckReaction::kUpdating, + metrics::DownloadErrorCode::kUnset, + &response, + nullptr)); + EXPECT_TRUE(response.update_exists); + EXPECT_TRUE(response.powerwash_required); +} + TEST_F(OmahaRequestActionTest, ExtraHeadersSentTest) { const string http_response = "<?xml invalid response"; request_params_.set_interactive(true); diff --git a/omaha_response.h b/omaha_response.h index b973eb5b..3fb2f6db 100644 --- a/omaha_response.h +++ b/omaha_response.h @@ -72,6 +72,9 @@ struct OmahaResponse { // True if the Omaha rule instructs us to disable p2p for sharing. bool disable_p2p_for_sharing = false; + // True if the Omaha rule instructs us to powerwash. + bool powerwash_required = false; + // If not blank, a base-64 encoded representation of the PEM-encoded // public key in the response. std::string public_key_rsa; diff --git a/omaha_response_handler_action.cc b/omaha_response_handler_action.cc index 2d6105aa..52aea4a8 100644 --- a/omaha_response_handler_action.cc +++ b/omaha_response_handler_action.cc @@ -139,7 +139,7 @@ void OmahaResponseHandlerAction::PerformAction() { system_state_->prefs()->SetString(current_channel_key, params->download_channel()); - if (params->ShouldPowerwash()) + if (response.powerwash_required || params->ShouldPowerwash()) install_plan_.powerwash_required = true; TEST_AND_RETURN(HasOutputPipe()); |