Statsd: change power units from double to int64

Changes the units for the following atoms from mAh to nAs:

DeviceCalculatedPowerUse
DeviceCalculatedPowerBlameUid
DeviceCalculatedPowerBlameOther

and changes them from floats to int64s.

int64 is better supported in statsd. In particular, Anomaly Detection
currently works only for int64, not floats.

The loss in precision here should be minimal or none. These numbers come
from BatteryStats, which calculates them as follows:

BatteryStats reports time in microseconds (us) as a long.
PowerProfile reports current in mA as a double.
  On the power_profile.xml files I have seen, they only have three
  decimal places of precision. So uA precision should suffice.

Thus, the absolute smallest unit of charge BatteryStats can therefore
measure (assuming three digits in the PowerProfile) is nAs. Given that our
measurements are over much longer periods of time than a microsecond, we
should be very safe.

In terms of max value: a phone battery is typically around
4000mAh  ~ 10^13 nAs << max_int64 by many orders of magnitude.

Bug: 119111972

Test: cts-tradefed run cts-dev -m CtsStatsdHostTestCases -t android.cts.statsd.atom.UidAtomTests#testDeviceCalculatedPowerUse
Test: cts-tradefed run cts-dev -m CtsStatsdHostTestCases -t android.cts.statsd.atom.UidAtomTests#testDeviceCalculatedPowerBlameUid

Test: cts-tradefed run cts-dev -m CtsStatsdHostTestCases -t android.cts.statsd.validation.BatteryStatsValidationTests#testPowerUse
Test: cts-tradefed run cts-dev -m CtsStatsdHostTestCases -t android.cts.statsd.validation.BatteryStatsValidationTests#testPowerBlameUid

Change-Id: I1cfd0a05717d7d357b43dd2408c85096599516c7
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto
index fd62843..51db2d2 100644
--- a/cmds/statsd/src/atoms.proto
+++ b/cmds/statsd/src/atoms.proto
@@ -3474,10 +3474,10 @@
  * Pulls on-device BatteryStats power use calculations for the overall device.
  */
 message DeviceCalculatedPowerUse {
-    // Power used by the device in mAh, as computed by BatteryStats, since BatteryStats last reset
-    // (i.e. roughly since device was last significantly charged).
-    // Currently, this is BatteryStatsHelper.getComputedPower() (not getTotalPower()).
-    optional float computed_power_milli_amp_hours = 1;
+    // Power used by the device in nAs (i.e. nanocoulombs (nC)), as computed by BatteryStats, since
+    // BatteryStats last reset (i.e. roughly since device was last significantly charged).
+    // Currently, this is from BatteryStatsHelper.getComputedPower() (not getTotalPower()).
+    optional int64 computed_power_nano_amp_secs = 1;
 }
 
 /**
@@ -3489,9 +3489,9 @@
     // Uid being blamed. Note: isolated uids have already been mapped to host uid.
     optional int32 uid = 1 [(is_uid) = true];
 
-    // Power used by this uid in mAh, as computed by BatteryStats, since BatteryStats last reset
-    // (i.e. roughly since device was last significantly charged).
-    optional float power_milli_amp_hours = 2;
+    // Power used by this uid in nAs (i.e. nanocoulombs (nC)), as computed by BatteryStats, since
+    // BatteryStats last reset (i.e. roughly since device was last significantly charged).
+    optional int64 power_nano_amp_secs = 2;
 }
 
 /**
@@ -3525,9 +3525,9 @@
     }
     optional DrainType drain_type = 1;
 
-    // Power used by this item in mAh, as computed by BatteryStats, since BatteryStats last reset
-    // (i.e. roughly since device was last significantly charged).
-    optional float power_milli_amp_hours = 2;
+    // Power used by this item in nAs (i.e. nanocoulombs (nC)), as computed by BatteryStats, since
+    // BatteryStats last reset (i.e. roughly since device was last significantly charged).
+    optional int64 power_nano_amp_secs = 2;
 }
 
 /**