update_engine: Support milestones to EOL from Omaha
Initiative to show EOL message on Chrome OS devices require that
update_engine parses the fields within Omaha response that pertain to the
new milestones to EOL field. The Omaha response will include a new
field called "milestones_to_eol" which will be an integer value
string.
The job of update_engine when it comes to milestones to EOL from Omaha
is to merely forward. No checks and no modifications of fields are
done within update_engine besides being able to convert the milestones
to EOL from a string to integer.
BUG=chromium:994999
TEST=FEATURES="test" emerge-$BOARD update_engine update_engine-client
TEST=cros deploy $IP update_engine update_engine-client
TEST=test_that -b $BOARD $IP autoupdate_EOL # from Cq-Depend
TEST=test_that -b $BOARD $IP autoupdate_EOL.milestones # from Cq-Depend
Cq-Depend:chromium:1761371
Change-Id: I268e4c8e641b17d6a727a50f53285cc97c76eb22
Reviewed-on: https://chromium-review.googlesource.com/1759285
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: Nicolas Norvez <norvez@chromium.org>
Reviewed-by: Amin Hassani <ahassani@chromium.org>
diff --git a/omaha_utils.cc b/omaha_utils.cc
index 6bd7525..dffa5d3 100644
--- a/omaha_utils.cc
+++ b/omaha_utils.cc
@@ -17,17 +17,15 @@
#include "update_engine/omaha_utils.h"
#include <base/logging.h>
+#include <base/strings/string_number_conversions.h>
namespace chromeos_update_engine {
-namespace {
-
-// The possible string values for the end-of-life status.
const char kEolStatusSupported[] = "supported";
const char kEolStatusSecurityOnly[] = "security-only";
const char kEolStatusEol[] = "eol";
-} // namespace
+const MilestonesToEol kMilestonesToEolNone = -1;
const char* EolStatusToString(EolStatus eol_status) {
switch (eol_status) {
@@ -50,8 +48,23 @@
return EolStatus::kSecurityOnly;
if (eol_status == kEolStatusEol)
return EolStatus::kEol;
- LOG(WARNING) << "Invalid end-of-life attribute: " << eol_status;
+ LOG(WARNING) << "Invalid EOL attribute: " << eol_status;
return EolStatus::kSupported;
}
+std::string MilestonesToEolToString(MilestonesToEol milestones_to_eol) {
+ return base::IntToString(milestones_to_eol);
+}
+
+MilestonesToEol StringToMilestonesToEol(const std::string& milestones_to_eol) {
+ MilestonesToEol milestone = kMilestonesToEolNone;
+ if (!base::StringToInt(milestones_to_eol, &milestone)) {
+ LOG(WARNING) << "Invalid milestones to EOL attribute: "
+ << milestones_to_eol;
+ return kMilestonesToEolNone;
+ }
+
+ return milestone;
+}
+
} // namespace chromeos_update_engine