Class: Stf::StopAllDebugSessionsInteractor
- Inherits:
-
Object
- Object
- Stf::StopAllDebugSessionsInteractor
- Includes:
- ADB, Log
- Defined in:
- lib/stf/interactor/stop_all_debug_sessions_interactor.rb
Instance Method Summary collapse
- #disconnect_unwanted_devices(filter, force_filter, healthcheck) ⇒ Object
-
#execute(options = {}) ⇒ Object
byFilter:.
Methods included from Log
Instance Method Details
#disconnect_unwanted_devices(filter, force_filter, healthcheck) ⇒ Object
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 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/stf/interactor/stop_all_debug_sessions_interactor.rb', line 25 def disconnect_unwanted_devices(filter, force_filter, healthcheck) DI[:android_util].cleanup_adb_devices to_disconnect = [] # array of device serials active_user_devices = DeviceList.new(DI[:stf].get_user_devices) adb_serials_to_urls = DI[:android_util].map_serials_to_adb_urls if filter && force_filter disconnect_because_filter = active_user_devices.except_filter(filter).asArray.map { |d| d.serial } unless disconnect_because_filter.empty? logger.info 'will be disconnected by filter: ' + disconnect_because_filter.join(',') to_disconnect += disconnect_because_filter end end if healthcheck disconnect_by_health = active_user_devices.select_not_healthy(healthcheck).asArray.map { |d| d.serial } unless disconnect_by_health.empty? logger.info 'will be disconnected by health check: ' + disconnect_by_health.join(',') to_disconnect += disconnect_by_health end end dead_persons = active_user_devices.asArray.map { |d| d.serial } - (adb_serials_to_urls.keys + DI[:connect_ios].ios_serials_to_urls.keys) unless dead_persons.empty? logger.info 'will be disconnected because not present locally: ' + dead_persons.join(',') to_disconnect += dead_persons end without_active_session = (adb_serials_to_urls.keys + DI[:connect_ios].ios_serials_to_urls.keys) - active_user_devices.asArray.map{ |d| d.serial } unless without_active_session.empty? logger.info 'will be disconnected because session is not active in SmartDust Lab: ' + without_active_session.join(',') to_disconnect += without_active_session end DeviceList.new(DI[:stf].get_devices).asArray.filter {|device| to_disconnect.include? device.serial }.each do |device| logger.info 'Cleanup the device ' + device.serial DI[:stop_debug_session_interactor].execute(device) end end |
#execute(options = {}) ⇒ Object
byFilter:
16 17 18 19 20 21 22 23 |
# File 'lib/stf/interactor/stop_all_debug_sessions_interactor.rb', line 16 def execute( = {}) DI[:demonizer].kill unless [:nokill] disconnect_unwanted_devices(nil, false, false) stf_devices = DeviceList.new(DI[:stf].get_user_devices) stf_devices = stf_devices.by_filter [:byFilter] if [:byFilter] stf_devices.asArray.each {|d| DI[:stop_debug_session_interactor].execute d} end |