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

Commit f163c211 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add systrace dump to the critical section of the bugreport"

parents 4876191c 9e260468
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -232,6 +232,7 @@ import android.view.WindowManagerPolicyConstants.PointerEventListener;

import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.BackgroundThread;
import com.android.internal.os.IResultReceiver;
import com.android.internal.policy.IKeyguardDismissCallback;
import com.android.internal.policy.IShortcutService;
@@ -414,6 +415,14 @@ public class WindowManagerService extends IWindowManager.Stub
        @Override
        public void dumpCritical(FileDescriptor fd, PrintWriter pw, String[] args,
                boolean asProto) {
            // Bugreport dumps the trace 2x, 1x as proto and 1x as text. Save file to disk only 1x.
            if (asProto && mWindowTracing.isEnabled()) {
                mWindowTracing.stopTrace(null, false /* writeToFile */);
                BackgroundThread.getHandler().post(() -> {
                    mWindowTracing.writeTraceToFile();
                    mWindowTracing.startTrace(null);
                });
            }
            doDump(fd, pw, new String[] {"-a"}, asProto);
        }

@@ -6182,9 +6191,6 @@ public class WindowManagerService extends IWindowManager.Stub
                return;
            } else if ("trace".equals(cmd)) {
                dumpTraceStatus(pw);
                synchronized (mGlobalLock) {
                    mWindowTracing.writeTraceToFile();
                }
                return;
            } else {
                // Dumping a single name?
+17 −2
Original line number Diff line number Diff line
@@ -100,7 +100,20 @@ class WindowTracing {
        }
    }

    /**
     * Stops the trace and write the current buffer to disk
     * @param pw Print writer
     */
    void stopTrace(@Nullable PrintWriter pw) {
        stopTrace(pw, true /* writeToFile */);
    }

    /**
     * Stops the trace
     * @param pw Print writer
     * @param writeToFile If the current buffer should be written to disk or not
     */
    void stopTrace(@Nullable PrintWriter pw, boolean writeToFile) {
        if (IS_USER) {
            logAndPrintln(pw, "Error: Tracing is not supported on user builds.");
            return;
@@ -113,10 +126,12 @@ class WindowTracing {
                logAndPrintln(pw, "ERROR: tracing was re-enabled while waiting for flush.");
                throw new IllegalStateException("tracing enabled while waiting for flush.");
            }
            if (writeToFile) {
                writeTraceToFileLocked();
                logAndPrintln(pw, "Trace written to " + mTraceFile + ".");
            }
        }
    }

    private void setLogLevel(@WindowTraceLogLevel int logLevel, PrintWriter pw) {
        logAndPrintln(pw, "Setting window tracing log level to " + logLevel);