1 /* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.ddmlib; 18 19 import com.android.ddmlib.Log.LogLevel; 20 21 import java.io.IOException; 22 import java.nio.ByteBuffer; 23 24 /** 25 * Handle thread status updates. 26 */ 27 final class HandleTest extends ChunkHandler { 28 29 public static final int CHUNK_TEST = type("TEST"); 30 31 private static final HandleTest mInst = new HandleTest(); 32 33 34 private HandleTest() {} 35 36 /** 37 * Register for the packets we expect to get from the client. 38 */ 39 public static void register(MonitorThread mt) { 40 mt.registerChunkHandler(CHUNK_TEST, mInst); 41 } 42 43 /** 44 * Client is ready. 45 */ 46 @Override 47 public void clientReady(Client client) throws IOException {} 48 49 /** 50 * Client went away. 51 */ 52 @Override 53 public void clientDisconnected(Client client) {} 54 55 /** 56 * Chunk handler entry point. 57 */ 58 @Override 59 public void handleChunk(Client client, int type, ByteBuffer data, boolean isReply, int msgId) { 60 61 Log.d("ddm-test", "handling " + ChunkHandler.name(type)); 62 63 if (type == CHUNK_TEST) { 64 handleTEST(client, data); 65 } else { 66 handleUnknownChunk(client, type, data, isReply, msgId); 67 } 68 } 69 70 /* 71 * Handle a thread creation message. 72 */ 73 private void handleTEST(Client client, ByteBuffer data) 74 { 75 /* 76 * Can't call data.array() on a read-only ByteBuffer, so we make 77 * a copy. 78 */ 79 byte[] copy = new byte[data.limit()]; 80 data.get(copy); 81 82 Log.d("ddm-test", "Received:"); 83 Log.hexDump("ddm-test", LogLevel.DEBUG, copy, 0, copy.length); 84 } 85 } 86 87