Fix metricsd to conform to the lastest server schema
The new server push enabled component/trait validation rules. This
allows us to use the new schema that does not require vendor commands,
parameters and state to start with underscore ("_").
Also fixed a few minor errors in schema definition.
Change-Id: I184dd8e4c69c05e0dd1b0dddb1f9a7b0aef78841
diff --git a/metricsd/etc/weaved/traits/metrics.json b/metricsd/etc/weaved/traits/metrics.json
index 7d17c77..7583270 100644
--- a/metricsd/etc/weaved/traits/metrics.json
+++ b/metricsd/etc/weaved/traits/metrics.json
@@ -1,15 +1,17 @@
{
"_metrics": {
"commands": {
- "_enableAnalyticsReporting": {
- "minimalRole": "manager"
+ "enableAnalyticsReporting": {
+ "minimalRole": "manager",
+ "parameters": {}
},
- "_disableAnalyticsReporting": {
- "minimalRole": "manager"
+ "disableAnalyticsReporting": {
+ "minimalRole": "manager",
+ "parameters": {}
}
},
"state": {
- "_AnalyticsReportingState": {
+ "analyticsReportingState": {
"type": "string",
"enum": [ "enabled", "disabled" ]
}
diff --git a/metricsd/metrics_collector.cc b/metricsd/metrics_collector.cc
index b5c2289..e9edf2e 100644
--- a/metricsd/metrics_collector.cc
+++ b/metricsd/metrics_collector.cc
@@ -229,11 +229,11 @@
device_->AddComponent(kWeaveComponent, {"_metrics"});
device_->AddCommandHandler(
kWeaveComponent,
- "_metrics._enableAnalyticsReporting",
+ "_metrics.enableAnalyticsReporting",
base::Bind(&MetricsCollector::OnEnableMetrics, base::Unretained(this)));
device_->AddCommandHandler(
kWeaveComponent,
- "_metrics._disableAnalyticsReporting",
+ "_metrics.disableAnalyticsReporting",
base::Bind(&MetricsCollector::OnDisableMetrics, base::Unretained(this)));
latest_cpu_use_microseconds_ = cpu_usage_collector_->GetCumulativeCpuUse();
@@ -294,7 +294,7 @@
metrics_lib_->AreMetricsEnabled() ? "enabled" : "disabled";
if (!device_->SetStateProperty(kWeaveComponent,
- "_metrics._AnalyticsReportingState",
+ "_metrics.analyticsReportingState",
enabled,
nullptr)) {
LOG(ERROR) << "failed to update weave's state";