BatteryStats: Keep track of coulomb counter
Bug:27174034
Change-Id: Ica66817faa20b9788536f28f0e593483f033904b
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index 2c63be2..959b309 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -1157,6 +1157,8 @@
public short batteryTemperature;
public char batteryVoltage;
+
+ public int batteryChargeCoulombs;
// Constants from SCREEN_BRIGHTNESS_*
public static final int STATE_BRIGHTNESS_SHIFT = 0;
@@ -1181,6 +1183,8 @@
public static final int STATE_WIFI_SCAN_FLAG = 1<<27;
public static final int STATE_WIFI_RADIO_ACTIVE_FLAG = 1<<26;
public static final int STATE_MOBILE_RADIO_ACTIVE_FLAG = 1<<25;
+ // Do not use, this is used for coulomb delta count.
+ private static final int STATE_RESERVED_0 = 1<<24;
// These are on the lower bits used for the command; if they change
// we need to write another int of data.
public static final int STATE_SENSOR_ON_FLAG = 1<<23;
@@ -1352,6 +1356,7 @@
bat = (((int)batteryTemperature)&0xffff)
| ((((int)batteryVoltage)<<16)&0xffff0000);
dest.writeInt(bat);
+ dest.writeInt(batteryChargeCoulombs);
dest.writeInt(states);
dest.writeInt(states2);
if (wakelockTag != null) {
@@ -1380,6 +1385,7 @@
int bat2 = src.readInt();
batteryTemperature = (short)(bat2&0xffff);
batteryVoltage = (char)((bat2>>16)&0xffff);
+ batteryChargeCoulombs = src.readInt();
states = src.readInt();
states2 = src.readInt();
if ((bat&0x10000000) != 0) {
@@ -1419,6 +1425,7 @@
batteryPlugType = 0;
batteryTemperature = 0;
batteryVoltage = 0;
+ batteryChargeCoulombs = 0;
states = 0;
states2 = 0;
wakelockTag = null;
@@ -1446,6 +1453,7 @@
batteryPlugType = o.batteryPlugType;
batteryTemperature = o.batteryTemperature;
batteryVoltage = o.batteryVoltage;
+ batteryChargeCoulombs = o.batteryChargeCoulombs;
states = o.states;
states2 = o.states2;
if (o.wakelockTag != null) {
@@ -1477,6 +1485,7 @@
&& batteryPlugType == o.batteryPlugType
&& batteryTemperature == o.batteryTemperature
&& batteryVoltage == o.batteryVoltage
+ && batteryChargeCoulombs == o.batteryChargeCoulombs
&& states == o.states
&& states2 == o.states2
&& currentTime == o.currentTime;
@@ -4527,6 +4536,7 @@
int oldPlug = -1;
int oldTemp = -1;
int oldVolt = -1;
+ int oldCharge = -1;
long lastTime = -1;
void reset() {
@@ -4537,6 +4547,7 @@
oldPlug = -1;
oldTemp = -1;
oldVolt = -1;
+ oldCharge = -1;
}
public void printNextItem(PrintWriter pw, HistoryItem rec, long baseTime, boolean checkin,
@@ -4698,6 +4709,11 @@
pw.print(checkin ? ",Bv=" : " volt=");
pw.print(oldVolt);
}
+ if (oldCharge != rec.batteryChargeCoulombs) {
+ oldCharge = rec.batteryChargeCoulombs;
+ pw.print(checkin ? ",Bcc=" : " charge=");
+ pw.print(oldCharge);
+ }
printBitDescriptions(pw, oldState, rec.states, rec.wakelockTag,
HISTORY_STATE_DESCRIPTIONS, !checkin);
printBitDescriptions(pw, oldState2, rec.states2, null,