Exemplo n.º 1
0
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: private boolean sendDeviceMonitoringRequest(java.nio.channels.SocketChannel socket, Device device) throws TimeoutException, AdbCommandRejectedException, java.io.IOException
        private bool sendDeviceMonitoringRequest(SocketChannel socket, Device device)
        {
            try
            {
                AdbHelper.setDevice(socket, device);

                var request = AdbHelper.formAdbRequest("track-jdwp"); //$NON-NLS-1$

                AdbHelper.write(socket, request);

                AdbHelper.AdbResponse resp = AdbHelper.readAdbResponse(socket, false); // readDiagString

                if (resp.okay == false)
                {
                    // request was refused by adb!
                    Log.e("DeviceMonitor", "adb refused request: " + resp.message);
                }

                return(resp.okay);
            }
            catch (TimeoutException e)
            {
                Log.e("DeviceMonitor", "Sending jdwp tracking request timed out!");
                throw e;
            }
            catch (IOException e)
            {
                Log.e("DeviceMonitor", "Sending jdwp tracking request failed!");
                throw e;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Opens the sync connection. This must be called before any calls to push[File] / pull[File]. </summary>
        /// <returns> true if the connection opened, false if adb refuse the connection. This can happen
        /// if the <seealso cref="Device"/> is invalid. </returns>
        /// <exception cref="TimeoutException"> in case of timeout on the connection. </exception>
        /// <exception cref="AdbCommandRejectedException"> if adb rejects the command </exception>
        /// <exception cref="IOException"> If the connection to adb failed. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: boolean openSync() throws TimeoutException, AdbCommandRejectedException, java.io.IOException
        internal bool openSync()
        {
            try
            {
                mChannel = SocketChannel.open(mAddress);
                mChannel.configureBlocking(false);

                // target a specific device
                AdbHelper.setDevice(mChannel, mDevice);

                var request = AdbHelper.formAdbRequest("sync:");                 //$NON-NLS-1$
                AdbHelper.write(mChannel, request, -1, DdmPreferences.timeOut);

                AdbHelper.AdbResponse resp = AdbHelper.readAdbResponse(mChannel, false);                 // readDiagString

                if (resp.okay == false)
                {
                    Log.w("ddms", "Got unhappy response from ADB sync req: " + resp.message);
                    mChannel.close();
                    mChannel = null;
                    return(false);
                }
            }
            catch (TimeoutException e)
            {
                if (mChannel != null)
                {
                    try
                    {
                        mChannel.close();
                    }
                    catch (IOException)
                    {
                        // we want to throw the original exception, so we ignore this one.
                    }
                    mChannel = null;
                }

                throw e;
            }
            catch (IOException e)
            {
                if (mChannel != null)
                {
                    try
                    {
                        mChannel.close();
                    }
                    catch (IOException)
                    {
                        // we want to throw the original exception, so we ignore this one.
                    }
                    mChannel = null;
                }

                throw e;
            }

            return(true);
        }
Exemplo n.º 3
0
        ///
        /// <summary>
        /// @return </summary>
        /// <exception cref="IOException"> </exception>
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: private boolean sendDeviceListMonitoringRequest() throws TimeoutException, java.io.IOException
        private bool sendDeviceListMonitoringRequest()
        {
            var request = AdbHelper.formAdbRequest("host:track-devices"); //$NON-NLS-1$

            try
            {
                AdbHelper.write(mMainAdbConnection, request);

                AdbHelper.AdbResponse resp = AdbHelper.readAdbResponse(mMainAdbConnection, false); // readDiagString

                if (resp.okay == false)
                {
                    // request was refused by adb!
                    Log.e("DeviceMonitor", "adb refused request: " + resp.message);
                }

                return(resp.okay);
            }
            catch (IOException e)
            {
                Log.e("DeviceMonitor", "Sending Tracking request failed!");
                mMainAdbConnection.close();
                throw e;
            }
        }