summaryrefslogtreecommitdiffstats
path: root/core/java/android/os/BatteryStats.java
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2014-09-05 15:50:25 -0700
committerDianne Hackborn <hackbod@google.com>2014-09-05 17:33:06 -0700
commitc3940bc1ba753bcbeb9849239ec4b2ec685c40e2 (patch)
tree2422f775ade6090cf29800dbe7e650f708d477c7 /core/java/android/os/BatteryStats.java
parent71cc3b8e84f34c4603da6115193d51336af423db (diff)
downloadframeworks_base-c3940bc1ba753bcbeb9849239ec4b2ec685c40e2.zip
frameworks_base-c3940bc1ba753bcbeb9849239ec4b2ec685c40e2.tar.gz
frameworks_base-c3940bc1ba753bcbeb9849239ec4b2ec685c40e2.tar.bz2
Fix issue #17397177: BatteryStats reporting error on job start/stop
Dumb, dumb, dumb mistake. Also fix battery stats wakeup reason tracking to use a SamplingTimer (like kernel wake locks) so we can track both the duration and count for each wakeup reason. Change-Id: I89d69661006dc533622b1b7e68a139166d3a6975
Diffstat (limited to 'core/java/android/os/BatteryStats.java')
-rw-r--r--core/java/android/os/BatteryStats.java31
1 files changed, 17 insertions, 14 deletions
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index fe9f79b..461469c 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -1667,7 +1667,7 @@ public abstract class BatteryStats implements Parcelable {
*/
public abstract long[] getChargeStepDurationsArray();
- public abstract Map<String, ? extends LongCounter> getWakeupReasonStats();
+ public abstract Map<String, ? extends Timer> getWakeupReasonStats();
public abstract Map<String, ? extends Timer> getKernelWakelockStats();
@@ -2045,11 +2045,15 @@ public abstract class BatteryStats implements Parcelable {
sb.toString());
}
}
- Map<String, ? extends LongCounter> wakeupReasons = getWakeupReasonStats();
+ Map<String, ? extends Timer> wakeupReasons = getWakeupReasonStats();
if (wakeupReasons.size() > 0) {
- for (Map.Entry<String, ? extends LongCounter> ent : wakeupReasons.entrySet()) {
+ for (Map.Entry<String, ? extends Timer> ent : wakeupReasons.entrySet()) {
+ // Not doing the regular wake lock formatting to remain compatible
+ // with the old checkin format.
+ long totalTimeMicros = ent.getValue().getTotalTimeLocked(rawRealtime, which);
+ int count = ent.getValue().getCountLocked(which);
dumpLine(pw, 0 /* uid */, category, WAKEUP_REASON_DATA,
- "\"" + ent.getKey() + "\"", ent.getValue().getCountLocked(which));
+ "\"" + ent.getKey() + "\"", (totalTimeMicros + 500) / 1000, count);
}
}
}
@@ -2921,14 +2925,14 @@ public abstract class BatteryStats implements Parcelable {
pw.println();
}
- Map<String, ? extends LongCounter> wakeupReasons = getWakeupReasonStats();
+ Map<String, ? extends Timer> wakeupReasons = getWakeupReasonStats();
if (wakeupReasons.size() > 0) {
pw.print(prefix); pw.println(" All wakeup reasons:");
final ArrayList<TimerEntry> reasons = new ArrayList<TimerEntry>();
- for (Map.Entry<String, ? extends LongCounter> ent : wakeupReasons.entrySet()) {
- BatteryStats.LongCounter counter = ent.getValue();
- reasons.add(new TimerEntry(ent.getKey(), 0, null,
- ent.getValue().getCountLocked(which)));
+ for (Map.Entry<String, ? extends Timer> ent : wakeupReasons.entrySet()) {
+ Timer timer = ent.getValue();
+ reasons.add(new TimerEntry(ent.getKey(), 0, timer,
+ timer.getCountLocked(which)));
}
Collections.sort(reasons, timerComparator);
for (int i=0; i<reasons.size(); i++) {
@@ -2938,9 +2942,8 @@ public abstract class BatteryStats implements Parcelable {
sb.append(prefix);
sb.append(" Wakeup reason ");
sb.append(timer.mName);
- sb.append(": ");
- formatTimeMs(sb, timer.mTime);
- sb.append("realtime");
+ printWakeLock(sb, timer.mTimer, rawRealtime, null, which, ": ");
+ sb.append(" realtime");
pw.println(sb.toString());
}
pw.println();
@@ -3138,7 +3141,7 @@ public abstract class BatteryStats implements Parcelable {
}
Map<String, ? extends Timer> jobs = u.getJobStats();
- if (syncs.size() > 0) {
+ if (jobs.size() > 0) {
for (Map.Entry<String, ? extends Timer> ent : jobs.entrySet()) {
Timer timer = ent.getValue();
// Convert from microseconds to milliseconds with rounding
@@ -3952,7 +3955,7 @@ public abstract class BatteryStats implements Parcelable {
prepareForDumpLocked();
dumpLine(pw, 0 /* uid */, "i" /* category */, VERSION_DATA,
- "10", getParcelVersion(), getStartPlatformVersion(), getEndPlatformVersion());
+ "11", getParcelVersion(), getStartPlatformVersion(), getEndPlatformVersion());
long now = getHistoryBaseTime() + SystemClock.elapsedRealtime();