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

Commit cd7ee3d8 authored by Olivier Gaillard's avatar Olivier Gaillard
Browse files

Add the timestamp of when the ANR was trigger.

It will help to better correlate log entries to the crash event. The header matches what we do for tombstones (except we do not have nano resolution)

Bug: 326067829
Change-Id: I9c297a4d73d3f5f78f18619b3c67e68b17c7f328
parent 36c28755
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -64,6 +64,9 @@ import com.android.server.wm.WindowProcessController;
import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
@@ -76,6 +79,9 @@ import java.util.concurrent.atomic.AtomicLong;
 * The error state of the process, such as if it's crashing/ANR etc.
 */
class ProcessErrorStateRecord {
    private static final DateTimeFormatter DROPBOX_TIME_FORMATTER =
            DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSZ");

    final ProcessRecord mApp;
    private final ActivityManagerService mService;

@@ -444,6 +450,13 @@ class ProcessErrorStateRecord {
            info.append("ErrorId: ").append(errorId.toString()).append("\n");
        }
        info.append("Frozen: ").append(mApp.mOptRecord.isFrozen()).append("\n");
        if (timeoutRecord != null && timeoutRecord.mEndUptimeMillis > 0) {
            long millisSinceEndUptimeMs = anrTime - timeoutRecord.mEndUptimeMillis;
            String formattedTime = DROPBOX_TIME_FORMATTER.format(
                    Instant.now().minusMillis(millisSinceEndUptimeMs)
                            .atZone(ZoneId.systemDefault()));
            info.append("Timestamp: ").append(formattedTime).append("\n");
        }

        // Retrieve controller with max ANR delay from AnrControllers
        // Note that we retrieve the controller before dumping stacks because dumping stacks can