Add IBatteryStats API to retrieve current charge times.
Also include charge/discharge information in dumpsys.
Change-Id: Ica1b333ad334dc698d4a67da391b378757662f41
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index 93d2297..f63fa8a 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -6358,6 +6358,14 @@
return (msPerLevel * mCurrentBatteryLevel) * 1000;
}
+ public int getNumDischargeStepDurations() {
+ return mNumDischargeStepDurations;
+ }
+
+ public long[] getDischargeStepDurationsArray() {
+ return mDischargeStepDurations;
+ }
+
@Override
public long computeChargeTimeRemaining(long curTime) {
if (mOnBattery) {
@@ -6387,6 +6395,14 @@
return (msPerLevel * (100-mCurrentBatteryLevel)) * 1000;
}
+ public int getNumChargeStepDurations() {
+ return mNumChargeStepDurations;
+ }
+
+ public long[] getChargeStepDurationsArray() {
+ return mChargeStepDurations;
+ }
+
long getBatteryUptimeLocked() {
return mOnBatteryTimeBase.getUptime(SystemClock.uptimeMillis() * 1000);
}
@@ -7705,25 +7721,6 @@
pr.println("*** Bluetooth active type #" + i + ":");
mBluetoothStateTimer[i].logState(pr, " ");
}
- StringBuilder sb = new StringBuilder(128);
- if (mNumDischargeStepDurations > 0) {
- pr.println("*** Discharge step durations:");
- for (int i=0; i<mNumDischargeStepDurations; i++) {
- sb.setLength(0);
- sb.append(" #"); sb.append(i); sb.append(": ");
- formatTimeMs(sb, mDischargeStepDurations[i]);
- pr.println(sb.toString());
- }
- }
- if (mNumChargeStepDurations > 0) {
- pr.println("*** Charge step durations:");
- for (int i=0; i<mNumChargeStepDurations; i++) {
- sb.setLength(0);
- sb.append(" #"); sb.append(i); sb.append(": ");
- formatTimeMs(sb, mChargeStepDurations[i]);
- pr.println(sb.toString());
- }
- }
}
super.dumpLocked(context, pw, flags, reqUid, histStart);
}