HandleHellopublic final class HandleHello extends ChunkHandler Handle the "hello" chunk (HELO). |
Fields Summary |
---|
public static final int | CHUNK_HELO | private static final HandleHello | mInst |
Constructors Summary |
---|
private HandleHello()
|
Methods Summary |
---|
public void | clientDisconnected(Client client)Client went away.
Log.d("ddm-hello", "Now disconnected: " + client);
| public void | clientReady(Client client)Client is ready.
Log.d("ddm-hello", "Now ready: " + client);
| public void | handleChunk(Client client, int type, java.nio.ByteBuffer data, boolean isReply, int msgId)Chunk handler entry point.
Log.d("ddm-hello", "handling " + ChunkHandler.name(type));
if (type == CHUNK_HELO) {
assert isReply;
handleHELO(client, data);
} else {
handleUnknownChunk(client, type, data, isReply, msgId);
}
| private static void | handleHELO(Client client, java.nio.ByteBuffer data)
int version, pid, vmIdentLen, appNameLen;
String vmIdent, appName;
version = data.getInt();
pid = data.getInt();
vmIdentLen = data.getInt();
appNameLen = data.getInt();
vmIdent = getString(data, vmIdentLen);
appName = getString(data, appNameLen);
Log.d("ddm-hello", "HELO: v=" + version + ", pid=" + pid
+ ", vm='" + vmIdent + "', app='" + appName + "'");
ClientData cd = client.getClientData();
synchronized (cd) {
if (cd.getPid() == pid) {
cd.setVmIdentifier(vmIdent);
cd.setClientDescription(appName);
cd.isDdmAware(true);
} else {
Log.e("ddm-hello", "Received pid (" + pid + ") does not match client pid ("
+ cd.getPid() + ")");
}
}
client = checkDebuggerPortForAppName(client, appName);
if (client != null) {
client.update(Client.CHANGE_NAME);
}
| public static void | register(MonitorThread mt)Register for the packets we expect to get from the client.
mt.registerChunkHandler(CHUNK_HELO, mInst);
| public static void | sendHELO(Client client, int serverProtocolVersion)Send a HELO request to the client.
ByteBuffer rawBuf = allocBuffer(4);
JdwpPacket packet = new JdwpPacket(rawBuf);
ByteBuffer buf = getChunkDataBuf(rawBuf);
buf.putInt(serverProtocolVersion);
finishChunkPacket(packet, CHUNK_HELO, buf.position());
Log.d("ddm-hello", "Sending " + name(CHUNK_HELO)
+ " ID=0x" + Integer.toHexString(packet.getId()));
client.sendAndConsume(packet, mInst);
|
|