fastlane-plugin-android_emulator 0.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6ae1d26eff6437f47f28af479ac38c7f73e549a8
4
- data.tar.gz: b23b045f89541ecdc445ee78e1dbbdcd7f75e3ce
2
+ SHA256:
3
+ metadata.gz: c342be284340d90d3080c8548d3eeeeabb7d0c36f59029f2e8e8e9e762a64dca
4
+ data.tar.gz: 67f0593397dbe0179bbee05734668e3bc1ca38ffd9da6ed1780608c127f93e55
5
5
  SHA512:
6
- metadata.gz: 8ed7317eb7423db1d580c363a6948b7fce3d9d73319c3230cb292eff0e304c6102e2266f2c2f0e5d0b283ca10812775d819392269090eb91e47e83fb819c078a
7
- data.tar.gz: 06c221714b1856cb5cfb19f5d52f1461beabe0fb9d68f7e7ecb8d78b45d148a3e0717bbefe9faa50f46f25e3c59e1b8f8e9a5d9a15b0ebd347ee6e4ea04f4940
6
+ metadata.gz: 25a713f0b52b55c5b78342cd3f977b68874e29239c5f6b2686abb9268d353241b3637b6b5e5be254424be7cd7b7556b2d34668f7a0c8168c5c46324aa4656796
7
+ data.tar.gz: 7385cc4e351984156f4f14f98b0e899f9a255345c56605f73e65d10260120e0ee911cc0124a1bb0a0242c35c182a9b4915a86c08f41034394679da40e144da4c
data/README.md CHANGED
@@ -13,6 +13,7 @@ fastlane add_plugin android_emulator
13
13
  ## About android_emulator
14
14
 
15
15
  Creates and starts a new Android Emulator (AVD)
16
+
16
17
  With additional features:
17
18
 
18
19
  * set location
@@ -20,12 +21,16 @@ With additional features:
20
21
 
21
22
  ## Example
22
23
 
24
+ **Available Options:** sdk_dir, package, name, device, port, location, demo_mode, cold_boot
25
+
23
26
  ```ruby
24
27
  android_emulator(
25
28
  location: '9.1808 48.7771',
26
29
  package: "system-images;android-24;google_apis;x86_64",
27
30
  demo_mode: true,
28
- sdk_dir: "PATH_TO_SDK"
31
+ sdk_dir: "PATH_TO_SDK",
32
+ device: "Nexus 5",
33
+ cold_boot: false
29
34
  )
30
35
  ```
31
36
 
@@ -39,11 +44,12 @@ ENV["AVD_PACKAGE"] = "system-images;android-24;google_apis;x86_64"
39
44
  android_sdk_update(
40
45
  additional_packages: [
41
46
  ENV["AVD_PACKAGE"],
42
- "emulator"]
47
+ "emulator"
48
+ ]
43
49
  )
44
50
 
45
51
  android_emulator(
46
- location: '9.1808 48.7771'
52
+ location: '9.1808 48.7771'
47
53
  )
48
54
  ```
49
55
 
@@ -3,45 +3,50 @@ require_relative '../helper/android_emulator_helper'
3
3
 
4
4
  module Fastlane
5
5
  module Actions
6
- module SharedValues
7
- ANDROID_SDK_DIR = :ANDROID_SDK_DIR
8
- end
9
-
10
6
  class AndroidEmulatorAction < Action
7
+ def self.avd_active(params)
8
+ image = params[:package].gsub(";", "/")
9
+ return File.readlines("#{Dir.home}/.android/avd/#{params[:name]}.avd/config.ini").grep(/#{image}/).size > 0
10
+ end
11
+
11
12
  def self.run(params)
12
13
  sdk_dir = params[:sdk_dir]
14
+ port = params[:port]
13
15
  adb = "#{sdk_dir}/platform-tools/adb"
14
16
 
15
17
  UI.message("Stopping emulator")
16
18
  system("#{adb} emu kill > /dev/null 2>&1 &")
17
-
18
- UI.message("Creating new emulator")
19
- FastlaneCore::CommandExecutor.execute(
20
- command: "#{sdk_dir}/tools/bin/avdmanager create avd -n '#{params[:name]}' -f -k '#{params[:package]}' -d 'Nexus 5'",
21
- print_all: true,
22
- print_command: false
23
- )
24
-
25
- UI.message("Override configuration")
26
- open("#{Dir.home}/.android/avd/#{params[:name]}.avd/config.ini", 'a') { |f|
27
- f << "hw.gpu.mode=auto\n"
28
- f << "hw.gpu.enabled=yes\n"
29
- f << "skin.dynamic=yes\n"
30
- f << "skin.name=1080x1920\n"
31
- }
19
+ sleep(3)
20
+
21
+ if !avd_active(params) || params[:cold_boot]
22
+ UI.message("Creating new emulator")
23
+ FastlaneCore::CommandExecutor.execute(
24
+ command: "#{sdk_dir}/tools/bin/avdmanager create avd -n '#{params[:name]}' -f -k '#{params[:package]}' -d '#{params[:device]}'",
25
+ print_all: true,
26
+ print_command: false
27
+ )
28
+
29
+ UI.message("Override configuration")
30
+ open("#{Dir.home}/.android/avd/#{params[:name]}.avd/config.ini", 'a') { |f|
31
+ f << "hw.gpu.mode=auto\n"
32
+ f << "hw.gpu.enabled=yes\n"
33
+ f << "skin.dynamic=yes\n"
34
+ f << "skin.name=1080x1920\n"
35
+ }
36
+ end
32
37
 
33
38
  # Verify HAXM installed on mac
34
39
  if FastlaneCore::Helper.mac?
35
40
  kextstat = Actions.sh("kextstat", log: false)
36
41
 
37
- UI.user_error! "Please install the HAXM-Extension" unless kextstat.include?("intel")
42
+ UI.important("Please install the HAXM-Extension for better performance") unless kextstat.include?("intel")
38
43
  end
39
44
 
40
45
  UI.message("Starting emulator")
41
- system("LC_NUMERIC=C; #{sdk_dir}/tools/emulator @#{params[:name]} > /dev/null 2>&1 &")
46
+ system("LC_NUMERIC=C; #{sdk_dir}/emulator/emulator @#{params[:name]} -port #{port} > /dev/null 2>&1 &")
42
47
  sh("#{adb} -e wait-for-device")
43
48
 
44
- until Actions.sh("#{adb} -e shell getprop init.svc.bootanim", log: false).include? "stopped" do
49
+ until Actions.sh("#{adb} -e shell getprop dev.bootcomplete", log: false).strip == "1" do
45
50
  sleep(5)
46
51
  end
47
52
 
@@ -55,6 +60,8 @@ module Fastlane
55
60
  sh("#{adb} -e shell settings put global sysui_demo_allowed 1")
56
61
  sh("#{adb} -e shell am broadcast -a com.android.systemui.demo -e command clock -e hhmm 0700")
57
62
  end
63
+
64
+ ENV['SCREENGRAB_SPECIFIC_DEVICE'] = "emulator-#{port}"
58
65
  end
59
66
 
60
67
  def self.description
@@ -81,7 +88,7 @@ module Fastlane
81
88
  FastlaneCore::ConfigItem.new(key: :sdk_dir,
82
89
  env_name: "ANDROID_SDK_DIR",
83
90
  description: "Path to the Android SDK DIR",
84
- default_value: Actions.lane_context[SharedValues::ANDROID_SDK_DIR],
91
+ default_value: ENV['ANDROID_HOME'] || ENV['ANDROID_SDK_ROOT'] || ENV['ANDROID_SDK'],
85
92
  optional: false,
86
93
  verify_block: proc do |value|
87
94
  UI.user_error!("No ANDROID_SDK_DIR given, pass using `sdk_dir: 'sdk_dir'`") unless value and !value.empty?
@@ -95,6 +102,16 @@ module Fastlane
95
102
  description: "Name of the AVD",
96
103
  default_value: "fastlane",
97
104
  optional: false),
105
+ FastlaneCore::ConfigItem.new(key: :device,
106
+ env_name: "AVD_DEVICE",
107
+ description: "Device",
108
+ default_value: "Nexus 5",
109
+ optional: false),
110
+ FastlaneCore::ConfigItem.new(key: :port,
111
+ env_name: "AVD_PORT",
112
+ description: "Port of the emulator",
113
+ default_value: "5554",
114
+ optional: false),
98
115
  FastlaneCore::ConfigItem.new(key: :location,
99
116
  env_name: "AVD_LOCATION",
100
117
  description: "Set location of the the emulator '<longitude> <latitude>'",
@@ -103,7 +120,12 @@ module Fastlane
103
120
  env_name: "AVD_DEMO_MODE",
104
121
  description: "Set the emulator in demo mode",
105
122
  is_string: false,
106
- default_value: true)
123
+ default_value: true),
124
+ FastlaneCore::ConfigItem.new(key: :cold_boot,
125
+ env_name: "AVD_COLD_BOOT",
126
+ description: "Create a new AVD every run",
127
+ is_string: false,
128
+ default_value: false)
107
129
  ]
108
130
  end
109
131
 
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module AndroidEmulator
3
- VERSION = "0.1.0"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-android_emulator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Ruhl
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-25 00:00:00.000000000 Z
11
+ date: 2021-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -136,7 +136,7 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: 2.78.0
139
- description:
139
+ description:
140
140
  email: michael.ruhl@novatec-gmbh.de
141
141
  executables: []
142
142
  extensions: []
@@ -152,7 +152,7 @@ homepage: https://github.com/NovaTecConsulting/fastlane-plugin-android_emulator
152
152
  licenses:
153
153
  - MIT
154
154
  metadata: {}
155
- post_install_message:
155
+ post_install_message:
156
156
  rdoc_options: []
157
157
  require_paths:
158
158
  - lib
@@ -167,9 +167,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
167
  - !ruby/object:Gem::Version
168
168
  version: '0'
169
169
  requirements: []
170
- rubyforge_project:
171
- rubygems_version: 2.6.10
172
- signing_key:
170
+ rubygems_version: 3.1.2
171
+ signing_key:
173
172
  specification_version: 4
174
173
  summary: Creates and starts an Android Emulator (AVD)
175
174
  test_files: []