update_engine: Pass is_enterprise_rollback in the StatusResult
Currently Chrome uses some sort of version comparison to define whether
an update is a rollback or not. But that is not very robust. The correct
way is the return this value in the StatusResult. We already have this
value as a placeholder in the update_engine.proto. So this is good to
go.
BUG=chromium:864672
TEST=FEATUERS=test emerge-reef update_engine
Change-Id: I8bd3af0d94abd656dc00a9e67550ea6c6913de91
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/1775116
Tested-by: Amin Hassani <ahassani@chromium.org>
Commit-Queue: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Jae Hoon Kim <kimjae@chromium.org>
diff --git a/client_library/client_dbus.cc b/client_library/client_dbus.cc
index d0f7f81..3c23de4 100644
--- a/client_library/client_dbus.cc
+++ b/client_library/client_dbus.cc
@@ -54,6 +54,7 @@
out_status->new_version = status.new_version();
out_status->new_size_bytes = status.new_size();
out_status->status = static_cast<UpdateStatus>(status.current_operation());
+ out_status->is_enterprise_rollback = status.is_enterprise_rollback();
out_status->is_install = status.is_install();
}
} // namespace
diff --git a/client_library/include/update_engine/update_status.h b/client_library/include/update_engine/update_status.h
index bc14e67..c877df6 100644
--- a/client_library/include/update_engine/update_status.h
+++ b/client_library/include/update_engine/update_status.h
@@ -83,6 +83,9 @@
uint64_t new_size_bytes;
// New product version.
std::string new_version;
+ // Wether the update is an enterprise rollback. The value is valid only if the
+ // current operation is passed CHECKING_FOR_UPDATE.
+ bool is_enterprise_rollback;
// Indication of install for DLC(s).
bool is_install;
};
diff --git a/dbus_service.cc b/dbus_service.cc
index 168265d..c4de3e7 100644
--- a/dbus_service.cc
+++ b/dbus_service.cc
@@ -47,6 +47,7 @@
out_status->set_current_operation(static_cast<Operation>(ue_status.status));
out_status->set_new_version(ue_status.new_version);
out_status->set_new_size(ue_status.new_size_bytes);
+ out_status->set_is_enterprise_rollback(ue_status.is_enterprise_rollback);
out_status->set_is_install(ue_status.is_install);
}
} // namespace
diff --git a/update_attempter.cc b/update_attempter.cc
index 71463b5..780ba7b 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -1382,6 +1382,8 @@
out_status->progress = download_progress_;
out_status->new_size_bytes = new_payload_size_;
out_status->new_version = new_version_;
+ out_status->is_enterprise_rollback =
+ install_plan_ && install_plan_->is_rollback;
out_status->is_install = is_install_;
return true;
}
diff --git a/update_attempter.h b/update_attempter.h
index 3db4097..51b672d 100644
--- a/update_attempter.h
+++ b/update_attempter.h
@@ -257,6 +257,9 @@
FRIEND_TEST(UpdateAttempterTest, DisableDeltaUpdateIfNeededTest);
FRIEND_TEST(UpdateAttempterTest, DownloadProgressAccumulationTest);
FRIEND_TEST(UpdateAttempterTest, InstallSetsStatusIdle);
+ FRIEND_TEST(UpdateAttempterTest, IsEnterpriseRollbackInGetStatusDefault);
+ FRIEND_TEST(UpdateAttempterTest, IsEnterpriseRollbackInGetStatusTrue);
+ FRIEND_TEST(UpdateAttempterTest, IsEnterpriseRollbackInGetStatusFalse);
FRIEND_TEST(UpdateAttempterTest, MarkDeltaUpdateFailureTest);
FRIEND_TEST(UpdateAttempterTest, PingOmahaTest);
FRIEND_TEST(UpdateAttempterTest, ProcessingDoneInstallError);
diff --git a/update_attempter_unittest.cc b/update_attempter_unittest.cc
index 4b9bc75..0e74353 100644
--- a/update_attempter_unittest.cc
+++ b/update_attempter_unittest.cc
@@ -2220,4 +2220,28 @@
TestOnUpdateScheduled();
}
+TEST_F(UpdateAttempterTest, IsEnterpriseRollbackInGetStatusDefault) {
+ UpdateEngineStatus status;
+ attempter_.GetStatus(&status);
+ EXPECT_FALSE(status.is_enterprise_rollback);
+}
+
+TEST_F(UpdateAttempterTest, IsEnterpriseRollbackInGetStatusFalse) {
+ attempter_.install_plan_.reset(new InstallPlan);
+ attempter_.install_plan_->is_rollback = false;
+
+ UpdateEngineStatus status;
+ attempter_.GetStatus(&status);
+ EXPECT_FALSE(status.is_enterprise_rollback);
+}
+
+TEST_F(UpdateAttempterTest, IsEnterpriseRollbackInGetStatusTrue) {
+ attempter_.install_plan_.reset(new InstallPlan);
+ attempter_.install_plan_->is_rollback = true;
+
+ UpdateEngineStatus status;
+ attempter_.GetStatus(&status);
+ EXPECT_TRUE(status.is_enterprise_rollback);
+}
+
} // namespace chromeos_update_engine
diff --git a/update_status_utils.cc b/update_status_utils.cc
index 0758314..639dc8b 100644
--- a/update_status_utils.cc
+++ b/update_status_utils.cc
@@ -33,6 +33,7 @@
// exactly these matches.
const char kCurrentOp[] = "CURRENT_OP";
const char kIsInstall[] = "IS_INSTALL";
+const char kIsEnterpriseRollback[] = "IS_ENTERPRISE_ROLLBACK";
const char kLastCheckedTime[] = "LAST_CHECKED_TIME";
const char kNewSize[] = "NEW_SIZE";
const char kNewVersion[] = "NEW_VERSION";
@@ -88,6 +89,8 @@
#endif
key_value_store.SetString(kCurrentOp, UpdateStatusToString(status.status));
key_value_store.SetString(kNewVersion, status.new_version);
+ key_value_store.SetBoolean(kIsEnterpriseRollback,
+ status.is_enterprise_rollback);
key_value_store.SetBoolean(kIsInstall, status.is_install);
return key_value_store.SaveToString();
diff --git a/update_status_utils_unittest.cc b/update_status_utils_unittest.cc
index dbd80d7..3af30c7 100644
--- a/update_status_utils_unittest.cc
+++ b/update_status_utils_unittest.cc
@@ -24,22 +24,11 @@
namespace chromeos_update_engine {
-TEST(UpdateStatusUtilsTest, UpdateEngineStatusToStringDefaultTest) {
- string print =
- R"(CURRENT_OP=UPDATE_STATUS_IDLE
-IS_INSTALL=false
-LAST_CHECKED_TIME=0
-NEW_SIZE=0
-NEW_VERSION=
-PROGRESS=0.0
-)";
- EXPECT_EQ(print, UpdateEngineStatusToString({}));
-}
-
TEST(UpdateStatusUtilsTest, UpdateEngineStatusToStringTest) {
update_engine::UpdateEngineStatus update_engine_status = {
.status = update_engine::UpdateStatus::CHECKING_FOR_UPDATE,
.is_install = true,
+ .is_enterprise_rollback = true,
.last_checked_time = 156000000,
.new_size_bytes = 888,
.new_version = "12345.0.0",
@@ -47,6 +36,7 @@
};
string print =
R"(CURRENT_OP=UPDATE_STATUS_CHECKING_FOR_UPDATE
+IS_ENTERPRISE_ROLLBACK=true
IS_INSTALL=true
LAST_CHECKED_TIME=156000000
NEW_SIZE=888