Add Bluetooth atoms

+ refactor pullers in StatsCompanionService to be more modular
+ rename CpuSuspendTime and CpuIdleTime to SystemElapsedRealtime
  and SystemUptime

Test: will add cts test
Change-Id: I463103fb271511cef4e0f877c20fd167fe8b173b
diff --git a/stats/atoms.proto b/stats/atoms.proto
index 99e871f..b8ff0bd 100644
--- a/stats/atoms.proto
+++ b/stats/atoms.proto
@@ -94,26 +94,27 @@
     }
 
     // Pulled events will start at field 10000.
+    // Next: 10019
     oneof pulled {
         WifiBytesTransfer wifi_bytes_transfer = 10000;
         WifiBytesTransferByFgBg wifi_bytes_transfer_by_fg_bg = 10001;
         MobileBytesTransfer mobile_bytes_transfer = 10002;
         MobileBytesTransferByFgBg mobile_bytes_transfer_by_fg_bg = 10003;
+        BluetoothBytesTransfer bluetooth_bytes_transfer = 10006;
         KernelWakelock kernel_wakelock = 10004;
         SubsystemSleepState subsystem_sleep_state = 10005;
-        // 10006 and 10007 are free to use.
         CpuTimePerFreq cpu_time_per_freq = 10008;
         CpuTimePerUid cpu_time_per_uid = 10009;
         CpuTimePerUidFreq cpu_time_per_uid_freq = 10010;
         WifiActivityEnergyInfo wifi_activity_energy_info = 10011;
         ModemActivityInfo modem_activity_info = 10012;
         ProcessMemoryStat process_memory_stat = 10013;
-        CpuSuspendTime cpu_suspend_time = 10014;
-        CpuIdleTime cpu_idle_time = 10015;
+        BluetoothActivityInfo bluetooth_activity_info = 10007;
+        SystemElapsedRealtime system_elapsed_realtime = 10014;
+        SystemUptime system_uptime = 10015;
         CpuActiveTime cpu_active_time = 10016;
         CpuClusterTime cpu_cluster_time = 10017;
         DiskSpace disk_space = 10018;
-        SystemUptime system_uptime = 10019;
     }
 }
 
@@ -999,6 +1000,20 @@
 }
 
 /**
+ * Pulls bytes transferred via bluetooth. It is pulled from Bluetooth controller.
+ *
+ * Pulled from:
+ *   StatsCompanionService
+ */
+message BluetoothBytesTransfer {
+    optional int32 uid = 1;
+
+    optional int64 rx_bytes = 2;
+
+    optional int64 tx_bytes = 3;
+}
+
+/**
  * Pulls the kernel wakelock durations. This atom is adapted from
  * android/internal/os/KernelWakelockStats.java
  *
@@ -1168,6 +1183,25 @@
     optional uint64 energy_used = 10;
 }
 
+/**
+ * Pulls Bluetooth Activity Energy Info
+ * Note: BluetoothBytesTransfer is pulled at the same time from the controller.
+ */
+message BluetoothActivityInfo {
+    // timestamp(wall clock) of record creation
+    optional uint64 timestamp_ms = 1;
+    // bluetooth stack state
+    optional int32 bluetooth_stack_state = 2;
+    // tx time in ms
+    optional uint64 controller_tx_time_ms = 3;
+    // rx time in ms
+    optional uint64 controller_rx_time_ms = 4;
+    // idle time in ms
+    optional uint64 controller_idle_time_ms = 5;
+    // product of current(mA), voltage(V) and time(ms)
+    optional uint64 energy_used = 6;
+}
+
 /*
  * Logs the memory stats for a process
  */
@@ -1214,17 +1248,21 @@
 }
 
 /*
- * Cpu syspend time for cpu power calculation.
+ * Elapsed real time from SystemClock.
  */
-message CpuSuspendTime {
-    optional uint64 time = 1;
+message SystemElapsedRealtime {
+    optional uint64 time_ms = 1;
 }
 
 /*
- * Cpu idle time for cpu power calculation.
+ * Up time from SystemClock.
  */
-message CpuIdleTime {
-    optional uint64 time = 1;
+message SystemUptime {
+    // Milliseconds since the system was booted.
+    // This clock stops when the system enters deep sleep (CPU off, display dark, device waiting
+    // for external input).
+    // It is not affected by clock scaling, idle, or other power saving mechanisms.
+    optional uint64 uptime_ms = 1;
 }
 
 /*
@@ -1268,14 +1306,3 @@
     // available bytes in download cache or temp directories
     optional uint64 temp_available_bytes = 3;
 }
-
-/*
- * Pulls system up time.
- */
-message SystemUptime {
-    // Milliseconds since the system was booted.
-    // This clock stops when the system enters deep sleep (CPU off, display dark, device waiting
-    // for external input).
-    // It is not affected by clock scaling, idle, or other power saving mechanisms.
-    optional uint64 uptime_ms = 1;
-}