diff options
-rw-r--r-- | UpdateEngine.conf | 3 | ||||
-rw-r--r-- | client_library/client_dbus.cc | 4 | ||||
-rw-r--r-- | client_library/client_dbus.h | 2 | ||||
-rw-r--r-- | client_library/include/update_engine/client.h | 3 | ||||
-rw-r--r-- | common/constants.cc | 1 | ||||
-rw-r--r-- | common/constants.h | 1 | ||||
-rw-r--r-- | common_service.cc | 16 | ||||
-rw-r--r-- | common_service.h | 4 | ||||
-rw-r--r-- | common_service_unittest.cc | 15 | ||||
-rw-r--r-- | dbus_bindings/org.chromium.UpdateEngineInterface.dbus-xml | 3 | ||||
-rw-r--r-- | dbus_service.cc | 5 | ||||
-rw-r--r-- | dbus_service.h | 3 | ||||
-rw-r--r-- | omaha_request_action.cc | 26 | ||||
-rw-r--r-- | omaha_request_action.h | 8 | ||||
-rw-r--r-- | omaha_request_action_unittest.cc | 50 | ||||
-rw-r--r-- | omaha_utils.cc | 29 | ||||
-rw-r--r-- | omaha_utils.h | 19 | ||||
-rw-r--r-- | omaha_utils_unittest.cc | 16 | ||||
-rw-r--r-- | update_engine_client.cc | 1 |
19 files changed, 18 insertions, 191 deletions
diff --git a/UpdateEngine.conf b/UpdateEngine.conf index 42f73fc3..e01c673d 100644 --- a/UpdateEngine.conf +++ b/UpdateEngine.conf @@ -84,9 +84,6 @@ <allow send_destination="org.chromium.UpdateEngine" send_interface="org.chromium.UpdateEngineInterface" send_member="GetLastAttemptError"/> - <allow send_destination="org.chromium.UpdateEngine" - send_interface="org.chromium.UpdateEngineInterface" - send_member="GetEolStatus"/> <allow send_interface="org.chromium.UpdateEngineLibcrosProxyResolvedInterface" /> </policy> <policy user="power"> diff --git a/client_library/client_dbus.cc b/client_library/client_dbus.cc index d1d6cc01..3497ce08 100644 --- a/client_library/client_dbus.cc +++ b/client_library/client_dbus.cc @@ -272,9 +272,5 @@ bool DBusUpdateEngineClient::GetLastAttemptError( return proxy_->GetLastAttemptError(last_attempt_error, nullptr); } -bool DBusUpdateEngineClient::GetEolStatus(int32_t* eol_status) const { - return proxy_->GetEolStatus(eol_status, nullptr); -} - } // namespace internal } // namespace update_engine diff --git a/client_library/client_dbus.h b/client_library/client_dbus.h index c9631cf7..e964399b 100644 --- a/client_library/client_dbus.h +++ b/client_library/client_dbus.h @@ -85,8 +85,6 @@ class DBusUpdateEngineClient : public UpdateEngineClient { bool GetLastAttemptError(int32_t* last_attempt_error) const override; - bool GetEolStatus(int32_t* eol_status) const override; - private: void DBusStatusHandlersRegistered(const std::string& interface, const std::string& signal_name, diff --git a/client_library/include/update_engine/client.h b/client_library/include/update_engine/client.h index 89f36af6..1a0461c0 100644 --- a/client_library/include/update_engine/client.h +++ b/client_library/include/update_engine/client.h @@ -135,9 +135,6 @@ class UpdateEngineClient { // Get the last UpdateAttempt error code. virtual bool GetLastAttemptError(int32_t* last_attempt_error) const = 0; - // Get the current end-of-life status code. See EolStatus enum for details. - virtual bool GetEolStatus(int32_t* eol_status) const = 0; - protected: // Use CreateInstance(). UpdateEngineClient() = default; diff --git a/common/constants.cc b/common/constants.cc index 64bdf0cf..d779dd44 100644 --- a/common/constants.cc +++ b/common/constants.cc @@ -56,7 +56,6 @@ const char kPrefsOmahaCohort[] = "omaha-cohort"; const char kPrefsOmahaCohortHint[] = "omaha-cohort-hint"; const char kPrefsOmahaCohortName[] = "omaha-cohort-name"; const char kPrefsOmahaEolDate[] = "omaha-eol-date"; -const char kPrefsOmahaEolStatus[] = "omaha-eol-status"; const char kPrefsP2PEnabled[] = "p2p-enabled"; const char kPrefsP2PFirstAttemptTimestamp[] = "p2p-first-attempt-timestamp"; const char kPrefsP2PNumAttempts[] = "p2p-num-attempts"; diff --git a/common/constants.h b/common/constants.h index 23c9003d..8685f7e7 100644 --- a/common/constants.h +++ b/common/constants.h @@ -57,7 +57,6 @@ extern const char kPrefsOmahaCohort[]; extern const char kPrefsOmahaCohortHint[]; extern const char kPrefsOmahaCohortName[]; extern const char kPrefsOmahaEolDate[]; -extern const char kPrefsOmahaEolStatus[]; extern const char kPrefsP2PEnabled[]; extern const char kPrefsP2PFirstAttemptTimestamp[]; extern const char kPrefsP2PNumAttempts[]; diff --git a/common_service.cc b/common_service.cc index 0d5ee6dc..d520cf13 100644 --- a/common_service.cc +++ b/common_service.cc @@ -412,20 +412,4 @@ bool UpdateEngineService::GetLastAttemptError(ErrorPtr* /* error */, return true; } -bool UpdateEngineService::GetEolStatus(ErrorPtr* error, - int32_t* out_eol_status) { - PrefsInterface* prefs = system_state_->prefs(); - - string str_eol_status; - if (prefs->Exists(kPrefsOmahaEolStatus) && - !prefs->GetString(kPrefsOmahaEolStatus, &str_eol_status)) { - LogAndSetError(error, FROM_HERE, "Error getting the end-of-life status."); - return false; - } - - // StringToEolStatus will return kSupported for invalid values. - *out_eol_status = static_cast<int32_t>(StringToEolStatus(str_eol_status)); - return true; -} - } // namespace chromeos_update_engine diff --git a/common_service.h b/common_service.h index f93855d9..3349244e 100644 --- a/common_service.h +++ b/common_service.h @@ -153,10 +153,6 @@ class UpdateEngineService { bool GetLastAttemptError(brillo::ErrorPtr* error, int32_t* out_last_attempt_error); - // Returns the current end-of-life status of the device. This value is updated - // on every update check and persisted on disk across reboots. - bool GetEolStatus(brillo::ErrorPtr* error, int32_t* out_eol_status); - private: SystemState* system_state_; }; diff --git a/common_service_unittest.cc b/common_service_unittest.cc index 65202a06..00c4357e 100644 --- a/common_service_unittest.cc +++ b/common_service_unittest.cc @@ -169,19 +169,4 @@ TEST_F(UpdateEngineServiceTest, ResetStatusFails) { UpdateEngineService::kErrorFailed)); } -TEST_F(UpdateEngineServiceTest, GetEolStatusTest) { - FakePrefs fake_prefs; - fake_system_state_.set_prefs(&fake_prefs); - // The default value should be "supported". - int32_t eol_status = static_cast<int32_t>(EolStatus::kEol); - EXPECT_TRUE(common_service_.GetEolStatus(&error_, &eol_status)); - EXPECT_EQ(nullptr, error_); - EXPECT_EQ(EolStatus::kSupported, static_cast<EolStatus>(eol_status)); - - fake_prefs.SetString(kPrefsOmahaEolStatus, "security-only"); - EXPECT_TRUE(common_service_.GetEolStatus(&error_, &eol_status)); - EXPECT_EQ(nullptr, error_); - EXPECT_EQ(EolStatus::kSecurityOnly, static_cast<EolStatus>(eol_status)); -} - } // namespace chromeos_update_engine diff --git a/dbus_bindings/org.chromium.UpdateEngineInterface.dbus-xml b/dbus_bindings/org.chromium.UpdateEngineInterface.dbus-xml index a1831476..b9e0a479 100644 --- a/dbus_bindings/org.chromium.UpdateEngineInterface.dbus-xml +++ b/dbus_bindings/org.chromium.UpdateEngineInterface.dbus-xml @@ -137,8 +137,5 @@ <method name="GetLastAttemptError"> <arg type="i" name="last_attempt_error" direction="out" /> </method> - <method name="GetEolStatus"> - <arg type="i" name="eol_status" direction="out" /> - </method> </interface> </node> diff --git a/dbus_service.cc b/dbus_service.cc index 065fe0c3..72e11eba 100644 --- a/dbus_service.cc +++ b/dbus_service.cc @@ -213,11 +213,6 @@ bool DBusUpdateEngineService::GetLastAttemptError( return common_->GetLastAttemptError(error, out_last_attempt_error); } -bool DBusUpdateEngineService::GetEolStatus(ErrorPtr* error, - int32_t* out_eol_status) { - return common_->GetEolStatus(error, out_eol_status); -} - UpdateEngineAdaptor::UpdateEngineAdaptor(SystemState* system_state) : org::chromium::UpdateEngineInterfaceAdaptor(&dbus_service_), bus_(DBusConnection::Get()->GetDBus()), diff --git a/dbus_service.h b/dbus_service.h index 2babf8c7..4ea1a532 100644 --- a/dbus_service.h +++ b/dbus_service.h @@ -157,9 +157,6 @@ class DBusUpdateEngineService bool GetLastAttemptError(brillo::ErrorPtr* error, int32_t* out_last_attempt_error) override; - // Returns the current end-of-life status of the device in |out_eol_status|. - bool GetEolStatus(brillo::ErrorPtr* error, int32_t* out_eol_status) override; - private: std::unique_ptr<UpdateEngineService> common_; }; diff --git a/omaha_request_action.cc b/omaha_request_action.cc index 7ca43720..6ebab0d1 100644 --- a/omaha_request_action.cc +++ b/omaha_request_action.cc @@ -108,7 +108,7 @@ constexpr char kValPostInstall[] = "postinstall"; constexpr char kValNoUpdate[] = "noupdate"; // updatecheck attributes (without the underscore prefix). -constexpr char kAttrEol[] = "eol"; +// Deprecated: "eol" constexpr char kAttrEolDate[] = "eol_date"; constexpr char kAttrRollback[] = "rollback"; constexpr char kAttrFirmwareVersion[] = "firmware_version"; @@ -699,8 +699,8 @@ bool OmahaRequestAction::ParseResponse(OmahaParserData* parser_data, } } - // Parse the updatecheck attributes. - PersistEolStatus(parser_data->updatecheck_attrs); + PersistEolInfo(parser_data->updatecheck_attrs); + // Rollback-related updatecheck attributes. // Defaults to false if attribute is not present. output_object->is_rollback = @@ -1317,30 +1317,16 @@ bool OmahaRequestAction::PersistCohortData(const string& prefs_key, return true; } -bool OmahaRequestAction::PersistEolStatus(const map<string, string>& attrs) { - bool ret = true; - - // Set EOL date. +bool OmahaRequestAction::PersistEolInfo(const map<string, string>& attrs) { auto eol_date_attr = attrs.find(kAttrEolDate); if (eol_date_attr == attrs.end()) { system_state_->prefs()->Delete(kPrefsOmahaEolDate); } else if (!system_state_->prefs()->SetString(kPrefsOmahaEolDate, eol_date_attr->second)) { LOG(ERROR) << "Setting EOL date failed."; - ret = false; - } - - // Set EOL. - auto eol_attr = attrs.find(kAttrEol); - if (eol_attr == attrs.end()) { - system_state_->prefs()->Delete(kPrefsOmahaEolStatus); - } else if (!system_state_->prefs()->SetString(kPrefsOmahaEolStatus, - eol_attr->second)) { - LOG(ERROR) << "Setting EOL status failed."; - ret = false; + return false; } - - return ret; + return true; } void OmahaRequestAction::ActionCompleted(ErrorCode code) { diff --git a/omaha_request_action.h b/omaha_request_action.h index 96f09e92..3f66de9b 100644 --- a/omaha_request_action.h +++ b/omaha_request_action.h @@ -183,11 +183,9 @@ class OmahaRequestAction : public Action<OmahaRequestAction>, bool PersistCohortData(const std::string& prefs_key, const std::string& new_value); - // Parse and persist the end-of-life status flag sent back in the updatecheck - // tag attributes. In addition, the optional end-of-life date flag will also - // be parsed and persisted. The flags will be validated and stored in the - // Prefs. - bool PersistEolStatus(const std::map<std::string, std::string>& attrs); + // Parses and persists the end-of-life date flag sent back in the updatecheck + // tag attributes. The flags will be validated and stored in the Prefs. + bool PersistEolInfo(const std::map<std::string, std::string>& attrs); // If this is an update check request, initializes // |ping_active_days_| and |ping_roll_call_days_| to values that may diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc index 94d5152a..b66375f2 100644 --- a/omaha_request_action_unittest.cc +++ b/omaha_request_action_unittest.cc @@ -1992,27 +1992,6 @@ TEST_F(OmahaRequestActionTest, BadElapsedSecondsTest) { ASSERT_TRUE(TestUpdateCheck()); } -TEST_F(OmahaRequestActionTest, ParseUpdateCheckAttributesTest) { - // Test that the "eol" flags is only parsed from the "_eol" attribute and not - // the "eol" attribute. - tuc_params_.http_response = - "<?xml version=\"1.0\" encoding=\"UTF-8\"?><response " - "protocol=\"3.0\"><app appid=\"foo\" status=\"ok\">" - "<ping status=\"ok\"/><updatecheck status=\"noupdate\" " - "_eol=\"security-only\" eol=\"eol\" _foo=\"bar\"/></app></response>"; - tuc_params_.expected_check_result = metrics::CheckResult::kNoUpdateAvailable; - tuc_params_.expected_check_reaction = metrics::CheckReaction::kUnset; - - ASSERT_TRUE(TestUpdateCheck()); - - string eol_pref; - EXPECT_TRUE( - fake_system_state_.prefs()->GetString(kPrefsOmahaEolStatus, &eol_pref)); - // Note that the eol="eol" attribute should be ignored and the _eol should be - // used instead. - EXPECT_EQ("security-only", eol_pref); -} - TEST_F(OmahaRequestActionTest, NoUniqueIDTest) { tuc_params_.http_response = "invalid xml>"; tuc_params_.expected_code = ErrorCode::kOmahaRequestXMLParseError; @@ -2810,62 +2789,51 @@ TEST_F(OmahaRequestActionTest, NoIncludeRequisitionTest) { EXPECT_EQ(string::npos, post_str.find("requisition")); } -TEST_F(OmahaRequestActionTest, PersistEolDatesTest) { +TEST_F(OmahaRequestActionTest, PersistEolDateTest) { tuc_params_.http_response = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><response " "protocol=\"3.0\"><app appid=\"foo\" status=\"ok\">" "<ping status=\"ok\"/><updatecheck status=\"noupdate\" " - "_eol=\"supported\" _eol_date=\"200\" " - "_foo=\"bar\"/></app></response>"; + "_eol_date=\"200\" _foo=\"bar\"/></app></response>"; tuc_params_.expected_check_result = metrics::CheckResult::kNoUpdateAvailable; tuc_params_.expected_check_reaction = metrics::CheckReaction::kUnset; ASSERT_TRUE(TestUpdateCheck()); - string eol, eol_date; - EXPECT_TRUE( - fake_system_state_.prefs()->GetString(kPrefsOmahaEolStatus, &eol)); - EXPECT_EQ(kEolStatusSupported, eol); + string eol_date; EXPECT_TRUE( fake_system_state_.prefs()->GetString(kPrefsOmahaEolDate, &eol_date)); EXPECT_EQ("200", eol_date); } -TEST_F(OmahaRequestActionTest, PersistEolMissingDatesTest) { +TEST_F(OmahaRequestActionTest, PersistEolMissingDateTest) { tuc_params_.http_response = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><response " "protocol=\"3.0\"><app appid=\"foo\" status=\"ok\">" "<ping status=\"ok\"/><updatecheck status=\"noupdate\" " - "_eol=\"supported\" _foo=\"bar\"/></app></response>"; + "_foo=\"bar\"/></app></response>"; tuc_params_.expected_check_result = metrics::CheckResult::kNoUpdateAvailable; tuc_params_.expected_check_reaction = metrics::CheckReaction::kUnset; ASSERT_TRUE(TestUpdateCheck()); - string eol, eol_date; - EXPECT_TRUE( - fake_system_state_.prefs()->GetString(kPrefsOmahaEolStatus, &eol)); - EXPECT_EQ(kEolStatusSupported, eol); + string eol_date; EXPECT_FALSE( fake_system_state_.prefs()->GetString(kPrefsOmahaEolDate, &eol_date)); } -TEST_F(OmahaRequestActionTest, PersistEolBadDatesTest) { +TEST_F(OmahaRequestActionTest, PersistEolBadDateTest) { tuc_params_.http_response = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><response " "protocol=\"3.0\"><app appid=\"foo\" status=\"ok\">" "<ping status=\"ok\"/><updatecheck status=\"noupdate\" " - "_eol=\"supported\" _eol_date=\"bad\" " - "foo=\"bar\"/></app></response>"; + "_eol_date=\"bad\" foo=\"bar\"/></app></response>"; tuc_params_.expected_check_result = metrics::CheckResult::kNoUpdateAvailable; tuc_params_.expected_check_reaction = metrics::CheckReaction::kUnset; ASSERT_TRUE(TestUpdateCheck()); - string eol, eol_date; - EXPECT_TRUE( - fake_system_state_.prefs()->GetString(kPrefsOmahaEolStatus, &eol)); - EXPECT_EQ(kEolStatusSupported, eol); + string eol_date; EXPECT_TRUE( fake_system_state_.prefs()->GetString(kPrefsOmahaEolDate, &eol_date)); EXPECT_EQ(kEolDateInvalid, StringToEolDate(eol_date)); diff --git a/omaha_utils.cc b/omaha_utils.cc index f9ec85ac..18a99cea 100644 --- a/omaha_utils.cc +++ b/omaha_utils.cc @@ -21,37 +21,8 @@ namespace chromeos_update_engine { -const char kEolStatusSupported[] = "supported"; -const char kEolStatusSecurityOnly[] = "security-only"; -const char kEolStatusEol[] = "eol"; - const EolDate kEolDateInvalid = -9999; -const char* EolStatusToString(EolStatus eol_status) { - switch (eol_status) { - case EolStatus::kSupported: - return kEolStatusSupported; - case EolStatus::kSecurityOnly: - return kEolStatusSecurityOnly; - case EolStatus::kEol: - return kEolStatusEol; - } - // Only reached if an invalid number is casted to |EolStatus|. - LOG(WARNING) << "Invalid EolStatus value: " << static_cast<int>(eol_status); - return kEolStatusSupported; -} - -EolStatus StringToEolStatus(const std::string& eol_status) { - if (eol_status == kEolStatusSupported || eol_status.empty()) - return EolStatus::kSupported; - if (eol_status == kEolStatusSecurityOnly) - return EolStatus::kSecurityOnly; - if (eol_status == kEolStatusEol) - return EolStatus::kEol; - LOG(WARNING) << "Invalid end-of-life attribute: " << eol_status; - return EolStatus::kSupported; -} - std::string EolDateToString(EolDate eol_date) { #if BASE_VER < 576279 return base::Int64ToString(eol_date); diff --git a/omaha_utils.h b/omaha_utils.h index 128232af..458bf9eb 100644 --- a/omaha_utils.h +++ b/omaha_utils.h @@ -26,25 +26,6 @@ using EolDate = int64_t; // |EolDate| indicating an invalid end-of-life date. extern const EolDate kEolDateInvalid; -// The possible string values for the end-of-life status. -extern const char kEolStatusSupported[]; -extern const char kEolStatusSecurityOnly[]; -extern const char kEolStatusEol[]; - -// The end-of-life status of the device. -enum class EolStatus { - kSupported = 0, - kSecurityOnly, - kEol, -}; - -// Returns the string representation of the |eol_status|. -const char* EolStatusToString(EolStatus eol_status); - -// Converts the end-of-life status string to an EolStatus numeric value. In case -// of an invalid string, the default "supported" value will be used instead. -EolStatus StringToEolStatus(const std::string& eol_status); - // Returns the string representation of the |eol_date|. std::string EolDateToString(EolDate eol_date); diff --git a/omaha_utils_unittest.cc b/omaha_utils_unittest.cc index ccb9578d..849905aa 100644 --- a/omaha_utils_unittest.cc +++ b/omaha_utils_unittest.cc @@ -23,22 +23,6 @@ namespace chromeos_update_engine { class OmahaUtilsTest : public ::testing::Test {}; -TEST(OmahaUtilsTest, EolStatusTest) { - EXPECT_EQ(EolStatus::kEol, StringToEolStatus("eol")); - - // Supported values are converted back and forth properly. - const std::vector<EolStatus> tests = { - EolStatus::kSupported, EolStatus::kSecurityOnly, EolStatus::kEol}; - for (EolStatus eol_status : tests) { - EXPECT_EQ(eol_status, StringToEolStatus(EolStatusToString(eol_status))) - << "The StringToEolStatus() was " << EolStatusToString(eol_status); - } - - // Invalid values are assumed as "supported". - EXPECT_EQ(EolStatus::kSupported, StringToEolStatus("")); - EXPECT_EQ(EolStatus::kSupported, StringToEolStatus("hello, world!")); -} - TEST(OmahaUtilsTest, EolDateTest) { // Supported values are converted back and forth properly. const std::vector<EolDate> tests = {kEolDateInvalid, -1, 0, 1}; diff --git a/update_engine_client.cc b/update_engine_client.cc index 7b5c4df1..e78eccfa 100644 --- a/update_engine_client.cc +++ b/update_engine_client.cc @@ -44,7 +44,6 @@ using brillo::KeyValueStore; using chromeos_update_engine::EolDate; using chromeos_update_engine::EolDateToString; -using chromeos_update_engine::EolStatus; using chromeos_update_engine::ErrorCode; using chromeos_update_engine::UpdateEngineStatusToString; using chromeos_update_engine::UpdateStatusToString; |