Fix issue #15195464: battery history says wakelock held when it's not
Simplify full wake lock logging, so wake_lock_in is a completely separate event from wake_lock and provides the full real raw log of wake lock events. Also attempt to address issue #15018750 (Incorrect wakelock reporting) by no longer being complicated and rolling up previous state in to a new history slice. Bug: 15195464 Bug: 15018750 Change-Id: I32154bdfc2f07113be969f9db5503b2f2807a427
This commit is contained in:
@@ -2443,8 +2443,10 @@ public abstract class BatteryStats implements Parcelable {
|
||||
pw.print(prefix); pw.print(" Capacity: ");
|
||||
printmAh(pw, helper.getPowerProfile().getBatteryCapacity());
|
||||
pw.print(", Computed drain: "); printmAh(pw, helper.getComputedPower());
|
||||
pw.print(", Min drain: "); printmAh(pw, helper.getMinDrainedPower());
|
||||
pw.print(", Max drain: "); printmAh(pw, helper.getMaxDrainedPower());
|
||||
pw.print(", actual drain: "); printmAh(pw, helper.getMinDrainedPower());
|
||||
if (helper.getMinDrainedPower() != helper.getMaxDrainedPower()) {
|
||||
pw.print("-"); printmAh(pw, helper.getMaxDrainedPower());
|
||||
}
|
||||
pw.println();
|
||||
for (int i=0; i<sippers.size(); i++) {
|
||||
BatterySipper bs = sippers.get(i);
|
||||
@@ -3351,7 +3353,10 @@ public abstract class BatteryStats implements Parcelable {
|
||||
}
|
||||
hprinter.printNextItem(pw, rec, baseTime, checkin,
|
||||
(flags&DUMP_VERBOSE) != 0);
|
||||
} else if (rec.eventCode != HistoryItem.EVENT_NONE) {
|
||||
} else if (false && rec.eventCode != HistoryItem.EVENT_NONE) {
|
||||
// This is an attempt to aggregate the previous state and generate
|
||||
// fake events to reflect that state at the point where we start
|
||||
// printing real events. It doesn't really work right, so is turned off.
|
||||
if (tracker == null) {
|
||||
tracker = new HistoryEventTracker();
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user