Class: Fastlane::Actions::AndroidCreateAvdAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_create_avd_action.rb

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



81
82
83
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_create_avd_action.rb', line 81

def self.authors
  ['Automattic']
end

.available_optionsObject



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
66
67
68
69
70
71
72
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_create_avd_action.rb', line 40

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :device_model,
                                 env_name: 'FL_ANDROID_CREATE_AVD_DEVICE_MODEL',
                                 description: 'The device model code to use to create the AVD. Valid values can be found using `avdmanager list devices`',
                                 type: String,
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :api_level,
                                 env_name: 'FL_ANDROID_CREATE_AVD_API_LEVEL',
                                 description: 'The API level to use to install the necessary system-image and create the AVD',
                                 type: Integer,
                                 optional: false),
    FastlaneCore::ConfigItem.new(key: :avd_name,
                                 env_name: 'FL_ANDROID_CREATE_AVD_AVD_NAME',
                                 description: 'The name to give to the created AVD. If not provided, will be derived from device model and API level',
                                 type: String,
                                 optional: true,
                                 default_value: nil),
    FastlaneCore::ConfigItem.new(key: :sdcard,
                                 env_name: 'FL_ANDROID_CREATE_AVD_SDCARD',
                                 description: 'The size of the SD card to use for the AVD',
                                 type: String,
                                 optional: true,
                                 default_value: '512M'),
    FastlaneCore::ConfigItem.new(key: :system_image,
                                 env_name: 'FL_ANDROID_CREATE_AVD_SYSTEM_IMAGE',
                                 description: 'The system image to use (as used/listed by `sdkmanager`). Defaults to the appropriate system image given the API level requested and the current machine\'s architecture',
                                 type: String,
                                 optional: true,
                                 default_value_dynamic: true,
                                 default_value: nil),
  ]
end

.descriptionObject



29
30
31
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_create_avd_action.rb', line 29

def self.description
  'Creates a new Android Virtual Device (AVD) for a specific device model and API level'
end

.detailsObject



33
34
35
36
37
38
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_create_avd_action.rb', line 33

def self.details
  <<~DESC
    Creates a new Android Virtual Device (AVD) for a specific device model and API level.
    By default, it also installs the necessary system image (using `sdkmanager`) if needed before creating the AVD
  DESC
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_create_avd_action.rb', line 85

def self.is_supported?(platform)
  platform == :android
end

.outputObject



74
75
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_create_avd_action.rb', line 74

def self.output
end

.return_valueObject



77
78
79
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_create_avd_action.rb', line 77

def self.return_value
  'Returns the name of the created AVD'
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_create_avd_action.rb', line 4

def self.run(params)
  device_model = params[:device_model]
  api_level = params[:api_level]
  avd_name = params[:avd_name]
  sdcard = params[:sdcard]

  helper = Fastlane::Helper::Android::EmulatorHelper.new

  # Ensure we have the system image needed for creating the AVD with this API level
  system_image = params[:system_image] || helper.install_system_image(api: api_level)

  # Create the AVD for device, API and system image we need
  helper.create_avd(
    api: api_level,
    device: device_model,
    system_image: system_image,
    name: avd_name,
    sdcard: sdcard
  )
end