diff options
author | Dianne Hackborn <hackbod@google.com> | 2014-05-15 17:05:22 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2014-05-16 10:46:33 -0700 |
commit | 9a7554300637902bbb25991ffba41a9b8f682eff (patch) | |
tree | 0243a39c0a5837d4fe86215a28003df91216315f /core | |
parent | 00bcf01a916938c5be4ca84c5fd8a3d6f502edb9 (diff) | |
download | frameworks_base-9a7554300637902bbb25991ffba41a9b8f682eff.zip frameworks_base-9a7554300637902bbb25991ffba41a9b8f682eff.tar.gz frameworks_base-9a7554300637902bbb25991ffba41a9b8f682eff.tar.bz2 |
Fix recording of wake_lock_in.
There was a bug that would allow the nesting count
to get off. Also better documentation of times in
HistoryItem, and new option to disable resetting of
the stats when unplugging.
Change-Id: If1b39a02475c5b620c67b700a323a6d0462d5c61
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/os/BatteryStats.java | 5 | ||||
-rw-r--r-- | core/java/com/android/internal/os/BatteryStatsImpl.java | 18 |
2 files changed, 15 insertions, 8 deletions
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java index cf0caed..af45fa0 100644 --- a/core/java/android/os/BatteryStats.java +++ b/core/java/android/os/BatteryStats.java @@ -531,7 +531,8 @@ public abstract class BatteryStats implements Parcelable { public final static class HistoryItem implements Parcelable { public HistoryItem next; - + + // The time of this event in milliseconds, as per SystemClock.elapsedRealtime(). public long time; public static final byte CMD_UPDATE = 0; // These can be written as deltas @@ -645,7 +646,7 @@ public abstract class BatteryStats implements Parcelable { public int eventCode; public HistoryTag eventTag; - // Only set for CMD_CURRENT_TIME. + // Only set for CMD_CURRENT_TIME or CMD_RESET, as per System.currentTimeMillis(). public long currentTime; // Meta-data when reading. diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java index 956c86d..8428f66 100644 --- a/core/java/com/android/internal/os/BatteryStatsImpl.java +++ b/core/java/com/android/internal/os/BatteryStatsImpl.java @@ -235,7 +235,8 @@ public final class BatteryStatsImpl extends BatteryStats { int mWakeLockNesting; boolean mWakeLockImportant; - public boolean mRecordAllWakeLocks; + boolean mRecordAllWakeLocks; + boolean mNoAutoReset; int mScreenState = Display.STATE_UNKNOWN; StopwatchTimer mScreenOnTimer; @@ -2314,9 +2315,6 @@ public final class BatteryStatsImpl extends BatteryStats { } } - private String mInitialAcquireWakeName; - private int mInitialAcquireWakeUid = -1; - public void setRecordAllWakeLocksLocked(boolean enabled) { mRecordAllWakeLocks = enabled; if (!enabled) { @@ -2325,6 +2323,13 @@ public final class BatteryStatsImpl extends BatteryStats { } } + public void setNoAutoReset(boolean enabled) { + mNoAutoReset = enabled; + } + + private String mInitialAcquireWakeName; + private int mInitialAcquireWakeUid = -1; + public void noteStartWakeLocked(int uid, int pid, String name, String historyName, int type, boolean unimportantForLogging, long elapsedRealtime, long uptime) { uid = mapUid(uid); @@ -2355,6 +2360,7 @@ public final class BatteryStatsImpl extends BatteryStats { } else if (mRecordAllWakeLocks) { if (mActiveEvents.updateState(HistoryItem.EVENT_WAKE_LOCK_START, historyName, uid, 0)) { + mWakeLockNesting++; return; } addHistoryEventLocked(elapsedRealtime, uptime, HistoryItem.EVENT_WAKE_LOCK_START, @@ -5942,9 +5948,9 @@ public final class BatteryStatsImpl extends BatteryStats { // we have gone through a significant charge (from a very low // level to a now very high level). boolean reset = false; - if (oldStatus == BatteryManager.BATTERY_STATUS_FULL + if (!mNoAutoReset && (oldStatus == BatteryManager.BATTERY_STATUS_FULL || level >= 90 - || (mDischargeCurrentLevel < 20 && level >= 80)) { + || (mDischargeCurrentLevel < 20 && level >= 80))) { doWrite = true; resetAllStatsLocked(); mDischargeStartLevel = level; |