@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) {
private void dumpHelp(PrintWriter pw) {
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(" --unplugged: only output data since last unplugged.");
pw.println(" --reset: reset the stats, clearing all current data.");
}
boolean isCheckin = false;
+ boolean includeHistory = false;
boolean isUnpluggedOnly = false;
boolean noOutput = false;
int reqUid = -1;
for (String arg : args) {
if ("--checkin".equals(arg)) {
isCheckin = true;
+ } else if ("-c".equals(arg)) {
+ isCheckin = true;
+ includeHistory = true;
} else if ("--unplugged".equals(arg)) {
isUnpluggedOnly = true;
} else if ("--reset".equals(arg)) {
if (isCheckin) {
List<ApplicationInfo> apps = mContext.getPackageManager().getInstalledApplications(0);
synchronized (mStats) {
- mStats.dumpCheckinLocked(pw, apps, isUnpluggedOnly);
+ mStats.dumpCheckinLocked(pw, apps, isUnpluggedOnly, includeHistory);
}
} else {
synchronized (mStats) {