Search in sources :

Example 56 with Chunk

use of org.apache.harmony.dalvik.ddmc.Chunk in project android_frameworks_base by DirtyUnicorns.

the class DdmHandleViewDebug method profileView.

/** Profiles provided view. */
private Chunk profileView(View rootView, final View targetView) {
    ByteArrayOutputStream b = new ByteArrayOutputStream(32 * 1024);
    BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(b), 32 * 1024);
    try {
        ViewDebug.profileViewAndChildren(targetView, bw);
    } catch (IOException e) {
        return createFailChunk(1, "Unexpected error while profiling view: " + e.getMessage());
    } finally {
        try {
            bw.close();
        } catch (IOException e) {
        // ignore
        }
    }
    byte[] data = b.toByteArray();
    return new Chunk(CHUNK_VUOP, data, 0, data.length);
}
Also used : OutputStreamWriter(java.io.OutputStreamWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) Chunk(org.apache.harmony.dalvik.ddmc.Chunk) BufferedWriter(java.io.BufferedWriter)

Example 57 with Chunk

use of org.apache.harmony.dalvik.ddmc.Chunk in project android_frameworks_base by DirtyUnicorns.

the class DdmHandleViewDebug method captureView.

private Chunk captureView(View rootView, View targetView) {
    ByteArrayOutputStream b = new ByteArrayOutputStream(1024);
    try {
        ViewDebug.capture(rootView, b, targetView);
    } catch (IOException e) {
        return createFailChunk(1, "Unexpected error while capturing view: " + e.getMessage());
    }
    byte[] data = b.toByteArray();
    return new Chunk(CHUNK_VUOP, data, 0, data.length);
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) Chunk(org.apache.harmony.dalvik.ddmc.Chunk)

Example 58 with Chunk

use of org.apache.harmony.dalvik.ddmc.Chunk in project android_frameworks_base by DirtyUnicorns.

the class DdmHandleViewDebug method captureLayers.

/** Returns a buffer with region details & bitmap of every single view. */
private Chunk captureLayers(View rootView) {
    ByteArrayOutputStream b = new ByteArrayOutputStream(1024);
    DataOutputStream dos = new DataOutputStream(b);
    try {
        ViewDebug.captureLayers(rootView, dos);
    } catch (IOException e) {
        return createFailChunk(1, "Unexpected error while obtaining view hierarchy: " + e.getMessage());
    } finally {
        try {
            dos.close();
        } catch (IOException e) {
        // ignore
        }
    }
    byte[] data = b.toByteArray();
    return new Chunk(CHUNK_VURT, data, 0, data.length);
}
Also used : DataOutputStream(java.io.DataOutputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) Chunk(org.apache.harmony.dalvik.ddmc.Chunk)

Example 59 with Chunk

use of org.apache.harmony.dalvik.ddmc.Chunk in project android_frameworks_base by DirtyUnicorns.

the class DdmHandleViewDebug method dumpTheme.

/**
     * 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);
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) Chunk(org.apache.harmony.dalvik.ddmc.Chunk)

Example 60 with Chunk

use of org.apache.harmony.dalvik.ddmc.Chunk in project android_frameworks_base by DirtyUnicorns.

the class DdmHandleAppName method sendAPNM.

/*
     * Send an APNM (APplication NaMe) chunk.
     */
private static void sendAPNM(String appName, int userId) {
    if (false)
        Log.v("ddm", "Sending app name");
    ByteBuffer out = ByteBuffer.allocate(4 + /* appName's length */
    appName.length() * 2 + /* appName */
    4);
    out.order(ChunkHandler.CHUNK_ORDER);
    out.putInt(appName.length());
    putString(out, appName);
    out.putInt(userId);
    Chunk chunk = new Chunk(CHUNK_APNM, out);
    DdmServer.sendChunk(chunk);
}
Also used : Chunk(org.apache.harmony.dalvik.ddmc.Chunk) ByteBuffer(java.nio.ByteBuffer)

Aggregations

Chunk (org.apache.harmony.dalvik.ddmc.Chunk)98 ByteBuffer (java.nio.ByteBuffer)48 IOException (java.io.IOException)36 ByteArrayOutputStream (java.io.ByteArrayOutputStream)29 BufferedWriter (java.io.BufferedWriter)6 DataOutputStream (java.io.DataOutputStream)6 OutputStreamWriter (java.io.OutputStreamWriter)6 VMRuntime (dalvik.system.VMRuntime)5