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

Commit 91e028dc authored by Vishnu Nair's avatar Vishnu Nair Committed by Android (Google) Code Review
Browse files

Merge "Add window tracing functions to WindowMangerService"

parents 39a57e7a c961504b
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -396,4 +396,19 @@ interface IWindowManager
     * Return the touch region for the current IME window, or an empty region if there is none.
     */
    Region getCurrentImeTouchRegion();

    /**
     * Starts a window trace.
     */
    void startWindowTrace();

    /**
     * Stops a window trace.
     */
    void stopWindowTrace();

    /**
     * Returns true if window trace is enabled.
     */
    boolean isWindowTraceEnabled();
}
+19 −0
Original line number Diff line number Diff line
@@ -5327,6 +5327,25 @@ public class WindowManagerService extends IWindowManager.Stub
        reconfigureDisplayLocked(displayContent);
    }

    @Override
    public void startWindowTrace(){
        try {
            mWindowTracing.startTrace(null /* printwriter */);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public void stopWindowTrace(){
        mWindowTracing.stopTrace(null /* printwriter */);
    }

    @Override
    public boolean isWindowTraceEnabled() {
        return mWindowTracing.isEnabled();
    }

    // -------------------------------------------------------------
    // Internals
    // -------------------------------------------------------------
+8 −5
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.content.Context;
import android.os.ShellCommand;
import android.os.SystemClock;
import android.os.Trace;
import android.annotation.Nullable;
import android.util.Log;
import android.util.proto.ProtoOutputStream;

@@ -62,7 +63,7 @@ class WindowTracing {
        mTraceFile = file;
    }

    void startTrace(PrintWriter pw) throws IOException {
    void startTrace(@Nullable PrintWriter pw) throws IOException {
        if (IS_USER){
            logAndPrintln(pw, "Error: Tracing is not supported on user builds.");
            return;
@@ -81,13 +82,15 @@ class WindowTracing {
        }
    }

    private void logAndPrintln(PrintWriter pw, String msg) {
    private void logAndPrintln(@Nullable PrintWriter pw, String msg) {
        Log.i(TAG, msg);
        if (pw != null) {
            pw.println(msg);
            pw.flush();
        }
    }

    void stopTrace(PrintWriter pw) {
    void stopTrace(@Nullable PrintWriter pw) {
        if (IS_USER){
            logAndPrintln(pw, "Error: Tracing is not supported on user builds.");
            return;