Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bebb3010 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Prevent IndexOutOfBoundsException when trimming the battery history directory" into main

parents 2a20688d 78596ce7
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -505,7 +505,9 @@ public class BatteryHistoryDirectory implements BatteryStatsHistory.BatteryHisto
                for (int i = 0; i < mHistoryFiles.size(); i++) {
                    size += (int) mHistoryFiles.get(i).atomicFile.getBaseFile().length();
                }
                while (size > mMaxHistorySize) {
                // Trim until the directory size is within the limit or there is just one most
                // recent file left in the directory
                while (size > mMaxHistorySize && mHistoryFiles.size() > 1) {
                    BatteryHistoryFile oldest = mHistoryFiles.get(0);
                    int length = (int) oldest.atomicFile.getBaseFile().length();
                    oldest.atomicFile.delete();