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

Commit a8ed28ba authored by Pablo Gamito's avatar Pablo Gamito
Browse files

Add WM API to start and stop transcation trace

Provides a way to eaily collect transaction traces from Flicker like is done for layer traces

Bug: 230462538
Test: collect transaction traces in Flicker using this API
Change-Id: Ie27cf60cac012af8fd23835cd0c6f0250dc72e42
parent a158b44d
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -748,6 +748,11 @@ interface IWindowManager
     */
    void setLayerTracingFlags(int flags);

    /**
     * Toggle active SurfaceFlinger transaction tracing.
     */
    void setActiveTransactionTracing(boolean active);

    /**
     * Forwards a scroll capture request to the appropriate window, if available.
     *
+35 −0
Original line number Diff line number Diff line
@@ -8764,6 +8764,41 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    /**
     * Toggle active transaction tracing.
     * Setting to true increases the buffer size for active debugging.
     * Setting to false resets the buffer size and dumps the trace to file.
     */
    public void setActiveTransactionTracing(boolean active) {
        if (!checkCallingPermission(
                android.Manifest.permission.DUMP, "setActiveTransactionTracing()")) {
            throw new SecurityException("Requires DUMP permission");
        }

        final long token = Binder.clearCallingIdentity();
        try {
            Parcel data = null;
            try {
                IBinder sf = ServiceManager.getService("SurfaceFlinger");
                if (sf != null) {
                    data = Parcel.obtain();
                    data.writeInterfaceToken("android.ui.ISurfaceComposer");
                    data.writeInt(active ? 1 : 0);
                    sf.transact(/* TRANSACTION_TRACE_CONTROL_CODE */ 1041, data,
                            null, 0 /* flags */);
                }
            } catch (RemoteException e) {
                Slog.e(TAG, "Failed to set transaction tracing");
            } finally {
                if (data != null) {
                    data.recycle();
                }
            }
        } finally {
            Binder.restoreCallingIdentity(token);
        }
    }

    @Override
    public boolean mirrorDisplay(int displayId, SurfaceControl outSurfaceControl) {
        if (!checkCallingPermission(READ_FRAME_BUFFER, "mirrorDisplay()")) {