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/stats_events.proto b/cmds/statsd/src/stats_events.proto
index 3789baf..5ce7c70 100644
--- a/cmds/statsd/src/stats_events.proto
+++ b/cmds/statsd/src/stats_events.proto
@@ -70,6 +70,7 @@
         WifiScanStateChanged wifi_scan_state_changed = 39;
         PhoneSignalStrengthChanged phone_signal_strength_changed = 40;
         SettingChanged setting_changed = 41;
+        KernelWakelockPulled kernel_wakelock_pulled = 42;
         // TODO: Reorder the numbering so that the most frequent occur events occur in the first 15.
     }
 }
@@ -679,3 +680,16 @@
     // The user ID associated. Defined in android/os/UserHandle.java
     optional int32 user = 7;
 }
+
+/*
+ * Pulls kernel wakelock changes.
+ *
+ * Pulled from:
+  *   frameworks/base/services/core/java/com/android/server/stats/StatsCompanionService.java
+ */
+message KernelWakelockPulled {
+    optional int32 count = 1;
+    optional int32 version = 2;
+    optional int64 total_time = 3;
+    optional string name = 4;
+}