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/update_manager/real_system_provider.cc b/update_manager/real_system_provider.cc
index 8d30f7f..34397f3 100644
--- a/update_manager/real_system_provider.cc
+++ b/update_manager/real_system_provider.cc
@@ -24,11 +24,13 @@
#include "update_engine/common/boot_control_interface.h"
#include "update_engine/common/hardware_interface.h"
+#include "update_engine/common/system_state.h"
#include "update_engine/common/utils.h"
#include "update_engine/cros/omaha_request_params.h"
#include "update_engine/update_manager/generic_variables.h"
#include "update_engine/update_manager/variable.h"
+using chromeos_update_engine::SystemState;
using std::string;
namespace chromeos_update_manager {
@@ -98,19 +100,20 @@
bool RealSystemProvider::Init() {
var_is_normal_boot_mode_.reset(new ConstCopyVariable<bool>(
- "is_normal_boot_mode", system_state_->hardware()->IsNormalBootMode()));
+ "is_normal_boot_mode",
+ SystemState::Get()->hardware()->IsNormalBootMode()));
var_is_official_build_.reset(new ConstCopyVariable<bool>(
- "is_official_build", system_state_->hardware()->IsOfficialBuild()));
+ "is_official_build", SystemState::Get()->hardware()->IsOfficialBuild()));
var_is_oobe_complete_.reset(new CallCopyVariable<bool>(
"is_oobe_complete",
base::Bind(&chromeos_update_engine::HardwareInterface::IsOOBEComplete,
- base::Unretained(system_state_->hardware()),
+ base::Unretained(SystemState::Get()->hardware()),
nullptr)));
var_num_slots_.reset(new ConstCopyVariable<unsigned int>(
- "num_slots", system_state_->boot_control()->GetNumSlots()));
+ "num_slots", SystemState::Get()->boot_control()->GetNumSlots()));
var_kiosk_required_platform_version_.reset(new RetryPollVariable<string>(
"kiosk_required_platform_version",
@@ -120,7 +123,7 @@
var_chromeos_version_.reset(new ConstCopyVariable<base::Version>(
"chromeos_version",
- base::Version(system_state_->request_params()->app_version())));
+ base::Version(SystemState::Get()->request_params()->app_version())));
return true;
}