Methods Summary |
---|
static java.nio.ByteBuffer | allocBuffer(int maxChunkLen)Allocate a ByteBuffer with enough space to hold the JDWP packet
header and one chunk header in addition to the demands of the
chunk being created.
"maxChunkLen" indicates the size of the chunk contents only.
ByteBuffer buf =
ByteBuffer.allocate(JdwpPacket.JDWP_HEADER_LEN + 8 +maxChunkLen);
buf.order(CHUNK_ORDER);
return buf;
|
protected static Client | checkDebuggerPortForAppName(Client client, java.lang.String appName)Check that the client is opened with the proper debugger port for the
specified application name, and if not, reopen it.
IDebugPortProvider provider = DebugPortManager.getProvider();
if (provider != null) {
Device device = client.getDevice();
int newPort = provider.getPort(device, appName);
if (newPort != IDebugPortProvider.NO_STATIC_PORT &&
newPort != client.getDebuggerListenPort()) {
AndroidDebugBridge bridge = AndroidDebugBridge.getBridge();
if (bridge != null) {
DeviceMonitor deviceMonitor = bridge.getDeviceMonitor();
if (deviceMonitor != null) {
deviceMonitor.addClientToDropAndReopen(client, newPort);
client = null;
}
}
}
}
return client;
|
abstract void | clientDisconnected(Client client)Client has gone away. Can be used to clean up any resources
associated with this client connection.
|
abstract void | clientReady(Client client)Client is ready. The monitor thread calls this method on all
handlers when the client is determined to be DDM-aware (usually
after receiving a HELO response.)
The handler can use this opportunity to initialize client-side
activity. Because there's a fair chance we'll want to send a
message to the client, this method can throw an IOException.
|
static void | finishChunkPacket(JdwpPacket packet, int type, int chunkLen)Write the chunk header at the start of the chunk.
Pass in the byte buffer returned by JdwpPacket.getPayload().
ByteBuffer buf = packet.getPayload();
buf.putInt(0x00, type);
buf.putInt(0x04, chunkLen);
packet.finishPacket(CHUNK_HEADER_LEN + chunkLen);
|
static java.nio.ByteBuffer | getChunkDataBuf(java.nio.ByteBuffer jdwpBuf)Return the slice of the JDWP packet buffer that holds just the
chunk data.
ByteBuffer slice;
assert jdwpBuf.position() == 0;
jdwpBuf.position(JdwpPacket.JDWP_HEADER_LEN + CHUNK_HEADER_LEN);
slice = jdwpBuf.slice();
slice.order(CHUNK_ORDER);
jdwpBuf.position(0);
return slice;
|
static java.lang.String | getString(java.nio.ByteBuffer buf, int len)Utility function to copy a String out of a ByteBuffer.
This is here because multiple chunk handlers can make use of it,
and there's nowhere better to put it.
char[] data = new char[len];
for (int i = 0; i < len; i++)
data[i] = buf.getChar();
return new String(data);
|
abstract void | handleChunk(Client client, int type, java.nio.ByteBuffer data, boolean isReply, int msgId)Handle an incoming chunk. The data, of chunk type "type", begins
at the start of "data" and continues to data.limit().
If "isReply" is set, then "msgId" will be the ID of the request
we sent to the client. Otherwise, it's the ID generated by the
client for this event. Note that it's possible to receive chunks
in reply packets for which we are not registered.
The handler may not modify the contents of "data".
|
protected void | handleUnknownChunk(Client client, int type, java.nio.ByteBuffer data, boolean isReply, int msgId)Handle chunks not recognized by handlers. The handleChunk() method
in sub-classes should call this if the chunk type isn't recognized.
if (type == CHUNK_FAIL) {
int errorCode, msgLen;
String msg;
errorCode = data.getInt();
msgLen = data.getInt();
msg = getString(data, msgLen);
Log.w("ddms", "WARNING: failure code=" + errorCode + " msg=" + msg);
} else {
Log.w("ddms", "WARNING: received unknown chunk " + name(type)
+ ": len=" + data.limit() + ", reply=" + isReply
+ ", msgId=0x" + Integer.toHexString(msgId));
}
Log.w("ddms", " client " + client + ", handler " + this);
|
static java.lang.String | name(int type)Convert an integer type to a 4-character string.
char[] ascii = new char[4];
ascii[0] = (char) ((type >> 24) & 0xff);
ascii[1] = (char) ((type >> 16) & 0xff);
ascii[2] = (char) ((type >> 8) & 0xff);
ascii[3] = (char) (type & 0xff);
return new String(ascii);
|
static void | putString(java.nio.ByteBuffer buf, java.lang.String str)Utility function to copy a String into a ByteBuffer.
int len = str.length();
for (int i = 0; i < len; i++)
buf.putChar(str.charAt(i));
|
static int | type(java.lang.String typeName)Convert a 4-character string to a 32-bit type.
int val = 0;
if (typeName.length() != 4) {
Log.e("ddms", "Type name must be 4 letter long");
throw new RuntimeException("Type name must be 4 letter long");
}
for (int i = 0; i < 4; i++) {
val <<= 8;
val |= (byte) typeName.charAt(i);
}
return val;
|