diff options
author | Kelvin Zhang <zhangkelvin@google.com> | 2021-03-31 20:31:26 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2021-03-31 20:31:26 +0000 |
commit | c154fdaedb1d508a3bc18550e05e964ef9c15bd3 (patch) | |
tree | 88c787a63afa8e7b25026ef412a900e70525b5eb | |
parent | f4471d61e11a8829b0cd44a512d17b16c22d1ac9 (diff) | |
parent | 0cf3b32669953633a38acf184d0ff74018af22be (diff) | |
download | update_engine-c154fdaedb1d508a3bc18550e05e964ef9c15bd3.tar.gz |
Report metrics on whether verity is used am: 9a5e3683a4 am: 0cf3b32669
Original change: https://android-review.googlesource.com/c/platform/system/update_engine/+/1656387
Change-Id: Ie9f7b4acbad32cfab8787e99fc9ef073adda82f6
-rw-r--r-- | aosp/metrics_reporter_android.cc | 29 | ||||
-rw-r--r-- | aosp/metrics_reporter_android.h | 10 | ||||
-rw-r--r-- | aosp/update_attempter_android.cc | 3 | ||||
-rw-r--r-- | common/metrics_reporter_interface.h | 4 | ||||
-rw-r--r-- | common/metrics_reporter_stub.cc | 3 |
5 files changed, 39 insertions, 10 deletions
diff --git a/aosp/metrics_reporter_android.cc b/aosp/metrics_reporter_android.cc index 1f8f45a6..a324fab1 100644 --- a/aosp/metrics_reporter_android.cc +++ b/aosp/metrics_reporter_android.cc @@ -18,6 +18,8 @@ #include <stdint.h> +#include <algorithm> +#include <any> #include <memory> #include <string> @@ -30,6 +32,7 @@ #include <statslog.h> #include "update_engine/common/constants.h" +#include "update_engine/payload_consumer/install_plan.h" using android::fs_mgr::GetPartitionGroupName; using android::fs_mgr::LpMetadata; @@ -48,6 +51,22 @@ constexpr auto kMetricsReporterEnumOffset = 10000; int32_t GetStatsdEnumValue(int32_t value) { return kMetricsReporterEnumOffset + value; } + +bool IsHashTreeEnabled( + const chromeos_update_engine::InstallPlan* install_plan) { + return std::any_of( + install_plan->partitions.begin(), + install_plan->partitions.end(), + [](const auto& partition) { return partition.hash_tree_size > 0; }); +} + +bool IsFECEnabled(const chromeos_update_engine::InstallPlan* install_plan) { + return std::any_of( + install_plan->partitions.begin(), + install_plan->partitions.end(), + [](const auto& partition) { return partition.fec_size > 0; }); +} + } // namespace namespace chromeos_update_engine { @@ -55,8 +74,10 @@ namespace chromeos_update_engine { namespace metrics { std::unique_ptr<MetricsReporterInterface> CreateMetricsReporter( - DynamicPartitionControlInterface* dynamic_partition_control) { - return std::make_unique<MetricsReporterAndroid>(dynamic_partition_control); + DynamicPartitionControlInterface* dynamic_partition_control, + const InstallPlan* install_plan) { + return std::make_unique<MetricsReporterAndroid>(dynamic_partition_control, + install_plan); } } // namespace metrics @@ -164,7 +185,9 @@ void MetricsReporterAndroid::ReportSuccessfulUpdateMetrics( static_cast<int32_t>(total_bytes_downloaded), static_cast<int32_t>(download_overhead_percentage), static_cast<int32_t>(total_duration.InMinutes()), - static_cast<int32_t>(reboot_count)); + static_cast<int32_t>(reboot_count), + IsHashTreeEnabled(install_plan_), + IsFECEnabled(install_plan_)); } void MetricsReporterAndroid::ReportAbnormallyTerminatedUpdateAttemptMetrics() { diff --git a/aosp/metrics_reporter_android.h b/aosp/metrics_reporter_android.h index abe7c277..aeb579a1 100644 --- a/aosp/metrics_reporter_android.h +++ b/aosp/metrics_reporter_android.h @@ -22,14 +22,17 @@ #include "update_engine/common/error_code.h" #include "update_engine/common/metrics_constants.h" #include "update_engine/common/metrics_reporter_interface.h" +#include "update_engine/payload_consumer/install_plan.h" namespace chromeos_update_engine { class MetricsReporterAndroid : public MetricsReporterInterface { public: explicit MetricsReporterAndroid( - DynamicPartitionControlInterface* dynamic_partition_control) - : dynamic_partition_control_(dynamic_partition_control) {} + DynamicPartitionControlInterface* dynamic_partition_control, + const InstallPlan* install_plan) + : dynamic_partition_control_(dynamic_partition_control), + install_plan_(install_plan) {} ~MetricsReporterAndroid() override = default; @@ -93,7 +96,8 @@ class MetricsReporterAndroid : public MetricsReporterInterface { bool has_time_restriction_policy, int time_to_update_days) override {} private: - DynamicPartitionControlInterface* dynamic_partition_control_; + DynamicPartitionControlInterface* dynamic_partition_control_{}; + const InstallPlan* install_plan_{}; DISALLOW_COPY_AND_ASSIGN(MetricsReporterAndroid); }; diff --git a/aosp/update_attempter_android.cc b/aosp/update_attempter_android.cc index 1080acba..ba61f255 100644 --- a/aosp/update_attempter_android.cc +++ b/aosp/update_attempter_android.cc @@ -64,7 +64,6 @@ using base::Bind; using base::Time; using base::TimeDelta; using base::TimeTicks; -using std::shared_ptr; using std::string; using std::vector; using update_engine::UpdateEngineStatus; @@ -143,7 +142,7 @@ UpdateAttempterAndroid::UpdateAttempterAndroid( processor_(new ActionProcessor()), clock_(new Clock()) { metrics_reporter_ = metrics::CreateMetricsReporter( - boot_control_->GetDynamicPartitionControl()); + boot_control_->GetDynamicPartitionControl(), &install_plan_); network_selector_ = network::CreateNetworkSelector(); } diff --git a/common/metrics_reporter_interface.h b/common/metrics_reporter_interface.h index 29d13faf..a7a91a54 100644 --- a/common/metrics_reporter_interface.h +++ b/common/metrics_reporter_interface.h @@ -26,6 +26,7 @@ #include "update_engine/common/dynamic_partition_control_interface.h" #include "update_engine/common/error_code.h" #include "update_engine/common/metrics_constants.h" +#include "update_engine/payload_consumer/install_plan.h" namespace chromeos_update_engine { @@ -237,7 +238,8 @@ class MetricsReporterInterface { namespace metrics { std::unique_ptr<MetricsReporterInterface> CreateMetricsReporter( - DynamicPartitionControlInterface* dynamic_partition_control); + DynamicPartitionControlInterface* dynamic_partition_control, + const InstallPlan* install_plan); } // namespace metrics diff --git a/common/metrics_reporter_stub.cc b/common/metrics_reporter_stub.cc index 96b519bf..61559d95 100644 --- a/common/metrics_reporter_stub.cc +++ b/common/metrics_reporter_stub.cc @@ -23,7 +23,8 @@ namespace chromeos_update_engine { namespace metrics { std::unique_ptr<MetricsReporterInterface> CreateMetricsReporter( - DynamicPartitionControlInterface* dynamic_partition_control) { + DynamicPartitionControlInterface* dynamic_partition_control, + const InstallPlan* install_plan) { return std::make_unique<MetricsReporterStub>(); } |