Exemple #1
0
        /**
         * Opens an AdbStream object corresponding to the specified destination.
         * This routine will block until the connection completes.
         * @param destination The destination to open on the target
         * @return AdbStream object corresponding to the specified destination
         */
        private T Open <T>(String destination)
            where T : AdbSessionBase
        {
            uint localId = ++lastLocalId;

            if (!connectAttempted)
            {
                throw new IOException("connect() must be called first");
            }

            /* Wait for the connect response */
            lock (this)
            {
                if (!connected)
                {
                    Monitor.Wait(this);
                }

                if (!connected)
                {
                    throw new IOException("Connection failed");
                }
            }

            /* Add this stream to this list of half-open streams */
            T stream = Activator.CreateInstance(typeof(T), this, localId) as T;

            openStreams.Add(localId, stream);

            /* Send the open */
            Send(AdbProtocol.GenerateOpen(localId, destination));


            /* Wait for the connection thread to receive the OKAY */
            lock (stream)
            {
                Monitor.Wait(stream);
            }

            /* Check if the open was rejected */
            if (stream.IsClosed)
            {
                throw new IOException("Stream open actively rejected by remote peer");
            }

            /* We're fully setup now */
            return(stream);
        }
Exemple #2
0
 public void Reboot()
 {
     Send(AdbProtocol.GenerateOpen(++lastLocalId, "reboot:"));
     Close();
 }