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

Commit c961504b authored by Vishnu Nair's avatar Vishnu Nair
Browse files

Add window tracing functions to WindowMangerService

Bug: 64831661
Test: Toggle window trace from new QS Tile
Change-Id: I34f9604e9af8f1d901245c9bb7a733c01ad86ecc
parent 33487775
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
@@ -5326,6 +5326,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;