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

Commit 0023356f authored by Elliott Hughes's avatar Elliott Hughes
Browse files

maybePruneOldTraces: bail if modification times change.

We could implement the right thing easily with streams, but we're not
allowed to use streams in this context, and it doesn't seem worth the
bother of doing it any of the hard ways, given that we've only seen this
once in the year the code's been doing this.

Bug: https://issuetracker.google.com/169836837
Test: treehugger
Change-Id: I4ee29916c1b335bebecfe7f72e74ff71e8a24228
parent c4099ac0
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -4060,6 +4060,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        final int max = SystemProperties.getInt("tombstoned.max_anr_count", 64);
        final long now = System.currentTimeMillis();
        try {
            Arrays.sort(files, Comparator.comparingLong(File::lastModified).reversed());
            for (int i = 0; i < files.length; ++i) {
                if (i > max || (now - files[i].lastModified()) > DAY_IN_MILLIS) {
@@ -4068,6 +4069,11 @@ public class ActivityManagerService extends IActivityManager.Stub
                    }
                }
            }
        } catch (IllegalArgumentException e) {
            // The modification times changed while we were sorting. Bail...
            // https://issuetracker.google.com/169836837
            Slog.w(TAG, "tombstone modification times changed while sorting; not pruning", e);
        }
    }
    /**