Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c480b8e6 authored by Alex Vakulenko's avatar Alex Vakulenko Committed by Gerrit Code Review
Browse files

Merge "metricsd: Split out the trait name from the command name"

parents b50bc6b3 ba95a94e
Loading
Loading
Loading
Loading
+6 −8
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ const char kMeminfoFileName[] = "/proc/meminfo";
const char kVmStatFileName[] = "/proc/vmstat";

const char kWeaveComponent[] = "metrics";
const char kWeaveTrait[] = "_metrics";

}  // namespace

@@ -259,15 +260,13 @@ void MetricsCollector::OnWeaveServiceConnected(
  if (!weave_service)
    return;

  weave_service->AddComponent(kWeaveComponent, {"_metrics"}, nullptr);
  weave_service->AddComponent(kWeaveComponent, {kWeaveTrait}, nullptr);
  weave_service->AddCommandHandler(
      kWeaveComponent,
      "_metrics.enableAnalyticsReporting",
      kWeaveComponent, kWeaveTrait, "enableAnalyticsReporting",
      base::Bind(&MetricsCollector::OnEnableMetrics,
                 weak_ptr_factory_.GetWeakPtr()));
  weave_service->AddCommandHandler(
      kWeaveComponent,
      "_metrics.disableAnalyticsReporting",
      kWeaveComponent, kWeaveTrait, "disableAnalyticsReporting",
      base::Bind(&MetricsCollector::OnDisableMetrics,
                 weak_ptr_factory_.GetWeakPtr()));

@@ -311,9 +310,8 @@ void MetricsCollector::UpdateWeaveState() {
  std::string enabled =
      metrics_lib_->AreMetricsEnabled() ? "enabled" : "disabled";

  if (!weave_service->SetStateProperty(kWeaveComponent,
                                       "_metrics.analyticsReportingState",
                                       enabled,
  if (!weave_service->SetStateProperty(kWeaveComponent, kWeaveTrait,
                                       "analyticsReportingState", enabled,
                                       nullptr)) {
    LOG(ERROR) << "failed to update weave's state";
  }