Sha256: 9e344bea7f41446476bc35708d4a1fa6a02cb338ab04aa80902aabc5c07c8bfe

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

require 'di'
require 'ADB'

require 'stf/client'
require 'stf/log/log'

module Stf
  class StopDebugSessionInteractor
    include Log
    include ADB

    def execute(remote_connect_url)
      remote_devices = DI[:stf].get_user_devices
      device = remote_devices.find {|d| d.remoteConnect == true && DI[:device_enhancer].get_tunneled_remote_connect_url(d).eql?(remote_connect_url)}

      # try to disconnect anyway
      execute_adb_with 30, "disconnect #{remote_connect_url}"

      if device.nil?
        logger.error "Device #{remote_connect_url} is not available"
        return false
      end

      success = false

      1..10.times do
        begin
          success = DI[:stf].stop_debug(device.serial)
          break if success
        rescue
        end

        logger.error 'Can\'t stop debug session. Retrying'
      end

      1..10.times do
        begin
          success = DI[:stf].remove_device(device.serial)
          break if success
        rescue
        end
        logger.error 'Can\'t remove device from user devices. Retrying'
      end

      if success
        logger.info "Successfully removed #{remote_connect_url}"
      else
        logger.error "Error removing #{remote_connect_url}"
      end

      success
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
smartdust-client-1.1.0 lib/stf/interactor/stop_debug_session_interactor.rb