Exemplo n.º 1
0
        /// <summary>
        /// Creates a client and register it to the monitor thread </summary>
        /// <param name="device"> </param>
        /// <param name="pid"> </param>
        /// <param name="socket"> </param>
        /// <param name="debuggerPort"> the debugger port. </param>
        /// <param name="monitorThread"> the <seealso cref="MonitorThread"/> object. </param>
        private void createClient(Device device, int pid, SocketChannel socket, int debuggerPort, MonitorThread monitorThread)
        {
            /*
             * Successfully connected to something. Create a Client object, add
             * it to the list, and initiate the JDWP handshake.
             */

            Client client = new Client(device, socket, pid);

            if (client.sendHandshake())
            {
                try
                {
                    if (AndroidDebugBridge.clientSupport)
                    {
                        client.listenForDebugger(debuggerPort);
                    }
                }
                catch (IOException)
                {
                    client.clientData.debuggerConnectionStatus = ClientData.DebuggerStatus.ERROR;
                    Log.e("ddms", "Can't bind to local " + debuggerPort + " for debugger");
                    // oh well
                }

                client.requestAllocationStatus();
            }
            else
            {
                Log.e("ddms", "Handshake with " + client + " failed!");

                /*
                 * The handshake send failed. We could remove it now, but if the
                 * failure is "permanent" we'll just keep banging on it and
                 * getting the same result. Keep it in the list with its "error"
                 * state so we don't try to reopen it.
                 */
            }

            if (client.valid)
            {
                device.addClient(client);
                monitorThread.addClient(client);
            }
            else
            {
                client = null;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a client and register it to the monitor thread </summary>
        /// <param name="device"> </param>
        /// <param name="pid"> </param>
        /// <param name="socket"> </param>
        /// <param name="debuggerPort"> the debugger port. </param>
        /// <param name="monitorThread"> the <seealso cref="MonitorThread"/> object. </param>
        private void createClient(Device device, int pid, SocketChannel socket, int debuggerPort, MonitorThread monitorThread)
        {

            /*
             * Successfully connected to something. Create a Client object, add
             * it to the list, and initiate the JDWP handshake.
             */

            Client client = new Client(device, socket, pid);

            if (client.sendHandshake())
            {
                try
                {
                    if (AndroidDebugBridge.clientSupport)
                    {
                        client.listenForDebugger(debuggerPort);
                    }
                }
                catch (IOException)
                {
                    client.clientData.debuggerConnectionStatus = ClientData.DebuggerStatus.ERROR;
                    Log.e("ddms", "Can't bind to local " + debuggerPort + " for debugger");
                    // oh well
                }

                client.requestAllocationStatus();
            }
            else
            {
                Log.e("ddms", "Handshake with " + client + " failed!");
                /*
                 * The handshake send failed. We could remove it now, but if the
                 * failure is "permanent" we'll just keep banging on it and
                 * getting the same result. Keep it in the list with its "error"
                 * state so we don't try to reopen it.
                 */
            }

            if (client.valid)
            {
                device.addClient(client);
                monitorThread.addClient(client);
            }
            else
            {
                client = null;
            }
        }