Skip to content

Commit 2f78c1c

Browse files
Jae Hoon KimCommit Bot
Jae Hoon Kim
authored and
Commit Bot
committed
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
1 parent 493fecb commit 2f78c1c

7 files changed

+47
-22
lines changed

client_library/client_dbus.cc

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ void ConvertToUpdateEngineStatus(const StatusResult& status,
5454
out_status->new_version = status.new_version();
5555
out_status->new_size_bytes = status.new_size();
5656
out_status->status = static_cast<UpdateStatus>(status.current_operation());
57+
out_status->is_install = status.is_install();
5758
}
5859
} // namespace
5960

client_library/include/update_engine/update_status.h

+9-8
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ enum class UpdateStatus {
5252
// This value is exclusively used in Chrome. DO NOT define nor use it.
5353
// TODO(crbug.com/977320): Remove this value from chrome by refactoring the
5454
// Chrome code and evantually from here. This is not really an operation or
55-
// state that the update engine stays on. This is the result of an internal
55+
// state that the update_engine stays on. This is the result of an internal
5656
// failure and should be reflected differently.
5757
// ERROR = -1,
5858
};
@@ -71,19 +71,20 @@ enum UpdateAttemptFlags : int32_t {
7171
DECLARE_FLAGS_ENUM(UpdateAttemptFlags);
7272

7373
struct UpdateEngineStatus {
74-
// When the update_engine last checked for updates (time_t: seconds from unix
75-
// epoch)
74+
// Update engine last checked update (time_t: seconds from unix epoch).
7675
int64_t last_checked_time;
77-
// the current status/operation of the update_engine
76+
// Current status/operation of the update_engine.
7877
UpdateStatus status;
79-
// the current product version (oem bundle id)
78+
// Current product version (oem bundle id).
8079
std::string current_version;
81-
// The current progress (0.0f-1.0f).
80+
// Current progress (0.0f-1.0f).
8281
double progress;
83-
// the size of the update (bytes)
82+
// Size of the update in bytes.
8483
uint64_t new_size_bytes;
85-
// the new product version
84+
// New product version.
8685
std::string new_version;
86+
// Indication of install for DLC(s).
87+
bool is_install;
8788
};
8889

8990
} // namespace update_engine

dbus_service.cc

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ void ConvertToStatusResult(const UpdateEngineStatus& ue_status,
4747
out_status->set_current_operation(static_cast<Operation>(ue_status.status));
4848
out_status->set_new_version(ue_status.new_version);
4949
out_status->set_new_size(ue_status.new_size_bytes);
50+
out_status->set_is_install(ue_status.is_install);
5051
}
5152
} // namespace
5253

update_attempter.cc

+1
Original file line numberDiff line numberDiff line change
@@ -1382,6 +1382,7 @@ bool UpdateAttempter::GetStatus(UpdateEngineStatus* out_status) {
13821382
out_status->progress = download_progress_;
13831383
out_status->new_size_bytes = new_payload_size_;
13841384
out_status->new_version = new_version_;
1385+
out_status->is_install = is_install_;
13851386
return true;
13861387
}
13871388

update_engine_client.cc

+3-14
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
using chromeos_update_engine::EolStatus;
4343
using chromeos_update_engine::ErrorCode;
44+
using chromeos_update_engine::UpdateEngineStatusToString;
4445
using chromeos_update_engine::UpdateStatusToString;
4546
using chromeos_update_engine::utils::ErrorCodeToString;
4647
using std::string;
@@ -138,12 +139,7 @@ class WatchingStatusUpdateHandler : public ExitingStatusUpdateHandler {
138139

139140
void WatchingStatusUpdateHandler::HandleStatusUpdate(
140141
const UpdateEngineStatus& status) {
141-
LOG(INFO) << "Got status update:";
142-
LOG(INFO) << " last_checked_time: " << status.last_checked_time;
143-
LOG(INFO) << " progress: " << status.progress;
144-
LOG(INFO) << " current_operation: " << UpdateStatusToString(status.status);
145-
LOG(INFO) << " new_version: " << status.new_version;
146-
LOG(INFO) << " new_size: " << status.new_size_bytes;
142+
LOG(INFO) << "Got status update: " << UpdateEngineStatusToString(status);
147143
}
148144

149145
bool UpdateEngineClient::ShowStatus() {
@@ -161,14 +157,7 @@ bool UpdateEngineClient::ShowStatus() {
161157
base::TimeDelta::FromSeconds(kShowStatusRetryIntervalInSeconds));
162158
}
163159

164-
printf("LAST_CHECKED_TIME=%" PRIi64
165-
"\nPROGRESS=%f\nCURRENT_OP=%s\n"
166-
"NEW_VERSION=%s\nNEW_SIZE=%" PRIi64 "\n",
167-
status.last_checked_time,
168-
status.progress,
169-
UpdateStatusToString(status.status),
170-
status.new_version.c_str(),
171-
status.new_size_bytes);
160+
printf("%s", UpdateEngineStatusToString(status).c_str());
172161

173162
return true;
174163
}

update_status_utils.cc

+29
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@
1616
#include "update_engine/update_status_utils.h"
1717

1818
#include <base/logging.h>
19+
#include <base/strings/string_number_conversions.h>
20+
#include <brillo/key_value_store.h>
1921
#include <update_engine/dbus-constants.h>
2022

23+
using brillo::KeyValueStore;
24+
using std::string;
25+
using update_engine::UpdateEngineStatus;
2126
using update_engine::UpdateStatus;
2227

2328
namespace chromeos_update_engine {
@@ -52,4 +57,28 @@ const char* UpdateStatusToString(const UpdateStatus& status) {
5257
return nullptr;
5358
}
5459

60+
string UpdateEngineStatusToString(const UpdateEngineStatus& status) {
61+
KeyValueStore key_value_store;
62+
63+
#if BASE_VER < 576279
64+
key_value_store.SetString("LAST_CHECKED_TIME",
65+
base::Int64ToString(status.last_checked_time));
66+
key_value_store.SetString("PROGRESS", base::DoubleToString(status.progress));
67+
key_value_store.SetString("NEW_SIZE",
68+
base::Uint64ToString(status.new_size_bytes));
69+
#else
70+
key_value_store.SetString("LAST_CHECKED_TIME",
71+
base::NumberToString(status.last_checked_time));
72+
key_value_store.SetString("PROGRESS", base::NumberToString(status.progress));
73+
key_value_store.SetString("NEW_SIZE",
74+
base::NumberToString(status.new_size_bytes));
75+
#endif
76+
key_value_store.SetString("CURRENT_OPERATION",
77+
UpdateStatusToString(status.status));
78+
key_value_store.SetString("NEW_VERSION", status.new_version);
79+
key_value_store.SetBoolean("IS_INSTALL", status.is_install);
80+
81+
return key_value_store.SaveToString();
82+
}
83+
5584
} // namespace chromeos_update_engine

update_status_utils.h

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ namespace chromeos_update_engine {
2525

2626
const char* UpdateStatusToString(const update_engine::UpdateStatus& status);
2727

28+
std::string UpdateEngineStatusToString(
29+
const update_engine::UpdateEngineStatus& status);
30+
2831
} // namespace chromeos_update_engine
2932

3033
#endif // UPDATE_ENGINE_UPDATE_STATUS_UTILS_H_

0 commit comments

Comments
 (0)