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

Commit 2d103db6 authored by Andreas Gampe's avatar Andreas Gampe Committed by android-build-merger
Browse files

Merge "ActivityManager: Fix slow-app ANR dumping" am: 923208e8 am: 2d47ac0d

am: 1c015160

Change-Id: Id3bd33caa4137b36b7ead74689bf2c0aaa09e3d4
parents f02176f3 1c015160
Loading
Loading
Loading
Loading
+6 −16
Original line number Diff line number Diff line
@@ -6303,22 +6303,15 @@ public class ActivityManagerService extends IActivityManager.Stub
        if (true || Build.IS_USER) {
            return;
        }
        String tracesPath = SystemProperties.get("dalvik.vm.stack-trace-file", null);
        if (tracesPath == null || tracesPath.length() == 0) {
            return;
        }
        StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
        StrictMode.allowThreadDiskWrites();
        try {
            final File tracesFile = new File(tracesPath);
            final File tracesDir = tracesFile.getParentFile();
            final File tracesTmp = new File(tracesDir, "__tmp__");
            File tracesDir = new File("/data/anr");
            File tracesFile = null;
            try {
                if (tracesFile.exists()) {
                    tracesTmp.delete();
                    tracesFile.renameTo(tracesTmp);
                }
                tracesFile = File.createTempFile("app_slow", null, tracesDir);
                StringBuilder sb = new StringBuilder();
                Time tobj = new Time();
                tobj.set(System.currentTimeMillis());
@@ -6335,14 +6328,14 @@ public class ActivityManagerService extends IActivityManager.Stub
                fos.close();
                FileUtils.setPermissions(tracesFile.getPath(), 0666, -1, -1); // -rw-rw-rw-
            } 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;
            }
            if (app != null && app.pid > 0) {
                ArrayList<Integer> firstPids = new ArrayList<Integer>();
                firstPids.add(app.pid);
                dumpStackTraces(tracesPath, firstPids, null, null);
                dumpStackTraces(tracesFile.getAbsolutePath(), firstPids, null, null);
            }
            File lastTracesFile = null;
@@ -6360,9 +6353,6 @@ public class ActivityManagerService extends IActivityManager.Stub
                lastTracesFile = curTracesFile;
            }
            tracesFile.renameTo(curTracesFile);
            if (tracesTmp.exists()) {
                tracesTmp.renameTo(tracesFile);
            }
        } finally {
            StrictMode.setThreadPolicy(oldPolicy);
        }