Пример #1
0
        /*
         * Process an incoming DDM packet. If this is a reply to an earlier request,
         * "handler" will be set to the handler responsible for the original
         * request. The spec allows a JDWP message to include multiple DDM chunks.
         */
        private void callHandler(Client client, JdwpPacket packet, ChunkHandler handler)
        {
            // on first DDM packet received, broadcast a "ready" message
            if (!client.ddmSeen())
            {
                broadcast(CLIENT_READY, client);
            }

            ByteBuffer buf = packet.payload;
            int        type, length;
            bool       reply = true;

            type   = buf.getInt();
            length = buf.getInt();

            if (handler == null)
            {
                // not a reply, figure out who wants it
                lock (mHandlerMap)
                {
                    handler = mHandlerMap[type];
                    reply   = false;
                }
            }

            if (handler == null)
            {
                Log.w("ddms", "Received unsupported chunk type " + ChunkHandler.name(type) + " (len=" + length + ")");
            }
            else
            {
                Log.d("ddms", "Calling handler for " + ChunkHandler.name(type) + " [" + handler + "] (len=" + length + ")");
                ByteBuffer ibuf  = buf.slice();
                ByteBuffer roBuf = ibuf.asReadOnlyBuffer();                 // enforce R/O
                roBuf.order = ChunkHandler.CHUNK_ORDER;
                // do the handling of the chunk synchronized on the client list
                // to be sure there's no concurrency issue when we look for HOME
                // in hasApp()
                lock (mClientList)
                {
                    handler.handleChunk(client, type, roBuf, reply, packet.id);
                }
            }
        }
Пример #2
0
        /*
         * Process an incoming DDM packet. If this is a reply to an earlier request,
         * "handler" will be set to the handler responsible for the original
         * request. The spec allows a JDWP message to include multiple DDM chunks.
         */
        private void callHandler(Client client, JdwpPacket packet, ChunkHandler handler)
        {
            // on first DDM packet received, broadcast a "ready" message
            if (!client.ddmSeen())
            {
                broadcast(CLIENT_READY, client);
            }

            ByteBuffer buf = packet.payload;
            int type, length;
            bool reply = true;

            type = buf.getInt();
            length = buf.getInt();

            if (handler == null)
            {
                // not a reply, figure out who wants it
                lock (mHandlerMap)
                {
                    handler = mHandlerMap[type];
                    reply = false;
                }
            }

            if (handler == null)
            {
                Log.w("ddms", "Received unsupported chunk type " + ChunkHandler.name(type) + " (len=" + length + ")");
            }
            else
            {
                Log.d("ddms", "Calling handler for " + ChunkHandler.name(type) + " [" + handler + "] (len=" + length + ")");
                ByteBuffer ibuf = buf.slice();
                ByteBuffer roBuf = ibuf.asReadOnlyBuffer(); // enforce R/O
                roBuf.order = ChunkHandler.CHUNK_ORDER;
                // do the handling of the chunk synchronized on the client list
                // to be sure there's no concurrency issue when we look for HOME
                // in hasApp()
                lock (mClientList)
                {
                    handler.handleChunk(client, type, roBuf, reply, packet.id);
                }
            }
        }