Loading services/core/java/com/android/server/am/ActivityManagerService.java +6 −16 Original line number Original line Diff line number Diff line Loading @@ -5772,22 +5772,15 @@ public class ActivityManagerService extends IActivityManager.Stub if (true || Build.IS_USER) { if (true || Build.IS_USER) { return; return; } } String tracesPath = SystemProperties.get("dalvik.vm.stack-trace-file", null); if (tracesPath == null || tracesPath.length() == 0) { return; } StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); StrictMode.allowThreadDiskWrites(); StrictMode.allowThreadDiskWrites(); try { try { final File tracesFile = new File(tracesPath); File tracesDir = new File("/data/anr"); final File tracesDir = tracesFile.getParentFile(); File tracesFile = null; final File tracesTmp = new File(tracesDir, "__tmp__"); try { try { if (tracesFile.exists()) { tracesFile = File.createTempFile("app_slow", null, tracesDir); tracesTmp.delete(); tracesFile.renameTo(tracesTmp); } StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder(); Time tobj = new Time(); Time tobj = new Time(); tobj.set(System.currentTimeMillis()); tobj.set(System.currentTimeMillis()); Loading @@ -5804,14 +5797,14 @@ public class ActivityManagerService extends IActivityManager.Stub fos.close(); fos.close(); FileUtils.setPermissions(tracesFile.getPath(), 0666, -1, -1); // -rw-rw-rw- FileUtils.setPermissions(tracesFile.getPath(), 0666, -1, -1); // -rw-rw-rw- } catch (IOException e) { } catch (IOException e) { Slog.w(TAG, "Unable to prepare slow app traces file: " + tracesPath, e); Slog.w(TAG, "Unable to prepare slow app traces file: " + tracesFile, e); return; return; } } if (app != null) { if (app != null) { ArrayList<Integer> firstPids = new ArrayList<Integer>(); ArrayList<Integer> firstPids = new ArrayList<Integer>(); firstPids.add(app.pid); firstPids.add(app.pid); dumpStackTraces(tracesPath, firstPids, null, null); dumpStackTraces(tracesFile.getAbsolutePath(), firstPids, null, null); } } File lastTracesFile = null; File lastTracesFile = null; Loading @@ -5829,9 +5822,6 @@ public class ActivityManagerService extends IActivityManager.Stub lastTracesFile = curTracesFile; lastTracesFile = curTracesFile; } } tracesFile.renameTo(curTracesFile); tracesFile.renameTo(curTracesFile); if (tracesTmp.exists()) { tracesTmp.renameTo(tracesFile); } } finally { } finally { StrictMode.setThreadPolicy(oldPolicy); StrictMode.setThreadPolicy(oldPolicy); } } Loading
services/core/java/com/android/server/am/ActivityManagerService.java +6 −16 Original line number Original line Diff line number Diff line Loading @@ -5772,22 +5772,15 @@ public class ActivityManagerService extends IActivityManager.Stub if (true || Build.IS_USER) { if (true || Build.IS_USER) { return; return; } } String tracesPath = SystemProperties.get("dalvik.vm.stack-trace-file", null); if (tracesPath == null || tracesPath.length() == 0) { return; } StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); StrictMode.allowThreadDiskWrites(); StrictMode.allowThreadDiskWrites(); try { try { final File tracesFile = new File(tracesPath); File tracesDir = new File("/data/anr"); final File tracesDir = tracesFile.getParentFile(); File tracesFile = null; final File tracesTmp = new File(tracesDir, "__tmp__"); try { try { if (tracesFile.exists()) { tracesFile = File.createTempFile("app_slow", null, tracesDir); tracesTmp.delete(); tracesFile.renameTo(tracesTmp); } StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder(); Time tobj = new Time(); Time tobj = new Time(); tobj.set(System.currentTimeMillis()); tobj.set(System.currentTimeMillis()); Loading @@ -5804,14 +5797,14 @@ public class ActivityManagerService extends IActivityManager.Stub fos.close(); fos.close(); FileUtils.setPermissions(tracesFile.getPath(), 0666, -1, -1); // -rw-rw-rw- FileUtils.setPermissions(tracesFile.getPath(), 0666, -1, -1); // -rw-rw-rw- } catch (IOException e) { } catch (IOException e) { Slog.w(TAG, "Unable to prepare slow app traces file: " + tracesPath, e); Slog.w(TAG, "Unable to prepare slow app traces file: " + tracesFile, e); return; return; } } if (app != null) { if (app != null) { ArrayList<Integer> firstPids = new ArrayList<Integer>(); ArrayList<Integer> firstPids = new ArrayList<Integer>(); firstPids.add(app.pid); firstPids.add(app.pid); dumpStackTraces(tracesPath, firstPids, null, null); dumpStackTraces(tracesFile.getAbsolutePath(), firstPids, null, null); } } File lastTracesFile = null; File lastTracesFile = null; Loading @@ -5829,9 +5822,6 @@ public class ActivityManagerService extends IActivityManager.Stub lastTracesFile = curTracesFile; lastTracesFile = curTracesFile; } } tracesFile.renameTo(curTracesFile); tracesFile.renameTo(curTracesFile); if (tracesTmp.exists()) { tracesTmp.renameTo(tracesFile); } } finally { } finally { StrictMode.setThreadPolicy(oldPolicy); StrictMode.setThreadPolicy(oldPolicy); } }