use of org.apache.harmony.dalvik.ddmc.Chunk in project platform_frameworks_base by android.
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);
}
}
use of org.apache.harmony.dalvik.ddmc.Chunk in project platform_frameworks_base by android.
the class DdmHandleThread method createStackChunk.
/*
* Serialize a StackTraceElement[] into an STKL chunk.
*
* We include the threadId in the response so the other side doesn't have
* to match up requests and responses as carefully.
*/
private Chunk createStackChunk(StackTraceElement[] trace, int threadId) {
int bufferSize = 0;
// version, flags, whatever
bufferSize += 4;
// thread ID
bufferSize += 4;
// frame count
bufferSize += 4;
for (StackTraceElement elem : trace) {
bufferSize += 4 + elem.getClassName().length() * 2;
bufferSize += 4 + elem.getMethodName().length() * 2;
bufferSize += 4;
if (elem.getFileName() != null)
bufferSize += elem.getFileName().length() * 2;
// line number
bufferSize += 4;
}
ByteBuffer out = ByteBuffer.allocate(bufferSize);
out.putInt(0);
out.putInt(threadId);
out.putInt(trace.length);
for (StackTraceElement elem : trace) {
out.putInt(elem.getClassName().length());
putString(out, elem.getClassName());
out.putInt(elem.getMethodName().length());
putString(out, elem.getMethodName());
if (elem.getFileName() != null) {
out.putInt(elem.getFileName().length());
putString(out, elem.getFileName());
} else {
out.putInt(0);
}
out.putInt(elem.getLineNumber());
}
return new Chunk(CHUNK_STKL, out);
}
use of org.apache.harmony.dalvik.ddmc.Chunk in project platform_frameworks_base by android.
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");
}
use of org.apache.harmony.dalvik.ddmc.Chunk in project platform_frameworks_base by android.
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);
}
use of org.apache.harmony.dalvik.ddmc.Chunk in project platform_frameworks_base by android.
the class DdmHandleViewDebug method listWindows.
/** Returns the list of windows owned by this client. */
private Chunk listWindows() {
String[] windowNames = WindowManagerGlobal.getInstance().getViewRootNames();
// # of windows
int responseLength = 4;
for (String name : windowNames) {
// length of next window name
responseLength += 4;
// window name
responseLength += name.length() * 2;
}
ByteBuffer out = ByteBuffer.allocate(responseLength);
out.order(ChunkHandler.CHUNK_ORDER);
out.putInt(windowNames.length);
for (String name : windowNames) {
out.putInt(name.length());
putString(out, name);
}
return new Chunk(CHUNK_VULW, out);
}
Aggregations