am 8144585c: Merge "Fix issue #10422349: Limit/change the battery history data in batterystats" into klp-dev

* commit '8144585c5853d5f2dd5f30e4ab9c0abe7457d556':
  Fix issue #10422349: Limit/change the battery history data in batterystats
This commit is contained in:
Dianne Hackborn
2013-09-04 18:24:36 -07:00
committed by Android Git Automerger
2 changed files with 20 additions and 13 deletions

View File

@@ -2380,22 +2380,25 @@ public abstract class BatteryStats implements Parcelable {
@SuppressWarnings("unused") @SuppressWarnings("unused")
public void dumpCheckinLocked( public void dumpCheckinLocked(
PrintWriter pw, List<ApplicationInfo> apps, boolean isUnpluggedOnly) { PrintWriter pw, List<ApplicationInfo> apps, boolean isUnpluggedOnly,
boolean includeHistory) {
prepareForDumpLocked(); prepareForDumpLocked();
long now = getHistoryBaseTime() + SystemClock.elapsedRealtime(); long now = getHistoryBaseTime() + SystemClock.elapsedRealtime();
final HistoryItem rec = new HistoryItem(); if (includeHistory) {
if (startIteratingHistoryLocked()) { final HistoryItem rec = new HistoryItem();
HistoryPrinter hprinter = new HistoryPrinter(); if (startIteratingHistoryLocked()) {
while (getNextHistoryLocked(rec)) { HistoryPrinter hprinter = new HistoryPrinter();
pw.print(BATTERY_STATS_CHECKIN_VERSION); pw.print(','); while (getNextHistoryLocked(rec)) {
pw.print(0); pw.print(','); pw.print(BATTERY_STATS_CHECKIN_VERSION); pw.print(',');
pw.print(HISTORY_DATA); pw.print(','); pw.print(0); pw.print(',');
hprinter.printNextItemCheckin(pw, rec, now); pw.print(HISTORY_DATA); pw.print(',');
pw.println(); hprinter.printNextItemCheckin(pw, rec, now);
pw.println();
}
finishIteratingHistoryLocked();
} }
finishIteratingHistoryLocked();
} }
if (apps != null) { if (apps != null) {

View File

@@ -481,7 +481,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub {
private void dumpHelp(PrintWriter pw) { private void dumpHelp(PrintWriter pw) {
pw.println("Battery stats (batterystats) dump options:"); pw.println("Battery stats (batterystats) dump options:");
pw.println(" [--checkin] [--unplugged] [--reset] [--write] [-h] [<package.name>]"); pw.println(" [--checkin] [-c] [--unplugged] [--reset] [--write] [-h] [<package.name>]");
pw.println(" --checkin: format output for a checkin report."); pw.println(" --checkin: format output for a checkin report.");
pw.println(" --unplugged: only output data since last unplugged."); pw.println(" --unplugged: only output data since last unplugged.");
pw.println(" --reset: reset the stats, clearing all current data."); pw.println(" --reset: reset the stats, clearing all current data.");
@@ -501,6 +501,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub {
} }
boolean isCheckin = false; boolean isCheckin = false;
boolean includeHistory = false;
boolean isUnpluggedOnly = false; boolean isUnpluggedOnly = false;
boolean noOutput = false; boolean noOutput = false;
int reqUid = -1; int reqUid = -1;
@@ -508,6 +509,9 @@ public final class BatteryStatsService extends IBatteryStats.Stub {
for (String arg : args) { for (String arg : args) {
if ("--checkin".equals(arg)) { if ("--checkin".equals(arg)) {
isCheckin = true; isCheckin = true;
} else if ("-c".equals(arg)) {
isCheckin = true;
includeHistory = true;
} else if ("--unplugged".equals(arg)) { } else if ("--unplugged".equals(arg)) {
isUnpluggedOnly = true; isUnpluggedOnly = true;
} else if ("--reset".equals(arg)) { } else if ("--reset".equals(arg)) {
@@ -550,7 +554,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub {
if (isCheckin) { if (isCheckin) {
List<ApplicationInfo> apps = mContext.getPackageManager().getInstalledApplications(0); List<ApplicationInfo> apps = mContext.getPackageManager().getInstalledApplications(0);
synchronized (mStats) { synchronized (mStats) {
mStats.dumpCheckinLocked(pw, apps, isUnpluggedOnly); mStats.dumpCheckinLocked(pw, apps, isUnpluggedOnly, includeHistory);
} }
} else { } else {
synchronized (mStats) { synchronized (mStats) {