Skip to content

Commit 45f0646

Browse files
author
Amith Yamasani
committed
Fix an NPE on overflow in BatteryStats history.
When the battery stats buffer hits 128KB, it hits a code path that causes an NPE. This can happen depending on usage and charging patterns and manifest in bad ways, such as failure to boot up or random crashes, or refusing to go to sleep. Bug: 5645407 Change-Id: I21d5d189431f776f25bcb7d598c86e598ad8cb17
1 parent 85c7394 commit 45f0646

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

core/java/com/android/internal/os/BatteryStatsImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,7 @@ void addHistoryBufferLocked(long curTime) {
12751275
// record changes to the battery level.
12761276
if (mHistoryLastWritten.batteryLevel == mHistoryCur.batteryLevel &&
12771277
(dataSize >= MAX_MAX_HISTORY_BUFFER
1278-
|| ((mHistoryEnd.states^mHistoryCur.states)
1278+
|| ((mHistoryLastWritten.states^mHistoryCur.states)
12791279
& HistoryItem.MOST_INTERESTING_STATES) == 0)) {
12801280
return;
12811281
}

0 commit comments

Comments
 (0)