update_engine: Parse and supply EOL date for Chrome
From Omaha, the optional field |_eol_date| is to indicate the EOL of a
device. Chrome side will leverage these values to display a
notification. The value for |_eol_date| should be an integer value
indicating the days from Unix Epoch date.
If |_eol_date| does not exist in the Omaha response or have non-integer
values, the default will fallback to |kEolDateInvalid|.
BUG=chromium:998983
TEST=FEATURES="test" emerge-$B update_engine update_engine-client system_api
TEST=test_that -b $B $IP autoupdate_EOL
TEST=test_that -b $B $IP autoupdate_EOL.approaching_eol
TEST=test_that -b $B $IP autoupdate_EOL.future_eol
Cq-Depend:chromium:1783596, chromium:1811116
Change-Id: I2b1063873118ccf8fe22ba09a5961e27aa980c7b
Reviewed-on: https://chromium-review.googlesource.com/1783897
Tested-by: Jae Hoon Kim <kimjae@chromium.org>
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
diff --git a/omaha_request_action.cc b/omaha_request_action.cc
index 4d86586..7ca4372 100644
--- a/omaha_request_action.cc
+++ b/omaha_request_action.cc
@@ -109,6 +109,7 @@
// updatecheck attributes (without the underscore prefix).
constexpr char kAttrEol[] = "eol";
+constexpr char kAttrEolDate[] = "eol_date";
constexpr char kAttrRollback[] = "rollback";
constexpr char kAttrFirmwareVersion[] = "firmware_version";
constexpr char kAttrKernelVersion[] = "kernel_version";
@@ -1317,14 +1318,29 @@
}
bool OmahaRequestAction::PersistEolStatus(const map<string, string>& attrs) {
- auto eol_attr = attrs.find(kAttrEol);
- if (eol_attr != attrs.end()) {
- return system_state_->prefs()->SetString(kPrefsOmahaEolStatus,
- eol_attr->second);
- } else if (system_state_->prefs()->Exists(kPrefsOmahaEolStatus)) {
- return system_state_->prefs()->Delete(kPrefsOmahaEolStatus);
+ bool ret = true;
+
+ // Set EOL date.
+ 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;
}
- return true;
+
+ // 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 ret;
}
void OmahaRequestAction::ActionCompleted(ErrorCode code) {