MetricsReporter gets DynamicPartitionControl.

Test: TH
Bug: 178732971
Change-Id: If434927b7abdecb8093db1462dae196cd744331a
diff --git a/aosp/metrics_reporter_android.cc b/aosp/metrics_reporter_android.cc
index 22ebf0d..18424d5 100644
--- a/aosp/metrics_reporter_android.cc
+++ b/aosp/metrics_reporter_android.cc
@@ -54,8 +54,9 @@
 
 namespace metrics {
 
-std::unique_ptr<MetricsReporterInterface> CreateMetricsReporter() {
-  return std::make_unique<MetricsReporterAndroid>();
+std::unique_ptr<MetricsReporterInterface> CreateMetricsReporter(
+    DynamicPartitionControlInterface* dynamic_partition_control) {
+  return std::make_unique<MetricsReporterAndroid>(dynamic_partition_control);
 }
 
 }  // namespace metrics
diff --git a/aosp/metrics_reporter_android.h b/aosp/metrics_reporter_android.h
index 729542e..abe7c27 100644
--- a/aosp/metrics_reporter_android.h
+++ b/aosp/metrics_reporter_android.h
@@ -27,7 +27,9 @@
 
 class MetricsReporterAndroid : public MetricsReporterInterface {
  public:
-  MetricsReporterAndroid() = default;
+  explicit MetricsReporterAndroid(
+      DynamicPartitionControlInterface* dynamic_partition_control)
+      : dynamic_partition_control_(dynamic_partition_control) {}
 
   ~MetricsReporterAndroid() override = default;
 
@@ -91,6 +93,8 @@
       bool has_time_restriction_policy, int time_to_update_days) override {}
 
  private:
+  DynamicPartitionControlInterface* dynamic_partition_control_;
+
   DISALLOW_COPY_AND_ASSIGN(MetricsReporterAndroid);
 };
 
diff --git a/aosp/update_attempter_android.cc b/aosp/update_attempter_android.cc
index 96bb67c..5c66141 100644
--- a/aosp/update_attempter_android.cc
+++ b/aosp/update_attempter_android.cc
@@ -140,7 +140,8 @@
       hardware_(hardware),
       processor_(new ActionProcessor()),
       clock_(new Clock()) {
-  metrics_reporter_ = metrics::CreateMetricsReporter();
+  metrics_reporter_ = metrics::CreateMetricsReporter(
+      boot_control_->GetDynamicPartitionControl());
   network_selector_ = network::CreateNetworkSelector();
 }
 
diff --git a/common/boot_control_interface.h b/common/boot_control_interface.h
index 3b61add..321174e 100644
--- a/common/boot_control_interface.h
+++ b/common/boot_control_interface.h
@@ -103,7 +103,7 @@
   // Check if |slot| is marked boot successfully.
   virtual bool IsSlotMarkedSuccessful(Slot slot) const = 0;
 
-  // Return the dynamic partition control interface.
+  // Return the dynamic partition control interface. Never null.
   virtual DynamicPartitionControlInterface* GetDynamicPartitionControl() = 0;
 
   // Return a human-readable slot name used for logging.
diff --git a/common/metrics_reporter_interface.h b/common/metrics_reporter_interface.h
index 08636e3..29d13fa 100644
--- a/common/metrics_reporter_interface.h
+++ b/common/metrics_reporter_interface.h
@@ -23,6 +23,7 @@
 #include <base/time/time.h>
 
 #include "update_engine/common/constants.h"
+#include "update_engine/common/dynamic_partition_control_interface.h"
 #include "update_engine/common/error_code.h"
 #include "update_engine/common/metrics_constants.h"
 
@@ -235,7 +236,8 @@
 
 namespace metrics {
 
-std::unique_ptr<MetricsReporterInterface> CreateMetricsReporter();
+std::unique_ptr<MetricsReporterInterface> CreateMetricsReporter(
+    DynamicPartitionControlInterface* dynamic_partition_control);
 
 }  // namespace metrics
 
diff --git a/common/metrics_reporter_stub.cc b/common/metrics_reporter_stub.cc
index dcb4e8c..96b519b 100644
--- a/common/metrics_reporter_stub.cc
+++ b/common/metrics_reporter_stub.cc
@@ -22,7 +22,8 @@
 
 namespace metrics {
 
-std::unique_ptr<MetricsReporterInterface> CreateMetricsReporter() {
+std::unique_ptr<MetricsReporterInterface> CreateMetricsReporter(
+    DynamicPartitionControlInterface* dynamic_partition_control) {
   return std::make_unique<MetricsReporterStub>();
 }
 
diff --git a/cros/metrics_reporter_omaha.cc b/cros/metrics_reporter_omaha.cc
index 22c0aa9..69cdb19 100644
--- a/cros/metrics_reporter_omaha.cc
+++ b/cros/metrics_reporter_omaha.cc
@@ -135,7 +135,8 @@
     "UpdateEngine.InstallDateProvisioningSource";
 const char kMetricTimeToRebootMinutes[] = "UpdateEngine.TimeToRebootMinutes";
 
-std::unique_ptr<MetricsReporterInterface> CreateMetricsReporter() {
+std::unique_ptr<MetricsReporterInterface> CreateMetricsReporter(
+    DynamicPartitionControlInterface* dynamic_partition_control) {
   return std::make_unique<MetricsReporterOmaha>();
 }