Sha256: 76a3b2083966981b69afbcc20e27d4ee7baf1062fc7da93be542c284e3867389

Contents?: true

Size: 1.06 KB

Versions: 9

Compression:

Stored size: 1.06 KB

Contents

require 'ADB'

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

class StopDebugSessionInteractor

  include Log
  include ADB

  def initialize(stf)
    @stf = stf
  end

  def execute(remoteConnectUrl)
    remote_devices = @stf.get_user_devices
    device         = remote_devices.find { |d| d.remoteConnect == true && d.remoteConnectUrl.eql?(remoteConnectUrl) }

    raise DeviceNotAvailableError if device.nil?

    execute_adb_with 30, "disconnect #{device.remoteConnectUrl}"

    success = false

    1..10.times do
      success = @stf.stop_debug(device.serial)
      if success == true
        break
      elsif logger.error 'Can\'t stop debug session. Retrying'
      end
    end

    1..10.times do
      success = @stf.remove_device(device.serial)
      if success == true
        break
      elsif logger.error 'Can\'t remove device from user devices. Retrying'
      end
    end

    if success == true
      logger.info "Successfully removed #{remoteConnectUrl}"
    elsif logger.error "Error removing #{remoteConnectUrl}"
    end

    return success
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
stf-client-neofreko-0.1.9 lib/stf/interactor/stop_debug_session_interactor.rb
stf-client-neofreko-0.1.8 lib/stf/interactor/stop_debug_session_interactor.rb
stf-client-neofreko-0.1.7 lib/stf/interactor/stop_debug_session_interactor.rb
stf-client-0.1.6 lib/stf/interactor/stop_debug_session_interactor.rb
stf-client-0.1.4 lib/stf/interactor/stop_debug_session_interactor.rb
stf-client-0.1.3 lib/stf/interactor/stop_debug_session_interactor.rb
stf-client-0.1.2 lib/stf/interactor/stop_debug_session_interactor.rb
stf-client-0.1.1 lib/stf/interactor/stop_debug_session_interactor.rb
stf-client-0.1.0 lib/stf/interactor/stop_debug_session_interactor.rb