12
13
14
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
|
# File 'lib/stf/interactor/stop_debug_session_interactor.rb', line 12
def execute(device)
if DI[:connect_ios].ios_serials_to_urls.keys.include? device.serial
DI[:connect_ios].disconnect(DI[:connect_ios].ios_serials_to_urls[device.serial])
elsif devices.include? device.serial
execute_adb_with 30, "disconnect #{remote_connect_url}"
end
if DeviceList.new(DI[:stf].get_user_devices).asArray.map {|d| d.serial}.include? device.serial
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 #{device.serial}"
else
logger.error "Error removing #{device.serial}"
end
end
success
end
|