Class: Fastlane::Actions::WaitAndroidEmuIdleAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::WaitAndroidEmuIdleAction
- Defined in:
- lib/fastlane/plugin/stream_actions/actions/wait_android_emu_idle.rb
Documentation collapse
Class Method Summary collapse
Class Method Details
.available_options ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/fastlane/plugin/stream_actions/actions/wait_android_emu_idle.rb', line 40 def self. [ FastlaneCore::ConfigItem.new( key: :load_threshold, description: 'Load threshold to consider device idle', is_string: false, default_value: 1.0 ), FastlaneCore::ConfigItem.new( key: :timeout, description: 'Timeout in seconds to wait for device to be idle', is_string: false, default_value: 1000 ) ] end |
.description ⇒ Object
36 37 38 |
# File 'lib/fastlane/plugin/stream_actions/actions/wait_android_emu_idle.rb', line 36 def self.description 'Adds environment variables to a test plan' end |
.is_supported?(platform) ⇒ Boolean
57 58 59 |
# File 'lib/fastlane/plugin/stream_actions/actions/wait_android_emu_idle.rb', line 57 def self.is_supported?(platform) [:android].include?(platform) end |
.run(params) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fastlane/plugin/stream_actions/actions/wait_android_emu_idle.rb', line 4 def self.run(params) start_time = Time.now UI.important("Start waiting until emulator is idle (#{Time.now})") check_emu_uptime = 'adb shell uptime | cut -d , -f 3 | cut -f 2 -d :' current_uptime_value = `#{check_emu_uptime}`.strip.to_f end_time = start_time + params[:timeout] while current_uptime_value > params[:load_threshold] && Time.now < end_time UI.important("Uptime value: #{current_uptime_value} > #{params[:load_threshold]}") not_responding_package = `adb shell dumpsys window | grep -E "mCurrentFocus.*Application Not Responding" | cut -f 2 -d : | sed -e "s/}//" -e "s/^ *//"`.strip unless not_responding_package.empty? UI.important("Closing not responding `#{not_responding_package}`") `adb shell input keyevent KEYCODE_ENTER` if not_responding_package == 'com.android.systemui' `adb shell input keyevent KEYCODE_DPAD_DOWN` `adb shell input keyevent KEYCODE_ENTER` end end sleep(10) current_uptime_value = `#{check_emu_uptime}`.strip.to_f end UI.important('Reached timeout before emulator is idle 😕') if current_uptime_value > params[:load_threshold] UI.important("Waited until emulator is idle for #{(Time.now - start_time).to_i} seconds ⌛️") end |