reretry ValueMetric implementation and pulling mechanism

Note:
This is for value metric. The default operations is sum the diffs.
The test uses kernel wake lock, which also needs dimension by kernel
wake lock name.

The test is a bit cumbersome as it needs StatsCompanionService to do
the alarm, which is not exact alarm.

The internal state of a slice of bucket would look something like this:

4:ipc0000005e_727_android.hardwar
0      0
4:SensorService_wakelock
40      64
4:ipc0000005c_727_android.hardwar
...

Test: manual test on device.
Change-Id: I2ed0ac7d3c5fcba8b7611d46f38a38ffd8bdc92a
diff --git a/cmds/statsd/src/config/ConfigManager.cpp b/cmds/statsd/src/config/ConfigManager.cpp
index e3ccb06..8812719 100644
--- a/cmds/statsd/src/config/ConfigManager.cpp
+++ b/cmds/statsd/src/config/ConfigManager.cpp
@@ -139,6 +139,9 @@
     int UID_PROCESS_STATE_TAG_ID = 27;
     int UID_PROCESS_STATE_UID_KEY = 1;
 
+    int KERNEL_WAKELOCK_TAG_ID = 41;
+    int KERNEL_WAKELOCK_NAME_KEY = 4;
+
     // Count Screen ON events.
     CountMetric* metric = config.add_count_metric();
     metric->set_metric_id(1);
@@ -228,6 +231,17 @@
     durationMetric->set_type(DurationMetric_AggregationType_DURATION_SUM);
     durationMetric->set_what("SCREEN_IS_ON");
 
+    // Value metric to count KERNEL_WAKELOCK when screen turned on
+    ValueMetric* valueMetric = config.add_value_metric();
+    valueMetric->set_metric_id(6);
+    valueMetric->set_what("KERNEL_WAKELOCK");
+    valueMetric->set_value_field(1);
+    valueMetric->set_condition("SCREEN_IS_ON");
+    keyMatcher = valueMetric->add_dimension();
+    keyMatcher->set_key(KERNEL_WAKELOCK_NAME_KEY);
+    // This is for testing easier. We should never set bucket size this small.
+    valueMetric->mutable_bucket()->set_bucket_size_millis(60 * 1000L);
+
     // Add an EventMetric to log process state change events.
     EventMetric* eventMetric = config.add_event_metric();
     eventMetric->set_metric_id(9);