ChunkHandler
public
abstract
class
ChunkHandler
extends JdwpInterceptor
| java.lang.Object | ||
| ↳ | com.android.tradefed.device.server.jdwp.JdwpInterceptor | |
| ↳ | com.android.tradefed.device.server.jdwp.chunkhandler.ChunkHandler | |
使用可处理一种或多种 chunk 类型的类对此类进行子类化。
摘要
常量 | |
|---|---|
int |
CHUNK_HEADER_LEN
|
int |
DDMS_CMD
|
int |
DDMS_CMD_SET
|
字段 | |
|---|---|
public
static
final
int |
CHUNK_FAIL
|
public
static
final
ByteOrder |
CHUNK_ORDER
|
公共构造函数 | |
|---|---|
ChunkHandler()
|
|
公共方法 | |
|---|---|
static
ByteBuffer
|
allocBuffer(int maxChunkLen)
分配一个 ByteBuffer,该 ByteBuffer 具有足够的空间来容纳 JDWP 数据包标头和一个块标头,此外还应满足所创建块的需求。 |
abstract
void
|
clientDisconnected(ClientImpl client)
客户端已消失。 |
abstract
void
|
clientReady(ClientImpl client)
客户端已准备就绪。 |
static
void
|
finishChunkPacket(JdwpPacket packet, int type, int chunkLen)
在块的开头写入块头。 |
static
ByteBuffer
|
getChunkDataBuf(ByteBuffer jdwpBuf)
返回仅包含块数据的 JDWP 数据包缓冲区的切片。 |
abstract
void
|
handleChunk(ClientImpl client, int type, ByteBuffer data, boolean isReply, int msgId)
处理传入的块。 |
void
|
handlePacket(ClientImpl client, JdwpPacket packet)
|
JdwpPacket
|
intercept(JdwpAgent agent, JdwpPacket packet)
|
static
int
|
type(String typeName)
将 4 字符的字符串转换为 32 位类型。 |
受保护的方法 | |
|---|---|
void
|
handleUnknownChunk(ClientImpl client, int type, ByteBuffer data, boolean isReply, int msgId)
处理程序无法识别的块。 |
常量
CHUNK_HEADER_LEN
public static final int CHUNK_HEADER_LEN
常量值: 8 (0x00000008)
DDMS_CMD
public static final int DDMS_CMD
常量值: 1 (0x00000001)
DDMS_CMD_SET
public static final int DDMS_CMD_SET
常量值: 199 (0x000000c7)
字段
CHUNK_FAIL
public static final int CHUNK_FAIL
CHUNK_ORDER
public static final ByteOrder CHUNK_ORDER
公共构造函数
ChunkHandler
public ChunkHandler ()
公共方法
allocBuffer
public static ByteBuffer allocBuffer (int maxChunkLen)
分配一个 ByteBuffer,该 ByteBuffer 具有足够的空间来容纳 JDWP 数据包标头和一个块标头,此外还应满足所创建块的需求。
“maxChunkLen”仅表示块内容的大小。
| 参数 | |
|---|---|
maxChunkLen |
int |
| 返回 | |
|---|---|
ByteBuffer |
|
clientDisconnected
public abstract void clientDisconnected (ClientImpl client)
客户端已消失。可用于清理与此客户端连接关联的任何资源。
| 参数 | |
|---|---|
client |
ClientImpl |
clientReady
public abstract void clientReady (ClientImpl client)
客户端已准备就绪。当客户端被确定为 DDM 感知型(通常是在收到 HELO 响应后)时,监控线程会在所有处理程序上调用此方法。
处理程序可以利用此机会初始化客户端 activity。由于我们很有可能会想向客户端发送消息,因此此方法可能会抛出 IOException。
| 参数 | |
|---|---|
client |
ClientImpl |
finishChunkPacket
public static void finishChunkPacket (JdwpPacket packet, int type, int chunkLen)
在块的开头写入块头。
传入由 JdwpPacket.getPayload() 返回的字节缓冲区。
| 参数 | |
|---|---|
packet |
JdwpPacket |
type |
int |
chunkLen |
int |
getChunkDataBuf
public static ByteBuffer getChunkDataBuf (ByteBuffer jdwpBuf)
返回仅包含块数据的 JDWP 数据包缓冲区的切片。
| 参数 | |
|---|---|
jdwpBuf |
ByteBuffer |
| 返回 | |
|---|---|
ByteBuffer |
|
handleChunk
public abstract void handleChunk (ClientImpl client, int type, ByteBuffer data, boolean isReply, int msgId)
处理传入的块。块类型为“type”的数据从“data”的开头开始,一直持续到 data.limit()。
如果设置了“isReply”,则“msgId”将是我们发送给客户端的请求的 ID。 否则,它是客户端为此事件生成的 ID。请注意,我们可能会收到未注册的回复数据块。
处理程序不得修改“data”的内容。
| 参数 | |
|---|---|
client |
ClientImpl |
type |
int |
data |
ByteBuffer |
isReply |
boolean |
msgId |
int |
handlePacket
public void handlePacket (ClientImpl client, JdwpPacket packet)
| 参数 | |
|---|---|
client |
ClientImpl |
packet |
JdwpPacket |
拦截
public JdwpPacket intercept (JdwpAgent agent, JdwpPacket packet)
| 参数 | |
|---|---|
agent |
JdwpAgent |
packet |
JdwpPacket |
| 返回 | |
|---|---|
JdwpPacket |
|
type
public static int type (String typeName)
将 4 字符的字符串转换为 32 位类型。
| 参数 | |
|---|---|
typeName |
String |
| 返回 | |
|---|---|
int |
|
受保护的方法
handleUnknownChunk
protected void handleUnknownChunk (ClientImpl client, int type, ByteBuffer data, boolean isReply, int msgId)
处理程序无法识别句柄块。如果无法识别 chunk 类型,子类中的 handleChunk() 方法应调用此方法。
| 参数 | |
|---|---|
client |
ClientImpl |
type |
int |
data |
ByteBuffer |
isReply |
boolean |
msgId |
int |