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


使用處理一或多個區塊類型的類別,將這個類別設為子類別。

摘要

常數

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,並預留足夠空間來保存 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)

Return the slice of the JDWP packet buffer that holds just the chunk data.

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,除了要建立的區塊需求外,還要有足夠空間來保存 JDWP 封包標頭和一個區塊標頭。

「maxChunkLen」只代表區塊內容的大小。

參數
maxChunkLen int

傳回
ByteBuffer

clientDisconnected

public abstract void clientDisconnected (ClientImpl client)

用戶端已離開。可用於清除與這個用戶端連線相關聯的任何資源。

參數
client ClientImpl

clientReady

public abstract void clientReady (ClientImpl client)

用戶端已準備就緒。當用戶端判斷為 DDM 感知型 (通常是在收到 HELO 回應後),監控執行緒會在所有處理常式上呼叫這個方法。

處理常式可利用這個機會初始化用戶端活動。因為我們很有可能想傳送訊息給用戶端,所以這個方法可能會擲回 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

類型

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)

處理常式無法辨識控點區塊。如果系統無法辨識區塊類型,子類別中的 handleChunk() 方法應呼叫這個方法。

參數
client ClientImpl

type int

data ByteBuffer

isReply boolean

msgId int