From cbf2c6402411d1fac7dd04c728d7bcc6b6a986d3 Mon Sep 17 00:00:00 2001 From: Tej Singh Date: Fri, 7 Jun 2019 17:23:30 -0700 Subject: [PATCH] Persist metric activation across beta4/5 ota In beta 4, activeEventActivation proto object does not have a state field and assumed to be active if it is written to disk. In beta 5, we add a state field to support persisting metric activation status across a system server crash. However, if a device updated from beta 4 to 5, we don't have any knowledge of the state when we read. Therefore, assume the lack of the state field as the event activation should be active for the provided ttl. Bug: 134795027 Test: used flashstation to flash a device to beta 4. Then manually push and activate a simple config. Then use vendor/google/tools/flashall to update to qt-dev + this change. Manually ensure metric/config are still active. Test: gts-tradefed run gts-dev --module GtsStatsdHostTestCases Test: bit statsd_test:* Change-Id: I8594d04efaa2ae1f669113aaffd33e5fa5851e73 --- cmds/statsd/src/metrics/MetricProducer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmds/statsd/src/metrics/MetricProducer.cpp b/cmds/statsd/src/metrics/MetricProducer.cpp index 8cbc9c45ca279..e892328c2e136 100644 --- a/cmds/statsd/src/metrics/MetricProducer.cpp +++ b/cmds/statsd/src/metrics/MetricProducer.cpp @@ -171,7 +171,9 @@ void MetricProducer::loadActiveMetricLocked(const ActiveMetric& activeMetric, continue; } auto& activation = it->second; - if (activeEventActivation.state() == ActiveEventActivation::ACTIVE) { + // If the event activation does not have a state, assume it is active. + if (!activeEventActivation.has_state() || + activeEventActivation.state() == ActiveEventActivation::ACTIVE) { // We don't want to change the ttl for future activations, so we set the start_ns // such that start_ns + ttl_ns == currentTimeNs + remaining_ttl_nanos activation->start_ns =