batteryservice: add battery current now and charge counter data

Available for retrieval via future APIs if desired.  Dumped by dumpsys.
Not added to batterystats or ACTION_BATTERY_CHANGED intents at this point.

Also fixes a formatting problem in the existing dumpsys output for voltage.

Change-Id: I5320b19035914256fb872c13095c09c648dd522a
This commit is contained in:
Todd Poynor
2013-07-30 20:33:27 -07:00
parent 9a04435e5f
commit df89ca3308
2 changed files with 18 additions and 1 deletions

View File

@@ -30,6 +30,8 @@ public class BatteryProperties implements Parcelable {
public boolean batteryPresent;
public int batteryLevel;
public int batteryVoltage;
public int batteryCurrentNow;
public int batteryChargeCounter;
public int batteryTemperature;
public String batteryTechnology;
@@ -47,6 +49,8 @@ public class BatteryProperties implements Parcelable {
batteryPresent = p.readInt() == 1 ? true : false;
batteryLevel = p.readInt();
batteryVoltage = p.readInt();
batteryCurrentNow = p.readInt();
batteryChargeCounter = p.readInt();
batteryTemperature = p.readInt();
batteryTechnology = p.readString();
}
@@ -60,6 +64,8 @@ public class BatteryProperties implements Parcelable {
p.writeInt(batteryPresent ? 1 : 0);
p.writeInt(batteryLevel);
p.writeInt(batteryVoltage);
p.writeInt(batteryCurrentNow);
p.writeInt(batteryChargeCounter);
p.writeInt(batteryTemperature);
p.writeString(batteryTechnology);
}

View File

@@ -314,6 +314,8 @@ public final class BatteryService extends Binder {
+ ", batteryLevel=" + mBatteryProps.batteryLevel
+ ", batteryTechnology=" + mBatteryProps.batteryTechnology
+ ", batteryVoltage=" + mBatteryProps.batteryVoltage
+ ", batteryCurrentNow=" + mBatteryProps.batteryCurrentNow
+ ", batteryChargeCounter=" + mBatteryProps.batteryChargeCounter
+ ", batteryTemperature=" + mBatteryProps.batteryTemperature
+ ", mBatteryLevelCritical=" + mBatteryLevelCritical
+ ", mPlugType=" + mPlugType);
@@ -613,7 +615,16 @@ public final class BatteryService extends Binder {
pw.println(" present: " + mBatteryProps.batteryPresent);
pw.println(" level: " + mBatteryProps.batteryLevel);
pw.println(" scale: " + BATTERY_SCALE);
pw.println(" voltage:" + mBatteryProps.batteryVoltage);
pw.println(" voltage: " + mBatteryProps.batteryVoltage);
if (mBatteryProps.batteryCurrentNow != Integer.MIN_VALUE) {
pw.println(" current now: " + mBatteryProps.batteryCurrentNow);
}
if (mBatteryProps.batteryChargeCounter != Integer.MIN_VALUE) {
pw.println(" charge counter: " + mBatteryProps.batteryChargeCounter);
}
pw.println(" temperature: " + mBatteryProps.batteryTemperature);
pw.println(" technology: " + mBatteryProps.batteryTechnology);
} else if (args.length == 3 && "set".equals(args[0])) {