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

Commit 583a7660 authored by Jon Miranda's avatar Jon Miranda Committed by Android Git Automerger
Browse files

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

* commit 'bff124f1e86a6cfc1710d41bedd060b7378de06b':
  Adds support for Theme dumping via DDM.
parents edfef021 3c7f018f
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 {