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

Commit 3c7f018f authored by Jon Miranda's avatar Jon Miranda Committed by Android (Google) Code Review
Browse files

Merge "Adds support for Theme dumping via DDM." into lmp-dev

parents 7e3d6c98 e82a4eeb
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -56,6 +56,9 @@ public class DdmHandleViewDebug extends ChunkHandler {
    /** Capture View Layers. */
    private static final int VURT_CAPTURE_LAYERS = 2;

    /** Dump View Theme. */
    private static final int VURT_DUMP_THEME = 3;

    /**
     * Generic View Operation, first parameter in the packet should be one of the
     * VUOP_* constants below.
@@ -131,6 +134,8 @@ public class DdmHandleViewDebug extends ChunkHandler {
                return dumpHierarchy(rootView, in);
            else if (op == VURT_CAPTURE_LAYERS)
                return captureLayers(rootView);
            else if (op == VURT_DUMP_THEME)
                return dumpTheme(rootView);
            else
                return createFailChunk(ERR_INVALID_OP, "Unknown view root operation: " + op);
        }
@@ -258,6 +263,22 @@ public class DdmHandleViewDebug extends ChunkHandler {
        return new Chunk(CHUNK_VURT, data, 0, data.length);
    }

    /**
     * Returns the Theme dump of the provided view.
     */
    private Chunk dumpTheme(View rootView) {
        ByteArrayOutputStream b = new ByteArrayOutputStream(1024);
        try {
            ViewDebug.dumpTheme(rootView, b);
        } catch (IOException e) {
            return createFailChunk(1, "Unexpected error while dumping the theme: "
                    + e.getMessage());
        }

        byte[] data = b.toByteArray();
        return new Chunk(CHUNK_VURT, data, 0, data.length);
    }

    private Chunk captureView(View rootView, View targetView) {
        ByteArrayOutputStream b = new ByteArrayOutputStream(1024);
        try {