summaryrefslogtreecommitdiffstats
path: root/core/java/com
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2014-06-02 12:42:12 -0700
committerDianne Hackborn <hackbod@google.com>2014-06-02 12:42:12 -0700
commitfc0641340ff927d9c35d5613723d25858f751118 (patch)
tree09ef9a4305fdc2d1eabec9264074425c402f5100 /core/java/com
parent725010a83f1798e5ba6edb93ca2656a96c29fcae (diff)
downloadframeworks_base-fc0641340ff927d9c35d5613723d25858f751118.zip
frameworks_base-fc0641340ff927d9c35d5613723d25858f751118.tar.gz
frameworks_base-fc0641340ff927d9c35d5613723d25858f751118.tar.bz2
Some battery stats history fixes.
- Now the full wake history uses the history tag if it can. Hopefully this will still result in a consistent history, since that isn't really want the tag is for... but the current implementation in places will probably make this work. - Possibly fix a bug with inconsistent state between partial history snapshots: after a snapshot is printed, don't allow any more batching into the most recent history entry, so the next snapshot will not miss anything that might get placed into it soon after. Also rework command line arguments for enable/disable to make these commands instead of options. Change-Id: Ia33445cad1538bf8df549cef284f1e736efbc079
Diffstat (limited to 'core/java/com')
-rw-r--r--core/java/com/android/internal/os/BatteryStatsImpl.java25
1 files changed, 19 insertions, 6 deletions
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index ed9f9bc..240d520 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -2006,6 +2006,11 @@ public final class BatteryStatsImpl extends BatteryStats {
}
}
+ @Override
+ public void commitCurrentHistoryBatchLocked() {
+ mHistoryLastWritten.cmd = HistoryItem.CMD_NULL;
+ }
+
void addHistoryBufferLocked(long elapsedRealtimeMs, long uptimeMs, HistoryItem cur) {
if (!mHaveBatteryLevel || !mRecordingHistory) {
return;
@@ -2342,13 +2347,16 @@ public final class BatteryStatsImpl extends BatteryStats {
// Only care about partial wake locks, since full wake locks
// will be canceled when the user puts the screen to sleep.
aggregateLastWakeupUptimeLocked(uptime);
+ if (historyName == null) {
+ historyName = name;
+ }
if (mRecordAllWakeLocks) {
- if (mActiveEvents.updateState(HistoryItem.EVENT_WAKE_LOCK_START, name, uid, 0)) {
+ if (mActiveEvents.updateState(HistoryItem.EVENT_WAKE_LOCK_START, historyName,
+ uid, 0)) {
addHistoryEventLocked(elapsedRealtime, uptime,
- HistoryItem.EVENT_WAKE_LOCK_START, name, uid);
+ HistoryItem.EVENT_WAKE_LOCK_START, historyName, uid);
}
}
- historyName = historyName == null ? name : historyName;
if (mWakeLockNesting == 0) {
mHistoryCur.states |= HistoryItem.STATE_WAKE_LOCK_FLAG;
if (DEBUG_HISTORY) Slog.v(TAG, "Start wake lock to: "
@@ -2358,7 +2366,8 @@ public final class BatteryStatsImpl extends BatteryStats {
mHistoryCur.wakelockTag.uid = mInitialAcquireWakeUid = uid;
mWakeLockImportant = !unimportantForLogging;
addHistoryRecordLocked(elapsedRealtime, uptime);
- } else if (!mWakeLockImportant && !unimportantForLogging) {
+ } else if (!mWakeLockImportant && !unimportantForLogging
+ && mHistoryLastWritten.cmd == HistoryItem.CMD_UPDATE) {
if (mHistoryLastWritten.wakelockTag != null) {
// We'll try to update the last tag.
mHistoryLastWritten.wakelockTag = null;
@@ -2386,9 +2395,13 @@ public final class BatteryStatsImpl extends BatteryStats {
if (type == WAKE_TYPE_PARTIAL) {
mWakeLockNesting--;
if (mRecordAllWakeLocks) {
- if (mActiveEvents.updateState(HistoryItem.EVENT_WAKE_LOCK_FINISH, name, uid, 0)) {
+ if (historyName == null) {
+ historyName = name;
+ }
+ if (mActiveEvents.updateState(HistoryItem.EVENT_WAKE_LOCK_FINISH, historyName,
+ uid, 0)) {
addHistoryEventLocked(elapsedRealtime, uptime,
- HistoryItem.EVENT_WAKE_LOCK_FINISH, name, uid);
+ HistoryItem.EVENT_WAKE_LOCK_FINISH, historyName, uid);
}
}
if (mWakeLockNesting == 0) {