Parse and expose end-of-life flag.
Omaha update or noupdate response can include _key=value pairs with
arbitrary data. One of those key can be "_eol" with the one of the
values "supported", "security-only" or "eol" which notifies the device
the end-of-life status of the device with respect to updates. This
information is now exposed via GetEolStatus() to the client so it
can be properly displayed in the UI.
Bug: 27924505
TEST=Added unittest. Run `update_engine_client --eol_status` on link.
Change-Id: Icc15f25b4d0b19cc894f5afc52ac7c43c7818982
diff --git a/common_service_unittest.cc b/common_service_unittest.cc
index 1c144d1..0a7bfc3 100644
--- a/common_service_unittest.cc
+++ b/common_service_unittest.cc
@@ -23,7 +23,9 @@
#include <policy/libpolicy.h>
#include <policy/mock_device_policy.h>
+#include "update_engine/common/fake_prefs.h"
#include "update_engine/fake_system_state.h"
+#include "update_engine/omaha_utils.h"
using std::string;
using testing::Return;
@@ -131,4 +133,19 @@
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