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/BUILD.gn b/BUILD.gn
index 1f5dc7f..5ac0a3f 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -146,7 +146,6 @@
     "common/terminator.cc",
     "common/utils.cc",
     "cros/platform_constants_chromeos.cc",
-    "download_action.cc",
     "payload_consumer/bzip_extent_writer.cc",
     "payload_consumer/cached_file_descriptor.cc",
     "payload_consumer/certificate_parser_stub.cc",
@@ -194,6 +193,7 @@
   sources = [
     "certificate_checker.cc",
     "common/connection_utils.cc",
+    "common/system_state.cc",
     "cros/boot_control_chromeos.cc",
     "cros/common_service.cc",
     "cros/connection_manager.cc",
@@ -216,6 +216,7 @@
     "cros/requisition_util.cc",
     "cros/shill_proxy.cc",
     "cros/update_attempter.cc",
+    "download_action.cc",
     "libcurl_http_fetcher.cc",
     "metrics_utils.cc",
     "update_boot_flags_action.cc",
@@ -331,6 +332,9 @@
 static_library("libpayload_generator") {
   sources = [
     "common/file_fetcher.cc",
+    "common/system_state.cc",
+    "cros/real_system_state.cc",
+    "download_action.cc",
     "payload_generator/ab_generator.cc",
     "payload_generator/annotated_operation.cc",
     "payload_generator/blob_file_writer.cc",