15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/stf/interactor/start_one_debug_session_interactor.rb', line 15
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}"
shell('echo adbtest', {serial: "#{result.remoteConnectUrl}"}, 30)
raise ADBError, "Could not execute shell test" unless stdout_contains "adbtest"
return true
rescue SignalException => e
raise e
rescue => e
begin
DI[:stf].remove_device serial
rescue
end
logger.error "Failed to connect to #{serial}: " + e.message
return false
end
end
|