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

Commit 56f10484 authored by Simon MacMullen's avatar Simon MacMullen Committed by Android (Google) Code Review
Browse files

Merge "Add CPU usage data to system server watchdog events."

parents 98d85060 dfc56be7
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -39,8 +39,10 @@ import android.system.StructRlimit;
import android.util.EventLog;
import android.util.Log;
import android.util.Slog;
import android.util.SparseArray;
import android.util.StatsLog;

import com.android.internal.os.ProcessCpuTracker;
import com.android.internal.os.ZygoteConnectionConstants;
import com.android.server.am.ActivityManagerService;
import com.android.server.wm.SurfaceAnimationThread;
@@ -606,13 +608,18 @@ public class Watchdog extends Thread {
            pids.add(Process.myPid());
            if (mPhonePid > 0) pids.add(mPhonePid);

            long anrTime = SystemClock.uptimeMillis();
            ProcessCpuTracker processCpuTracker = new ProcessCpuTracker(false);
            final File stack = ActivityManagerService.dumpStackTraces(
                    pids, null, null, getInterestingNativePids());
                    pids, processCpuTracker, new SparseArray<>(), getInterestingNativePids());

            // Give some extra time to make sure the stack traces get written.
            // The system's been hanging for a minute, another second or two won't hurt much.
            SystemClock.sleep(5000);

            processCpuTracker.update();
            String cpuInfo = processCpuTracker.printCurrentState(anrTime);

            // Trigger the kernel to dump all blocked threads, and backtraces on all CPUs to the kernel log
            doSysRq('w');
            doSysRq('l');
@@ -627,7 +634,7 @@ public class Watchdog extends Thread {
                        if (mActivity != null) {
                            mActivity.addErrorToDropBox(
                                    "watchdog", null, "system_server", null, null, null,
                                    subject, null, stack, null);
                                    subject, cpuInfo, stack, null);
                        }
                        StatsLog.write(StatsLog.SYSTEM_SERVER_WATCHDOG_OCCURRED, subject);
                    }