class Fastlane::Helper::EmulatorCommander
Attributes
container_name[RW]
Public Class Methods
new(container_name)
click to toggle source
# File lib/fastlane/plugin/mango/helper/emulator_commander.rb, line 8 def initialize(container_name) @container_name = container_name @docker_commander = DockerCommander.new(container_name) end
Public Instance Methods
check_connection()
click to toggle source
Restarts adb on the separate port and checks if created emulator is connected
# File lib/fastlane/plugin/mango/helper/emulator_commander.rb, line 36 def check_connection UI.success('Checking if emulator is connected to ADB.') if emulator_is_healthy? UI.success('Emulator connected successfully') true else UI.important("Something went wrong. Newly created device couldn't connect to the adb") false end end
disable_animations()
click to toggle source
Disables animation for faster and stable testing
# File lib/fastlane/plugin/mango/helper/emulator_commander.rb, line 14 def disable_animations @docker_commander.exec(command: 'adb shell settings put global window_animation_scale 0.0') @docker_commander.exec(command: 'adb shell settings put global transition_animation_scale 0.0') @docker_commander.exec(command: 'adb shell settings put global animator_duration_scale 0.0') rescue FastlaneCore::Interface::FastlaneShellError => e # Under weird circumstances it can happen that adb is running but shell on the emu is not completely up # it recovers after some time, so wait and retry retry_counter = retry_counter.to_i + 1 if retry_counter <= 5 sleep 10 * retry_counter retry else raise e end end
emulator_is_healthy?()
click to toggle source
# File lib/fastlane/plugin/mango/helper/emulator_commander.rb, line 48 def emulator_is_healthy? list_devices = @docker_commander.exec(command: 'adb devices') list_devices.include? "\tdevice" rescue FastlaneCore::Interface::FastlaneShellError => e # Under weird circumstances it can happen that adb is running but adb is not completely up # it recovers after some time, so wait and retry retry_counter = retry_counter.to_i + 1 if retry_counter <= 5 sleep 10 * retry_counter retry else raise e end end
increase_logcat_storage()
click to toggle source
Increases logcat storage
# File lib/fastlane/plugin/mango/helper/emulator_commander.rb, line 31 def increase_logcat_storage @docker_commander.exec(command: 'adb logcat -G 16m') end