Merge "maybePruneOldTraces: bail if modification times change." am: 9144eaf12f am: 72d2a3f7cc am: 69de46ba86
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1712554 Change-Id: I783858d1215dae38814d67dc9b7c88233a9c6d91
This commit is contained in:
@@ -3287,13 +3287,19 @@ public class ActivityManagerService extends IActivityManager.Stub
|
|||||||
|
|
||||||
final int max = SystemProperties.getInt("tombstoned.max_anr_count", 64);
|
final int max = SystemProperties.getInt("tombstoned.max_anr_count", 64);
|
||||||
final long now = System.currentTimeMillis();
|
final long now = System.currentTimeMillis();
|
||||||
Arrays.sort(files, Comparator.comparingLong(File::lastModified).reversed());
|
try {
|
||||||
for (int i = 0; i < files.length; ++i) {
|
Arrays.sort(files, Comparator.comparingLong(File::lastModified).reversed());
|
||||||
if (i > max || (now - files[i].lastModified()) > DAY_IN_MILLIS) {
|
for (int i = 0; i < files.length; ++i) {
|
||||||
if (!files[i].delete()) {
|
if (i > max || (now - files[i].lastModified()) > DAY_IN_MILLIS) {
|
||||||
Slog.w(TAG, "Unable to prune stale trace file: " + files[i]);
|
if (!files[i].delete()) {
|
||||||
|
Slog.w(TAG, "Unable to prune stale trace file: " + files[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user