update_engine: Leverage install indication in StatusResult protobuf
Update engine will provide this install indication for signal listeners
(specifically dlcservice) and status requesters to indicate whether
update engine is in the process of installing or updating. With this,
dlcservice will can be altered to not probe update engine for status
during a DLC uninstall.
The update engine client is also updated when getting the status from
update engine by using KeyValueStore printouts now.
Old output:
[0725/202915.815630:INFO:update_engine_client.cc(501)] Querying Update
Engine status...
LAST_CHECKED_TIME=1564102396
PROGRESS=1.000000
CURRENT_OP=UPDATE_STATUS_IDLE
NEW_VERSION=12354.0.2019_07_19_1136
NEW_SIZE=792
New output:
[0726/173804.558077:INFO:update_engine_client.cc(490)] Querying Update
Engine status...
CURRENT_OPERATION=UPDATE_STATUS_IDLE
IS_INSTALL=false
LAST_CHECKED_TIME=1564187860
NEW_SIZE=792
NEW_VERSION=12369.0.2019_07_26_0904
PROGRESS=1.0
BUG=chromium:871340
TEST=FEATURES="test" emerge-$BOARD update_engine update_engine-client system_api
TEST=/usr/bin/update_engine_client --status
Cq-Depend: chromium:1717661
Change-Id: Iaacea27e0fc0711200ec81fdebb7fef45f94af43
diff --git a/update_status_utils.cc b/update_status_utils.cc
index f3917d1..b56d94a 100644
--- a/update_status_utils.cc
+++ b/update_status_utils.cc
@@ -16,8 +16,13 @@
#include "update_engine/update_status_utils.h"
#include <base/logging.h>
+#include <base/strings/string_number_conversions.h>
+#include <brillo/key_value_store.h>
#include <update_engine/dbus-constants.h>
+using brillo::KeyValueStore;
+using std::string;
+using update_engine::UpdateEngineStatus;
using update_engine::UpdateStatus;
namespace chromeos_update_engine {
@@ -52,4 +57,28 @@
return nullptr;
}
+string UpdateEngineStatusToString(const UpdateEngineStatus& status) {
+ KeyValueStore key_value_store;
+
+#if BASE_VER < 576279
+ key_value_store.SetString("LAST_CHECKED_TIME",
+ base::Int64ToString(status.last_checked_time));
+ key_value_store.SetString("PROGRESS", base::DoubleToString(status.progress));
+ key_value_store.SetString("NEW_SIZE",
+ base::Uint64ToString(status.new_size_bytes));
+#else
+ key_value_store.SetString("LAST_CHECKED_TIME",
+ base::NumberToString(status.last_checked_time));
+ key_value_store.SetString("PROGRESS", base::NumberToString(status.progress));
+ key_value_store.SetString("NEW_SIZE",
+ base::NumberToString(status.new_size_bytes));
+#endif
+ key_value_store.SetString("CURRENT_OPERATION",
+ UpdateStatusToString(status.status));
+ key_value_store.SetString("NEW_VERSION", status.new_version);
+ key_value_store.SetBoolean("IS_INSTALL", status.is_install);
+
+ return key_value_store.SaveToString();
+}
+
} // namespace chromeos_update_engine