Merge "BatteryStats: Fix units on battery charge counter" into nyc-dev

This commit is contained in:
Adam Lesinski
2016-05-03 19:47:33 +00:00
committed by Android (Google) Code Review
4 changed files with 32 additions and 32 deletions

View File

@@ -1158,7 +1158,8 @@ public abstract class BatteryStats implements Parcelable {
public short batteryTemperature;
public char batteryVoltage;
public int batteryChargeCoulombs;
// The charge of the battery in micro-Ampere-hours.
public int batteryChargeUAh;
// Constants from SCREEN_BRIGHTNESS_*
public static final int STATE_BRIGHTNESS_SHIFT = 0;
@@ -1356,7 +1357,7 @@ public abstract class BatteryStats implements Parcelable {
bat = (((int)batteryTemperature)&0xffff)
| ((((int)batteryVoltage)<<16)&0xffff0000);
dest.writeInt(bat);
dest.writeInt(batteryChargeCoulombs);
dest.writeInt(batteryChargeUAh);
dest.writeInt(states);
dest.writeInt(states2);
if (wakelockTag != null) {
@@ -1385,7 +1386,7 @@ public abstract class BatteryStats implements Parcelable {
int bat2 = src.readInt();
batteryTemperature = (short)(bat2&0xffff);
batteryVoltage = (char)((bat2>>16)&0xffff);
batteryChargeCoulombs = src.readInt();
batteryChargeUAh = src.readInt();
states = src.readInt();
states2 = src.readInt();
if ((bat&0x10000000) != 0) {
@@ -1425,7 +1426,7 @@ public abstract class BatteryStats implements Parcelable {
batteryPlugType = 0;
batteryTemperature = 0;
batteryVoltage = 0;
batteryChargeCoulombs = 0;
batteryChargeUAh = 0;
states = 0;
states2 = 0;
wakelockTag = null;
@@ -1453,7 +1454,7 @@ public abstract class BatteryStats implements Parcelable {
batteryPlugType = o.batteryPlugType;
batteryTemperature = o.batteryTemperature;
batteryVoltage = o.batteryVoltage;
batteryChargeCoulombs = o.batteryChargeCoulombs;
batteryChargeUAh = o.batteryChargeUAh;
states = o.states;
states2 = o.states2;
if (o.wakelockTag != null) {
@@ -1485,7 +1486,7 @@ public abstract class BatteryStats implements Parcelable {
&& batteryPlugType == o.batteryPlugType
&& batteryTemperature == o.batteryTemperature
&& batteryVoltage == o.batteryVoltage
&& batteryChargeCoulombs == o.batteryChargeCoulombs
&& batteryChargeUAh == o.batteryChargeUAh
&& states == o.states
&& states2 == o.states2
&& currentTime == o.currentTime;
@@ -4536,7 +4537,7 @@ public abstract class BatteryStats implements Parcelable {
int oldPlug = -1;
int oldTemp = -1;
int oldVolt = -1;
int oldCharge = -1;
int oldChargeMAh = -1;
long lastTime = -1;
void reset() {
@@ -4547,7 +4548,7 @@ public abstract class BatteryStats implements Parcelable {
oldPlug = -1;
oldTemp = -1;
oldVolt = -1;
oldCharge = -1;
oldChargeMAh = -1;
}
public void printNextItem(PrintWriter pw, HistoryItem rec, long baseTime, boolean checkin,
@@ -4709,10 +4710,11 @@ public abstract class BatteryStats implements Parcelable {
pw.print(checkin ? ",Bv=" : " volt=");
pw.print(oldVolt);
}
if (oldCharge != rec.batteryChargeCoulombs) {
oldCharge = rec.batteryChargeCoulombs;
final int chargeMAh = rec.batteryChargeUAh / 1000;
if (oldChargeMAh != chargeMAh) {
oldChargeMAh = chargeMAh;
pw.print(checkin ? ",Bcc=" : " charge=");
pw.print(oldCharge);
pw.print(oldChargeMAh);
}
printBitDescriptions(pw, oldState, rec.states, rec.wakelockTag,
HISTORY_STATE_DESCRIPTIONS, !checkin);

View File

@@ -123,7 +123,7 @@ interface IBatteryStats {
void noteNetworkStatsEnabled();
void noteDeviceIdleMode(int mode, String activeReason, int activeUid);
void setBatteryState(int status, int health, int plugType, int level, int temp, int volt,
int chargeCount);
int chargeUAh);
long getAwakeTimeBattery();
long getAwakeTimePlugged();

View File

@@ -2185,8 +2185,8 @@ public class BatteryStatsImpl extends BatteryStats {
static final int DELTA_WAKELOCK_FLAG = 0x00400000;
// Flag in delta int: contains an event description.
static final int DELTA_EVENT_FLAG = 0x00800000;
// Flag in delta int: contains a coulomb charge count.
static final int DELTA_BATTERY_CHARGE_COULOMBS_FLAG = 0x01000000;
// Flag in delta int: contains the battery charge count in uAh.
static final int DELTA_BATTERY_CHARGE_FLAG = 0x01000000;
// These upper bits are the frequently changing state bits.
static final int DELTA_STATE_MASK = 0xfe000000;
@@ -2250,10 +2250,9 @@ public class BatteryStatsImpl extends BatteryStats {
firstToken |= DELTA_EVENT_FLAG;
}
final boolean batteryChargeCoulombsChanged = cur.batteryChargeCoulombs
!= last.batteryChargeCoulombs;
if (batteryChargeCoulombsChanged) {
firstToken |= DELTA_BATTERY_CHARGE_COULOMBS_FLAG;
final boolean batteryChargeChanged = cur.batteryChargeUAh != last.batteryChargeUAh;
if (batteryChargeChanged) {
firstToken |= DELTA_BATTERY_CHARGE_FLAG;
}
dest.writeInt(firstToken);
if (DEBUG) Slog.i(TAG, "WRITE DELTA: firstToken=0x" + Integer.toHexString(firstToken)
@@ -2338,10 +2337,9 @@ public class BatteryStatsImpl extends BatteryStats {
}
mLastHistoryStepLevel = cur.batteryLevel;
if (batteryChargeCoulombsChanged) {
if (DEBUG) Slog.i(TAG, "WRITE DELTA: batteryChargeCoulombs="
+ cur.batteryChargeCoulombs);
dest.writeInt(cur.batteryChargeCoulombs);
if (batteryChargeChanged) {
if (DEBUG) Slog.i(TAG, "WRITE DELTA: batteryChargeUAh=" + cur.batteryChargeUAh);
dest.writeInt(cur.batteryChargeUAh);
}
}
@@ -2590,8 +2588,8 @@ public class BatteryStatsImpl extends BatteryStats {
cur.stepDetails = null;
}
if ((firstToken&DELTA_BATTERY_CHARGE_COULOMBS_FLAG) != 0) {
cur.batteryChargeCoulombs = src.readInt();
if ((firstToken&DELTA_BATTERY_CHARGE_FLAG) != 0) {
cur.batteryChargeUAh = src.readInt();
}
}
@@ -9310,7 +9308,7 @@ public class BatteryStatsImpl extends BatteryStats {
public static final int BATTERY_PLUGGED_NONE = 0;
public void setBatteryStateLocked(int status, int health, int plugType, int level,
int temp, int volt, int chargeCount) {
int temp, int volt, int chargeUAh) {
final boolean onBattery = plugType == BATTERY_PLUGGED_NONE;
final long uptime = mClocks.uptimeMillis();
final long elapsedRealtime = mClocks.elapsedRealtime();
@@ -9362,7 +9360,7 @@ public class BatteryStatsImpl extends BatteryStats {
mHistoryCur.batteryPlugType = (byte)plugType;
mHistoryCur.batteryTemperature = (short)temp;
mHistoryCur.batteryVoltage = (char)volt;
mHistoryCur.batteryChargeCoulombs = chargeCount;
mHistoryCur.batteryChargeUAh = chargeUAh;
setOnBatteryLocked(elapsedRealtime, uptime, onBattery, oldStatus, level);
} else {
boolean changed = false;
@@ -9396,9 +9394,9 @@ public class BatteryStatsImpl extends BatteryStats {
mHistoryCur.batteryVoltage = (char)volt;
changed = true;
}
if (chargeCount >= (mHistoryCur.batteryChargeCoulombs+10)
|| chargeCount <= (mHistoryCur.batteryChargeCoulombs-10)) {
mHistoryCur.batteryChargeCoulombs = chargeCount;
if (chargeUAh >= (mHistoryCur.batteryChargeUAh+10)
|| chargeUAh <= (mHistoryCur.batteryChargeUAh-10)) {
mHistoryCur.batteryChargeUAh = chargeUAh;
changed = true;
}
long modeBits = (((long)mInitStepMode) << STEP_LEVEL_INITIAL_MODE_SHIFT)

View File

@@ -974,7 +974,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub
@Override
public void setBatteryState(final int status, final int health, final int plugType,
final int level, final int temp, final int volt, final int chargeCount) {
final int level, final int temp, final int volt, final int chargeUAh) {
enforceCallingPermission();
// BatteryService calls us here and we may update external state. It would be wrong
@@ -988,7 +988,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub
// The battery state has not changed, so we don't need to sync external
// stats immediately.
mStats.setBatteryStateLocked(status, health, plugType, level, temp, volt,
chargeCount);
chargeUAh);
return;
}
}
@@ -998,7 +998,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub
updateExternalStatsSync("battery-state", BatteryStatsImpl.ExternalStatsSync.UPDATE_ALL);
synchronized (mStats) {
mStats.setBatteryStateLocked(status, health, plugType, level, temp, volt,
chargeCount);
chargeUAh);
}
}
});