Fix issue #10422349: Limit/change the battery history data in batterystats
Don't include history in real checkins; have a new compact option
for bug reports.
Change-Id: I077f9218b365154f6bae9cc685c2c6b378e0283a
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index 38ffb96..dbaa325 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -2380,22 +2380,25 @@
@SuppressWarnings("unused")
public void dumpCheckinLocked(
- PrintWriter pw, List<ApplicationInfo> apps, boolean isUnpluggedOnly) {
+ PrintWriter pw, List<ApplicationInfo> apps, boolean isUnpluggedOnly,
+ boolean includeHistory) {
prepareForDumpLocked();
long now = getHistoryBaseTime() + SystemClock.elapsedRealtime();
- final HistoryItem rec = new HistoryItem();
- if (startIteratingHistoryLocked()) {
- HistoryPrinter hprinter = new HistoryPrinter();
- while (getNextHistoryLocked(rec)) {
- pw.print(BATTERY_STATS_CHECKIN_VERSION); pw.print(',');
- pw.print(0); pw.print(',');
- pw.print(HISTORY_DATA); pw.print(',');
- hprinter.printNextItemCheckin(pw, rec, now);
- pw.println();
+ if (includeHistory) {
+ final HistoryItem rec = new HistoryItem();
+ if (startIteratingHistoryLocked()) {
+ HistoryPrinter hprinter = new HistoryPrinter();
+ while (getNextHistoryLocked(rec)) {
+ pw.print(BATTERY_STATS_CHECKIN_VERSION); pw.print(',');
+ pw.print(0); pw.print(',');
+ pw.print(HISTORY_DATA); pw.print(',');
+ hprinter.printNextItemCheckin(pw, rec, now);
+ pw.println();
+ }
+ finishIteratingHistoryLocked();
}
- finishIteratingHistoryLocked();
}
if (apps != null) {