update_engine: Make SystemState accessible from everywhere
SystemState is supposed to be a global context and is used lamost
everywhere. So instead of passing it to functions and keeping multiple
pointers to it, its better to do what we did in dlcservice and make it a
singleton class with a getter that can be get from everywhere.
BUG=b:171829801
TEST=unittests
Change-Id: I3b2de9394b7769b3911195ca52d61dbe49afd4dd
Reviewed-on: https://chromium-review.googlesource.com/c/aosp/platform/system/update_engine/+/2521792
Commit-Queue: Amin Hassani <ahassani@chromium.org>
Tested-by: Amin Hassani <ahassani@chromium.org>
Reviewed-by: Jae Hoon Kim <kimjae@chromium.org>
diff --git a/cros/omaha_request_params.cc b/cros/omaha_request_params.cc
index e7e719b..0d69b24 100644
--- a/cros/omaha_request_params.cc
+++ b/cros/omaha_request_params.cc
@@ -65,8 +65,8 @@
const string& update_url,
const UpdateCheckParams& params) {
LOG(INFO) << "Initializing parameters for this update attempt";
- image_props_ = LoadImageProperties(system_state_);
- mutable_image_props_ = LoadMutableImageProperties(system_state_);
+ image_props_ = LoadImageProperties();
+ mutable_image_props_ = LoadMutableImageProperties();
// Validation check the channel names.
if (!IsValidChannel(image_props_.current_channel))
@@ -84,8 +84,8 @@
os_sp_ = image_props_.version + "_" + GetMachineType();
app_lang_ = "en-US";
- hwid_ = system_state_->hardware()->GetHardwareClass();
- device_requisition_ = system_state_->hardware()->GetDeviceRequisition();
+ hwid_ = SystemState::Get()->hardware()->GetHardwareClass();
+ device_requisition_ = SystemState::Get()->hardware()->GetDeviceRequisition();
if (image_props_.current_channel == mutable_image_props_.target_channel) {
// deltas are only okay if the /.nodelta file does not exist. if we don't
@@ -177,7 +177,7 @@
new_props.target_channel = new_target_channel;
new_props.is_powerwash_allowed = is_powerwash_allowed;
- if (!StoreMutableImageProperties(system_state_, new_props)) {
+ if (!StoreMutableImageProperties(new_props)) {
if (error_message)
*error_message = "Error storing the new channel value.";
return false;