Search in sources :

Example 16 with Chunk

use of org.apache.harmony.dalvik.ddmc.Chunk in project platform_frameworks_base by android.

the class DdmHandleViewDebug method dumpHierarchy.

/**
     * Returns the view hierarchy and/or view properties starting at the provided view.
     * Based on the input options, the return data may include:
     *  - just the view hierarchy
     *  - view hierarchy & the properties for each of the views
     *  - just the view properties for a specific view.
     *  TODO: Currently this only returns views starting at the root, need to fix so that
     *  it can return properties of any view.
     */
private Chunk dumpHierarchy(View rootView, ByteBuffer in) {
    boolean skipChildren = in.getInt() > 0;
    boolean includeProperties = in.getInt() > 0;
    boolean v2 = in.hasRemaining() && in.getInt() > 0;
    long start = System.currentTimeMillis();
    ByteArrayOutputStream b = new ByteArrayOutputStream(2 * 1024 * 1024);
    try {
        if (v2) {
            ViewDebug.dumpv2(rootView, b);
        } else {
            ViewDebug.dump(rootView, skipChildren, includeProperties, b);
        }
    } catch (IOException | InterruptedException e) {
        return createFailChunk(1, "Unexpected error while obtaining view hierarchy: " + e.getMessage());
    }
    long end = System.currentTimeMillis();
    Log.d(TAG, "Time to obtain view hierarchy (ms): " + (end - start));
    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 17 with Chunk

use of org.apache.harmony.dalvik.ddmc.Chunk in project platform_frameworks_base by android.

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 18 with Chunk

use of org.apache.harmony.dalvik.ddmc.Chunk in project platform_frameworks_base by android.

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 19 with Chunk

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

the class DdmHandleHello method handleHELO.

/*
     * Handle introductory packet.
     */
private Chunk handleHELO(Chunk request) {
    if (false)
        return createFailChunk(123, "This is a test");
    /*
         * Process the request.
         */
    ByteBuffer in = wrapChunk(request);
    int serverProtoVers = in.getInt();
    if (false)
        Log.v("ddm-hello", "Server version is " + serverProtoVers);
    /*
         * Create a response.
         */
    String vmName = System.getProperty("java.vm.name", "?");
    String vmVersion = System.getProperty("java.vm.version", "?");
    String vmIdent = vmName + " v" + vmVersion;
    //String appName = android.app.ActivityThread.currentPackageName();
    //if (appName == null)
    //    appName = "unknown";
    String appName = DdmHandleAppName.getAppName();
    ByteBuffer out = ByteBuffer.allocate(20 + vmIdent.length() * 2 + appName.length() * 2);
    out.order(ChunkHandler.CHUNK_ORDER);
    out.putInt(DdmServer.CLIENT_PROTOCOL_VERSION);
    out.putInt(android.os.Process.myPid());
    out.putInt(vmIdent.length());
    out.putInt(appName.length());
    putString(out, vmIdent);
    putString(out, appName);
    out.putInt(UserHandle.myUserId());
    Chunk reply = new Chunk(CHUNK_HELO, out);
    /*
         * Take the opportunity to inform DDMS if we are waiting for a
         * debugger to attach.
         */
    if (Debug.waitingForDebugger())
        sendWAIT(0);
    return reply;
}
Also used : Chunk(org.apache.harmony.dalvik.ddmc.Chunk) ByteBuffer(java.nio.ByteBuffer)

Example 20 with Chunk

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

the class DdmHandleThread method handleTHST.

/*
     * Handle a "THread STatus" request.  This is constructed by the VM.
     */
private Chunk handleTHST(Chunk request) {
    ByteBuffer in = wrapChunk(request);
    // currently nothing to read from "in"
    //Log.d("ddm-thread", "Thread status request");
    byte[] status = DdmVmInternal.getThreadStats();
    if (status != null)
        return new Chunk(CHUNK_THST, status, 0, status.length);
    else
        return createFailChunk(1, "Can't build THST 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