Sha256: c38a2fc8799c6a7928c1bae7957a51775c2d8fe9ca42b5f9e1f11acc1fe0568d

Contents?: true

Size: 1.1 KB

Versions: 2

Compression:

Stored size: 1.1 KB

Contents

require 'di'
require 'ADB'

require 'stf/client'
require 'stf/log/log'
require 'stf/errors'
require 'stf/model/session'

module Stf
  class StartOneDebugSessionInteractor

    include Log
    include ADB

    def execute(device)
      return false if device.nil?
      serial = device.serial

      begin
        success = DI[:stf].add_device serial
        if success
          logger.info "Device added #{serial}"
        else
          logger.error "Can't add device #{serial}"
          raise
        end

        result = DI[:stf].start_debug serial
        if result.success
          logger.info "Debug started #{serial}"
        else
          logger.error "Can't start debugging session for device #{serial}"
          raise
        end

        execute_adb_with 30, "connect #{result.remoteConnectUrl}"

        return true

      rescue SignalException => e
        raise e

      rescue => e
        begin
          # we will try clean anyway
          DI[:stf].remove_device serial
        rescue
        end

        logger.error "Failed to connect to #{serial}"
        return false
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stf-client-0.2.1 lib/stf/interactor/start_one_debug_session_interactor.rb
stf-client-0.2.0 lib/stf/interactor/start_one_debug_session_interactor.rb