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

Commit e82a4eeb authored by Jon Miranda's avatar Jon Miranda
Browse files

Adds support for Theme dumping via DDM.

Bug: 17515415
Change-Id: Ice145a4b452177e36345cf2e071377bb7b3feeb3
parent 7c744bdb
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 {