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

Commit 98a3f121 authored by Olivier Gaillard's avatar Olivier Gaillard Committed by Android (Google) Code Review
Browse files

Merge "Add the timestamp of when the ANR was trigger." into main

parents c73e2e20 cd7ee3d8
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