FileDocCategorySizeDatePackage
HandleHello.javaAPI DocAndroid 1.5 API3713Wed May 06 22:41:08 BST 2009com.android.ddmlib

HandleHello

public 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 voidclientDisconnected(Client client)
Client went away.

        Log.d("ddm-hello", "Now disconnected: " + client);
    
public voidclientReady(Client client)
Client is ready.

        Log.d("ddm-hello", "Now ready: " + client);
    
public voidhandleChunk(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 voidhandleHELO(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 voidregister(MonitorThread mt)
Register for the packets we expect to get from the client.

        mt.registerChunkHandler(CHUNK_HELO, mInst);
    
public static voidsendHELO(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);