Skip to content

Commit

Permalink
Check and install missing system images packages before creating emul…
Browse files Browse the repository at this point in the history
…ators.
  • Loading branch information
mik9 committed Mar 27, 2018
1 parent 0585a2f commit 48fd6ba
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,16 @@ def self.run(params)
UI.message("Configuring environment in order to launch emulators: ".yellow)
UI.message("Getting avaliable AVDs".yellow)
devices = Action.sh(adb_controller.command_get_avds)

for i in 0...avd_schemes.length
packages = Action.sh(adb_controller.command_get_installed_packages)

for i in 0...avd_schemes.length
unless packages.match(avd_schemes[i].create_avd_package + "\\s*|").nil?
UI.message(["Missing package ", avd_schemes[i].create_avd_package, " installing..."].join("").yellow)
Action.sh(avd_controllers[i].command_install_package)
else
UI.message(["Package ", avd_schemes[i].create_avd_package, " already installed"].join("").yellow)
end

unless devices.match(avd_schemes[i].avd_name).nil?
UI.message(["AVD with name '", avd_schemes[i].avd_name, "' currently exists."].join("").yellow)
if params[:AVD_recreate_new]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class ADB_Controller
:command_get_devices,
:command_wait_for_device,
:command_get_avds,
:command_get_installed_packages,
:adb_path
end

Expand All @@ -18,6 +19,7 @@ def self.get_adb_controller(params)
# Get paths
path_sdk = "#{params[:SDK_path]}"
path_avdmanager_binary = path_sdk + "/tools/bin/avdmanager"
path_sdkmanager_binary = path_sdk + "/tools/bin/sdkmanager"
path_adb = path_sdk + "/platform-tools/adb"

# ADB shell command parts
Expand Down Expand Up @@ -54,6 +56,11 @@ def self.get_adb_controller(params)
adb_controller.command_get_avds = [
path_avdmanager_binary,
sh_list_avd_adb].join(" ").chomp

adb_controller.command_get_installed_packages = [
path_sdkmanager_binary,
"--list"
].join(" ")

return adb_controller
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Fastlane
module Factory

class AVD_Controller
attr_accessor :command_create_avd, :command_start_avd, :command_delete_avd, :command_apply_config_avd, :command_get_property, :command_kill_device,
attr_accessor :command_install_package, :command_create_avd, :command_start_avd, :command_delete_avd, :command_apply_config_avd, :command_get_property, :command_kill_device,
:output_file

def self.create_output_file(params)
Expand All @@ -20,6 +20,7 @@ def self.get_avd_controller(params, avd_scheme)
# Get paths
path_sdk = "#{params[:SDK_path]}"
path_avdmanager_binary = path_sdk + "/tools/bin/avdmanager"
path_sdkmanager_binary = path_sdk + "/tools/bin/sdkmanager"
path_adb = path_sdk + "/platform-tools/adb"
path_avd = "#{params[:AVD_path]}"

Expand Down Expand Up @@ -122,6 +123,11 @@ def self.get_avd_controller(params, avd_scheme)
sh_kill_device,
"&>/dev/null"].join(" ")

avd_controller.command_install_package = [
path_sdkmanager_binary,
"\"" + avd_scheme.create_avd_package + "\""
].join(" ")

return avd_controller
end
end
Expand Down

0 comments on commit 48fd6ba

Please sign in to comment.