Search in sources :

Example 36 with Chunk

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

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

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

the class DdmHandleHello method connected.

/**
     * Called when the DDM server connects.  The handler is allowed to
     * send messages to the server.
     */
public void connected() {
    if (false)
        Log.v("ddm-hello", "Connected!");
    if (false) {
        /* test spontaneous transmission */
        byte[] data = new byte[] { 0, 1, 2, 3, 4, -4, -3, -2, -1, 127 };
        Chunk testChunk = new Chunk(ChunkHandler.type("TEST"), data, 1, data.length - 2);
        DdmServer.sendChunk(testChunk);
    }
}
Also used : Chunk(org.apache.harmony.dalvik.ddmc.Chunk)

Example 38 with Chunk

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

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

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

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

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

the class DdmHandleHello method handleHELO.

/*
     * Handle introductory packet. This is called during JNI_CreateJavaVM
     * before frameworks native methods are registered, so be careful not
     * to call any APIs that depend on frameworks native code.
     */
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();
    VMRuntime vmRuntime = VMRuntime.getRuntime();
    String instructionSetDescription = vmRuntime.is64Bit() ? "64-bit" : "32-bit";
    String vmInstructionSet = vmRuntime.vmInstructionSet();
    if (vmInstructionSet != null && vmInstructionSet.length() > 0) {
        instructionSetDescription += " (" + vmInstructionSet + ")";
    }
    String vmFlags = "CheckJNI=" + (vmRuntime.isCheckJniEnabled() ? "true" : "false");
    boolean isNativeDebuggable = vmRuntime.isNativeDebuggable();
    ByteBuffer out = ByteBuffer.allocate(28 + vmIdent.length() * 2 + appName.length() * 2 + instructionSetDescription.length() * 2 + vmFlags.length() * 2 + 1);
    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());
    out.putInt(instructionSetDescription.length());
    putString(out, instructionSetDescription);
    out.putInt(vmFlags.length());
    putString(out, vmFlags);
    out.put((byte) (isNativeDebuggable ? 1 : 0));
    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 : VMRuntime(dalvik.system.VMRuntime) 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