Loading services/core/java/com/android/server/am/ActivityManagerService.java +9 −8 Original line number Original line Diff line number Diff line Loading @@ -5681,15 +5681,16 @@ public class ActivityManagerService extends IActivityManager.Stub * since it's the system_server that creates trace files for most ANRs. * since it's the system_server that creates trace files for most ANRs. */ */ private static void maybePruneOldTraces(File tracesDir) { private static void maybePruneOldTraces(File tracesDir) { final long now = System.currentTimeMillis(); final File[] files = tracesDir.listFiles(); final File[] traceFiles = tracesDir.listFiles(); if (files == null) return; if (traceFiles != null) { final int max = SystemProperties.getInt("tombstoned.max_anr_count", 64); for (File file : traceFiles) { final long now = System.currentTimeMillis(); if ((now - file.lastModified()) > DAY_IN_MILLIS) { Arrays.sort(files, Comparator.comparingLong(File::lastModified).reversed()); if (!file.delete()) { for (int i = 0; i < files.length; ++i) { Slog.w(TAG, "Unable to prune stale trace file: " + file); if (i > max || (now - files[i].lastModified()) > DAY_IN_MILLIS) { } if (!files[i].delete()) { Slog.w(TAG, "Unable to prune stale trace file: " + files[i]); } } } } } } Loading
services/core/java/com/android/server/am/ActivityManagerService.java +9 −8 Original line number Original line Diff line number Diff line Loading @@ -5681,15 +5681,16 @@ public class ActivityManagerService extends IActivityManager.Stub * since it's the system_server that creates trace files for most ANRs. * since it's the system_server that creates trace files for most ANRs. */ */ private static void maybePruneOldTraces(File tracesDir) { private static void maybePruneOldTraces(File tracesDir) { final long now = System.currentTimeMillis(); final File[] files = tracesDir.listFiles(); final File[] traceFiles = tracesDir.listFiles(); if (files == null) return; if (traceFiles != null) { final int max = SystemProperties.getInt("tombstoned.max_anr_count", 64); for (File file : traceFiles) { final long now = System.currentTimeMillis(); if ((now - file.lastModified()) > DAY_IN_MILLIS) { Arrays.sort(files, Comparator.comparingLong(File::lastModified).reversed()); if (!file.delete()) { for (int i = 0; i < files.length; ++i) { Slog.w(TAG, "Unable to prune stale trace file: " + file); if (i > max || (now - files[i].lastModified()) > DAY_IN_MILLIS) { } if (!files[i].delete()) { Slog.w(TAG, "Unable to prune stale trace file: " + files[i]); } } } } } }