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

Commit cfdb7804 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "frameworks/base: creating separate files for ANRs traces based on debug flag"

parents 4e760828 d13eae5d
Loading
Loading
Loading
Loading
+20 −2
Original line number Diff line number Diff line
@@ -51,7 +51,8 @@ import android.util.Log;
import android.util.Slog;
import android.util.SparseArray;
import android.util.TimeUtils;

import java.util.Date;
import java.text.SimpleDateFormat;
import java.io.File;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -76,7 +77,7 @@ class AppErrors {

    private final ActivityManagerService mService;
    private final Context mContext;

    SimpleDateFormat mTraceDateFormat = new SimpleDateFormat("dd_MMM_HH_mm_ss.SSS");
    private ArraySet<String> mAppsNotReportingCrashes;

    /**
@@ -886,6 +887,23 @@ class AppErrors {
                    annotation != null ? "ANR " + annotation : "ANR",
                    info.toString());

            boolean enableTraceRename = SystemProperties.getBoolean("persist.sys.enableTraceRename", false);
            //Set the trace file name to app name + current date format to avoid overrinding trace file based on debug flag
            if(enableTraceRename) {
                String tracesPath = SystemProperties.get("dalvik.vm.stack-trace-file", null);
                if (tracesPath != null && tracesPath.length() != 0) {
                    File traceRenameFile = new File(tracesPath);
                    String newTracesPath;
                    int lpos = tracesPath.lastIndexOf (".");
                    if (-1 != lpos)
                        newTracesPath = tracesPath.substring (0, lpos) + "_" + app.processName + "_" + mTraceDateFormat.format(new Date()) + tracesPath.substring (lpos);
                    else
                        newTracesPath = tracesPath + "_" + app.processName;

                    traceRenameFile.renameTo(new File(newTracesPath));
                    SystemClock.sleep(1000);
                }
            }
            // Bring up the infamous App Not Responding dialog
            Message msg = Message.obtain();
            HashMap<String, Object> map = new HashMap<String, Object>();