summaryrefslogtreecommitdiffstats
path: root/core/java/com
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2014-05-24 00:35:54 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-05-24 00:35:55 +0000
commita82c9be2f71c7fdd1aba2cc8ccb3e404886f8561 (patch)
tree58a8f9e39a1ec0e33e9f4279b256ff01113989b2 /core/java/com
parent0bfa56e76630647b7b277141d717ab434295ac5c (diff)
parent536456f2d4c0d93bb55950ce5edc24e9bb9547eb (diff)
downloadframeworks_base-a82c9be2f71c7fdd1aba2cc8ccb3e404886f8561.zip
frameworks_base-a82c9be2f71c7fdd1aba2cc8ccb3e404886f8561.tar.gz
frameworks_base-a82c9be2f71c7fdd1aba2cc8ccb3e404886f8561.tar.bz2
Merge "Fix issue #15195464: battery history says wakelock held when it's not" into lmp-preview-dev
Diffstat (limited to 'core/java/com')
-rw-r--r--core/java/com/android/internal/os/BatteryStatsImpl.java39
1 files changed, 14 insertions, 25 deletions
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index 24e55e4..ed9f9bc 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -2342,7 +2342,13 @@ 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);
- historyName = historyName == null || mRecordAllWakeLocks ? name : historyName;
+ if (mRecordAllWakeLocks) {
+ if (mActiveEvents.updateState(HistoryItem.EVENT_WAKE_LOCK_START, name, uid, 0)) {
+ addHistoryEventLocked(elapsedRealtime, uptime,
+ HistoryItem.EVENT_WAKE_LOCK_START, name, 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: "
@@ -2352,7 +2358,7 @@ public final class BatteryStatsImpl extends BatteryStats {
mHistoryCur.wakelockTag.uid = mInitialAcquireWakeUid = uid;
mWakeLockImportant = !unimportantForLogging;
addHistoryRecordLocked(elapsedRealtime, uptime);
- } else if (!mRecordAllWakeLocks && !mWakeLockImportant && !unimportantForLogging) {
+ } else if (!mWakeLockImportant && !unimportantForLogging) {
if (mHistoryLastWritten.wakelockTag != null) {
// We'll try to update the last tag.
mHistoryLastWritten.wakelockTag = null;
@@ -2362,14 +2368,6 @@ public final class BatteryStatsImpl extends BatteryStats {
addHistoryRecordLocked(elapsedRealtime, uptime);
}
mWakeLockImportant = true;
- } else if (mRecordAllWakeLocks) {
- if (mActiveEvents.updateState(HistoryItem.EVENT_WAKE_LOCK_START, historyName,
- uid, 0)) {
- mWakeLockNesting++;
- return;
- }
- addHistoryEventLocked(elapsedRealtime, uptime, HistoryItem.EVENT_WAKE_LOCK_START,
- historyName, uid);
}
mWakeLockNesting++;
}
@@ -2387,28 +2385,19 @@ public final class BatteryStatsImpl extends BatteryStats {
uid = mapUid(uid);
if (type == WAKE_TYPE_PARTIAL) {
mWakeLockNesting--;
- historyName = historyName == null || mRecordAllWakeLocks ? name : historyName;
+ if (mRecordAllWakeLocks) {
+ if (mActiveEvents.updateState(HistoryItem.EVENT_WAKE_LOCK_FINISH, name, uid, 0)) {
+ addHistoryEventLocked(elapsedRealtime, uptime,
+ HistoryItem.EVENT_WAKE_LOCK_FINISH, name, uid);
+ }
+ }
if (mWakeLockNesting == 0) {
mHistoryCur.states &= ~HistoryItem.STATE_WAKE_LOCK_FLAG;
if (DEBUG_HISTORY) Slog.v(TAG, "Stop wake lock to: "
+ Integer.toHexString(mHistoryCur.states));
- if (mRecordAllWakeLocks
- || (historyName != null && !historyName.equals(mInitialAcquireWakeName))
- || uid != mInitialAcquireWakeUid) {
- mHistoryCur.wakelockTag = mHistoryCur.localWakelockTag;
- mHistoryCur.wakelockTag.string = historyName;
- mHistoryCur.wakelockTag.uid = uid;
- }
mInitialAcquireWakeName = null;
mInitialAcquireWakeUid = -1;
addHistoryRecordLocked(elapsedRealtime, uptime);
- } else if (mRecordAllWakeLocks) {
- if (mActiveEvents.updateState(HistoryItem.EVENT_WAKE_LOCK_FINISH, historyName,
- uid, 0)) {
- return;
- }
- addHistoryEventLocked(elapsedRealtime, uptime, HistoryItem.EVENT_WAKE_LOCK_FINISH,
- historyName, uid);
}
}
if (uid >= 0) {