Reset STATE2_EXTENSIONS_FLAG when unused and on every new buffer

Bug: 244500357
Test: atest FrameworksServicesTests:BatteryStatsTests
Change-Id: Iaaedf2c47c982855bcc66b2673a6c82281c93d0a
This commit is contained in:
Dmitri Plotnikov
2022-08-30 17:49:45 -07:00
parent f437c2c252
commit 3d1fd42292

View File

@@ -1235,6 +1235,8 @@ public class BatteryStatsHistory {
for (Map.Entry<HistoryTag, Integer> entry : mHistoryTagPool.entrySet()) {
entry.setValue(entry.getValue() | BatteryStatsHistory.TAG_FIRST_OCCURRENCE_FLAG);
}
mMeasuredEnergyHeaderWritten = false;
// Make a copy of mHistoryCur.
HistoryItem copy = new HistoryItem();
copy.setTo(cur);
@@ -1400,6 +1402,8 @@ public class BatteryStatsHistory {
}
if (extensionFlags != 0) {
cur.states2 |= HistoryItem.STATE2_EXTENSIONS_FLAG;
} else {
cur.states2 &= ~HistoryItem.STATE2_EXTENSIONS_FLAG;
}
final boolean state2IntChanged = cur.states2 != last.states2;
if (state2IntChanged) {