2 * Copyright (C) 2007 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.ddmlib;
19 import com.android.ddmlib.ClientData.DebuggerStatus;
21 import java.io.IOException;
22 import java.nio.ByteBuffer;
25 * Handle the "wait" chunk (WAIT). These are sent up when the client is
26 * waiting for something, e.g. for a debugger to attach.
28 final class HandleWait extends ChunkHandler {
30 public static final int CHUNK_WAIT = ChunkHandler.type("WAIT");
32 private static final HandleWait mInst = new HandleWait();
35 private HandleWait() {}
38 * Register for the packets we expect to get from the client.
40 public static void register(MonitorThread mt) {
41 mt.registerChunkHandler(CHUNK_WAIT, mInst);
48 public void clientReady(Client client) throws IOException {}
54 public void clientDisconnected(Client client) {}
57 * Chunk handler entry point.
60 public void handleChunk(Client client, int type, ByteBuffer data, boolean isReply, int msgId) {
62 Log.d("ddm-wait", "handling " + ChunkHandler.name(type));
64 if (type == CHUNK_WAIT) {
66 handleWAIT(client, data);
68 handleUnknownChunk(client, type, data, isReply, msgId);
73 * Handle a reply to our WAIT message.
75 private static void handleWAIT(Client client, ByteBuffer data) {
80 Log.d("ddm-wait", "WAIT: reason=" + reason);
83 ClientData cd = client.getClientData();
85 cd.setDebuggerConnectionStatus(DebuggerStatus.WAITING);
88 client.update(Client.CHANGE_DEBUGGER_STATUS);