Exemplo n.º 1
0
 /// <summary>
 /// Gets the currently connected devices.
 /// </summary>
 public static IEnumerable <AndroidDevice> GetDevices(int timeout)
 {
     try
     {
         using (var socket = new AdbDevicesRequest(EndPoint))
         {
             return(socket.Devices());
         }
     }
     catch (Exception ex)
     {
         throw new AdbException(string.Format("Failed to list devices because: {0}", ex.Message));
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Perform the monitor loop
        /// </summary>
        private void Run()
        {
            var initialLoopCounter = loopCounter;

            while (initialLoopCounter == loopCounter)
            {
                try
                {
                    if (errorCount > 0)
                    {
                        // Ensure Adb is started
                        new Adb().StartServer(Adb.Timeout.StartServer);
                        errorCount = 0;
                        Thread.Sleep(500);
                    }
                    else
                    {
                        // Start tracking
                        try
                        {
                            using (request = new AdbDevicesRequest(endPoint))
                            {
                                request.TrackDevices(CallBack);
                            }
                        }
                        finally
                        {
                            request = null;
                        }
                    }
                }
                catch
                {
                    errorCount++;
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Gets the currently connected devices.
 /// </summary>
 public static IEnumerable<AndroidDevice> GetDevices(int timeout)
 {
     try
     {
         using (var socket = new AdbDevicesRequest(EndPoint))
         {
             return socket.Devices();
         }
     }
     catch (Exception ex)
     {
         throw new AdbException(string.Format("Failed to list devices because: {0}", ex.Message));
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Perform the monitor loop
 /// </summary>
 private void Run()
 {
     var initialLoopCounter = loopCounter;
     while (initialLoopCounter == loopCounter)
     {
         try
         {
             if (errorCount > 0)
             {
                 // Ensure Adb is started
                 new Adb().StartServer(Adb.Timeout.StartServer);
                 errorCount = 0;
                 Thread.Sleep(500);
             }
             else
             {
                 // Start tracking
                 try
                 {
                     using (request = new AdbDevicesRequest(endPoint))
                     {
                         request.TrackDevices(CallBack);
                     }
                 }
                 finally
                 {
                     request = null;
                 }
             }
         }
         catch
         {
             errorCount++;
         }
     }
 }