Loading core/java/android/os/BatteryStats.java +53 −46 Original line number Diff line number Diff line Loading @@ -4356,13 +4356,6 @@ public abstract class BatteryStats { } } /** * Temporary for settings. */ public final void dumpCheckinLocked(Context context, PrintWriter pw, int which, int reqUid) { dumpCheckinLocked(context, pw, which, reqUid, checkWifiOnly(context)); } private static final String[] CHECKIN_POWER_COMPONENT_LABELS = new String[BatteryConsumer.POWER_COMPONENT_COUNT]; static { Loading Loading @@ -7477,22 +7470,8 @@ public abstract class BatteryStats { public static final int DUMP_DEVICE_WIFI_ONLY = 1<<6; private void dumpHistory(PrintWriter pw, int flags, long histStart, boolean checkin) { if (!checkin) { synchronized (this) { final long historyTotalSize = getHistoryTotalSize(); final long historyUsedSize = getHistoryUsedSize(); pw.print("Battery History ("); pw.print((100 * historyUsedSize) / historyTotalSize); pw.print("% used, "); printSizeValue(pw, historyUsedSize); pw.print(" used of "); printSizeValue(pw, historyTotalSize); pw.print(", "); pw.print(getHistoryStringPoolSize()); pw.print(" strings using "); printSizeValue(pw, getHistoryStringPoolBytes()); pw.println("):"); } dumpHistoryTagPoolLocked(pw, checkin); } final HistoryPrinter hprinter = new HistoryPrinter(); Loading Loading @@ -7586,6 +7565,43 @@ public abstract class BatteryStats { } } private void dumpHistoryTagPoolLocked(PrintWriter pw, boolean checkin) { if (checkin) { for (int i = 0; i < getHistoryStringPoolSize(); i++) { pw.print(BATTERY_STATS_CHECKIN_VERSION); pw.print(','); pw.print(HISTORY_STRING_POOL); pw.print(','); pw.print(i); pw.print(","); pw.print(getHistoryTagPoolUid(i)); pw.print(",\""); String str = getHistoryTagPoolString(i); if (str != null) { str = str.replace("\\", "\\\\"); str = str.replace("\"", "\\\""); pw.print(str); } pw.print("\""); pw.println(); } } else { final long historyTotalSize = getHistoryTotalSize(); final long historyUsedSize = getHistoryUsedSize(); pw.print("Battery History ("); pw.print((100 * historyUsedSize) / historyTotalSize); pw.print("% used, "); printSizeValue(pw, historyUsedSize); pw.print(" used of "); printSizeValue(pw, historyTotalSize); pw.print(", "); pw.print(getHistoryStringPoolSize()); pw.print(" strings using "); printSizeValue(pw, getHistoryStringPoolBytes()); pw.println("):"); } } private void dumpDailyLevelStepSummary(PrintWriter pw, String prefix, String label, LevelStepTracker steps, StringBuilder tmpSb, int[] tmpOutInt) { if (steps == null) { Loading Loading @@ -7804,33 +7820,17 @@ public abstract class BatteryStats { // This is called from BatteryStatsService. @SuppressWarnings("unused") public void dumpCheckinLocked(Context context, PrintWriter pw, public void dumpCheckin(Context context, PrintWriter pw, List<ApplicationInfo> apps, int flags, long histStart) { synchronized (this) { prepareForDumpLocked(); dumpLine(pw, 0 /* uid */, "i" /* category */, VERSION_DATA, CHECKIN_VERSION, getParcelVersion(), getStartPlatformVersion(), getEndPlatformVersion()); } if ((flags & (DUMP_INCLUDE_HISTORY | DUMP_HISTORY_ONLY)) != 0) { for (int i = 0; i < getHistoryStringPoolSize(); i++) { pw.print(BATTERY_STATS_CHECKIN_VERSION); pw.print(','); pw.print(HISTORY_STRING_POOL); pw.print(','); pw.print(i); pw.print(","); pw.print(getHistoryTagPoolUid(i)); pw.print(",\""); String str = getHistoryTagPoolString(i); if (str != null) { str = str.replace("\\", "\\\\"); str = str.replace("\"", "\\\""); pw.print(str); } pw.print("\""); pw.println(); } dumpHistory(pw, flags, histStart, true); } Loading @@ -7838,6 +7838,13 @@ public abstract class BatteryStats { return; } synchronized (this) { dumpCheckinLocked(context, pw, apps, flags); } } private void dumpCheckinLocked(Context context, PrintWriter pw, List<ApplicationInfo> apps, int flags) { if (apps != null) { SparseArray<Pair<ArrayList<String>, MutableBoolean>> uids = new SparseArray<>(); for (int i=0; i<apps.size(); i++) { Loading services/core/java/com/android/server/am/BatteryStatsService.java +8 −10 Original line number Diff line number Diff line Loading @@ -2880,7 +2880,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub checkinStats.setPowerProfileLocked(mPowerProfile); checkinStats.readSummaryFromParcel(in); in.recycle(); checkinStats.dumpCheckinLocked(mContext, pw, apps, flags, checkinStats.dumpCheckin(mContext, pw, apps, flags, historyStart); mStats.mCheckinFile.delete(); return; Loading @@ -2892,17 +2892,15 @@ public final class BatteryStatsService extends IBatteryStats.Stub } } } if (DBG) Slog.d(TAG, "begin dumpCheckinLocked from UID " + Binder.getCallingUid()); if (DBG) Slog.d(TAG, "begin dumpCheckin from UID " + Binder.getCallingUid()); awaitCompletion(); synchronized (mStats) { mStats.dumpCheckinLocked(mContext, pw, apps, flags, historyStart); mStats.dumpCheckin(mContext, pw, apps, flags, historyStart); if (writeData) { mStats.writeAsyncLocked(); } } if (DBG) Slog.d(TAG, "end dumpCheckinLocked"); if (DBG) Slog.d(TAG, "end dumpCheckin"); } else { if (DBG) Slog.d(TAG, "begin dumpLocked from UID " + Binder.getCallingUid()); if (DBG) Slog.d(TAG, "begin dump from UID " + Binder.getCallingUid()); awaitCompletion(); mStats.dump(mContext, pw, flags, reqUid, historyStart); Loading @@ -2912,7 +2910,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub pw.println(); mCpuWakeupStats.dump(new IndentingPrintWriter(pw, " "), SystemClock.elapsedRealtime()); if (DBG) Slog.d(TAG, "end dumpLocked"); if (DBG) Slog.d(TAG, "end dump"); } } Loading Loading
core/java/android/os/BatteryStats.java +53 −46 Original line number Diff line number Diff line Loading @@ -4356,13 +4356,6 @@ public abstract class BatteryStats { } } /** * Temporary for settings. */ public final void dumpCheckinLocked(Context context, PrintWriter pw, int which, int reqUid) { dumpCheckinLocked(context, pw, which, reqUid, checkWifiOnly(context)); } private static final String[] CHECKIN_POWER_COMPONENT_LABELS = new String[BatteryConsumer.POWER_COMPONENT_COUNT]; static { Loading Loading @@ -7477,22 +7470,8 @@ public abstract class BatteryStats { public static final int DUMP_DEVICE_WIFI_ONLY = 1<<6; private void dumpHistory(PrintWriter pw, int flags, long histStart, boolean checkin) { if (!checkin) { synchronized (this) { final long historyTotalSize = getHistoryTotalSize(); final long historyUsedSize = getHistoryUsedSize(); pw.print("Battery History ("); pw.print((100 * historyUsedSize) / historyTotalSize); pw.print("% used, "); printSizeValue(pw, historyUsedSize); pw.print(" used of "); printSizeValue(pw, historyTotalSize); pw.print(", "); pw.print(getHistoryStringPoolSize()); pw.print(" strings using "); printSizeValue(pw, getHistoryStringPoolBytes()); pw.println("):"); } dumpHistoryTagPoolLocked(pw, checkin); } final HistoryPrinter hprinter = new HistoryPrinter(); Loading Loading @@ -7586,6 +7565,43 @@ public abstract class BatteryStats { } } private void dumpHistoryTagPoolLocked(PrintWriter pw, boolean checkin) { if (checkin) { for (int i = 0; i < getHistoryStringPoolSize(); i++) { pw.print(BATTERY_STATS_CHECKIN_VERSION); pw.print(','); pw.print(HISTORY_STRING_POOL); pw.print(','); pw.print(i); pw.print(","); pw.print(getHistoryTagPoolUid(i)); pw.print(",\""); String str = getHistoryTagPoolString(i); if (str != null) { str = str.replace("\\", "\\\\"); str = str.replace("\"", "\\\""); pw.print(str); } pw.print("\""); pw.println(); } } else { final long historyTotalSize = getHistoryTotalSize(); final long historyUsedSize = getHistoryUsedSize(); pw.print("Battery History ("); pw.print((100 * historyUsedSize) / historyTotalSize); pw.print("% used, "); printSizeValue(pw, historyUsedSize); pw.print(" used of "); printSizeValue(pw, historyTotalSize); pw.print(", "); pw.print(getHistoryStringPoolSize()); pw.print(" strings using "); printSizeValue(pw, getHistoryStringPoolBytes()); pw.println("):"); } } private void dumpDailyLevelStepSummary(PrintWriter pw, String prefix, String label, LevelStepTracker steps, StringBuilder tmpSb, int[] tmpOutInt) { if (steps == null) { Loading Loading @@ -7804,33 +7820,17 @@ public abstract class BatteryStats { // This is called from BatteryStatsService. @SuppressWarnings("unused") public void dumpCheckinLocked(Context context, PrintWriter pw, public void dumpCheckin(Context context, PrintWriter pw, List<ApplicationInfo> apps, int flags, long histStart) { synchronized (this) { prepareForDumpLocked(); dumpLine(pw, 0 /* uid */, "i" /* category */, VERSION_DATA, CHECKIN_VERSION, getParcelVersion(), getStartPlatformVersion(), getEndPlatformVersion()); } if ((flags & (DUMP_INCLUDE_HISTORY | DUMP_HISTORY_ONLY)) != 0) { for (int i = 0; i < getHistoryStringPoolSize(); i++) { pw.print(BATTERY_STATS_CHECKIN_VERSION); pw.print(','); pw.print(HISTORY_STRING_POOL); pw.print(','); pw.print(i); pw.print(","); pw.print(getHistoryTagPoolUid(i)); pw.print(",\""); String str = getHistoryTagPoolString(i); if (str != null) { str = str.replace("\\", "\\\\"); str = str.replace("\"", "\\\""); pw.print(str); } pw.print("\""); pw.println(); } dumpHistory(pw, flags, histStart, true); } Loading @@ -7838,6 +7838,13 @@ public abstract class BatteryStats { return; } synchronized (this) { dumpCheckinLocked(context, pw, apps, flags); } } private void dumpCheckinLocked(Context context, PrintWriter pw, List<ApplicationInfo> apps, int flags) { if (apps != null) { SparseArray<Pair<ArrayList<String>, MutableBoolean>> uids = new SparseArray<>(); for (int i=0; i<apps.size(); i++) { Loading
services/core/java/com/android/server/am/BatteryStatsService.java +8 −10 Original line number Diff line number Diff line Loading @@ -2880,7 +2880,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub checkinStats.setPowerProfileLocked(mPowerProfile); checkinStats.readSummaryFromParcel(in); in.recycle(); checkinStats.dumpCheckinLocked(mContext, pw, apps, flags, checkinStats.dumpCheckin(mContext, pw, apps, flags, historyStart); mStats.mCheckinFile.delete(); return; Loading @@ -2892,17 +2892,15 @@ public final class BatteryStatsService extends IBatteryStats.Stub } } } if (DBG) Slog.d(TAG, "begin dumpCheckinLocked from UID " + Binder.getCallingUid()); if (DBG) Slog.d(TAG, "begin dumpCheckin from UID " + Binder.getCallingUid()); awaitCompletion(); synchronized (mStats) { mStats.dumpCheckinLocked(mContext, pw, apps, flags, historyStart); mStats.dumpCheckin(mContext, pw, apps, flags, historyStart); if (writeData) { mStats.writeAsyncLocked(); } } if (DBG) Slog.d(TAG, "end dumpCheckinLocked"); if (DBG) Slog.d(TAG, "end dumpCheckin"); } else { if (DBG) Slog.d(TAG, "begin dumpLocked from UID " + Binder.getCallingUid()); if (DBG) Slog.d(TAG, "begin dump from UID " + Binder.getCallingUid()); awaitCompletion(); mStats.dump(mContext, pw, flags, reqUid, historyStart); Loading @@ -2912,7 +2910,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub pw.println(); mCpuWakeupStats.dump(new IndentingPrintWriter(pw, " "), SystemClock.elapsedRealtime()); if (DBG) Slog.d(TAG, "end dumpLocked"); if (DBG) Slog.d(TAG, "end dump"); } } Loading