diff options
| -rw-r--r-- | cmds/statsd/src/atoms.proto | 20 | ||||
| -rw-r--r-- | services/core/java/com/android/server/stats/StatsCompanionService.java | 11 |
2 files changed, 18 insertions, 13 deletions
diff --git a/cmds/statsd/src/atoms.proto b/cmds/statsd/src/atoms.proto index fd62843701b2..51db2d200461 100644 --- a/cmds/statsd/src/atoms.proto +++ b/cmds/statsd/src/atoms.proto @@ -3474,10 +3474,10 @@ message BuildInformation { * 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 @@ message DeviceCalculatedPowerBlameUid { // 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 @@ message DeviceCalculatedPowerBlameOther { } 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; } /** diff --git a/services/core/java/com/android/server/stats/StatsCompanionService.java b/services/core/java/com/android/server/stats/StatsCompanionService.java index 4ec8b87be3ac..30aa5280eac6 100644 --- a/services/core/java/com/android/server/stats/StatsCompanionService.java +++ b/services/core/java/com/android/server/stats/StatsCompanionService.java @@ -1563,11 +1563,16 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { return mBatteryStatsHelper; } + private long milliAmpHrsToNanoAmpSecs(double mAh) { + final long MILLI_AMP_HR_TO_NANO_AMP_SECS = 1_000_000L * 3600L; + return (long) (mAh * MILLI_AMP_HR_TO_NANO_AMP_SECS + 0.5); + } + private void pullDeviceCalculatedPowerUse(int tagId, long elapsedNanos, final long wallClockNanos, List<StatsLogEventWrapper> pulledData) { BatteryStatsHelper bsHelper = getBatteryStatsHelper(); StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, elapsedNanos, wallClockNanos); - e.writeFloat((float) bsHelper.getComputedPower()); + e.writeLong(milliAmpHrsToNanoAmpSecs(bsHelper.getComputedPower())); pulledData.add(e); } @@ -1583,7 +1588,7 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { } StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, elapsedNanos, wallClockNanos); e.writeInt(bs.uidObj.getUid()); - e.writeFloat((float) bs.totalPowerMah); + e.writeLong(milliAmpHrsToNanoAmpSecs(bs.totalPowerMah)); pulledData.add(e); } } @@ -1603,7 +1608,7 @@ public class StatsCompanionService extends IStatsCompanionService.Stub { } StatsLogEventWrapper e = new StatsLogEventWrapper(tagId, elapsedNanos, wallClockNanos); e.writeInt(bs.drainType.ordinal()); - e.writeFloat((float) bs.totalPowerMah); + e.writeLong(milliAmpHrsToNanoAmpSecs(bs.totalPowerMah)); pulledData.add(e); } } |