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
diff --git a/aosp/metrics_reporter_android.cc b/aosp/metrics_reporter_android.cc
index 1f8f45a..a324fab 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 @@
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 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 @@
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 abe7c27..aeb579a 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 @@
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 1080acb..ba61f25 100644
--- a/aosp/update_attempter_android.cc
+++ b/aosp/update_attempter_android.cc
@@ -64,7 +64,6 @@
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 @@
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 29d13fa..a7a91a5 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 @@
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 96b519b..61559d9 100644
--- a/common/metrics_reporter_stub.cc
+++ b/common/metrics_reporter_stub.cc
@@ -23,7 +23,8 @@
namespace metrics {
std::unique_ptr<MetricsReporterInterface> CreateMetricsReporter(
- DynamicPartitionControlInterface* dynamic_partition_control) {
+ DynamicPartitionControlInterface* dynamic_partition_control,
+ const InstallPlan* install_plan) {
return std::make_unique<MetricsReporterStub>();
}