lib/ruboto/util/emulator.rb in ruboto-0.13.0 vs lib/ruboto/util/emulator.rb in ruboto-0.14.0
- old
+ new
@@ -4,12 +4,12 @@
module Util
module Emulator
ON_WINDOWS = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw/i)
API_LEVEL_TO_VERSION = {
- 7 => '2.1', 8 => '2.2', 10 => '2.3.3', 11 => '3.0', 12 => '3.1',
- 13 => '3.2', 14 => '4.0', 15 => '4.0.3', 16 => '4.1.2', 17 => '4.2.2',
+ 10 => '2.3.3', 11 => '3.0', 12 => '3.1', 13 => '3.2', 14 => '4.0',
+ 15 => '4.0.3', 16 => '4.1.2', 17 => '4.2.2',
}
def sdk_level_name(sdk_level)
API_LEVEL_TO_VERSION[sdk_level]
end
@@ -50,10 +50,11 @@
end
else
puts 'No emulator is running.'
end
+ # FIXME(uwe): Change use of "killall" to use the Ruby Process API
loop do
`killall -0 #{emulator_cmd} 2> /dev/null`
if $? == 0
`killall #{emulator_cmd}`
10.times do |i|
@@ -81,20 +82,22 @@
abi_opt = '--abi armeabi-v7a'
elsif sdk_level == 10
abi_opt = '--abi armeabi'
end
- unless File.exists? "#{ENV['HOME']}/.android/avd/#{avd_name}.avd"
+ avd_home = "#{ENV['HOME'].gsub('\\', '/')}/.android/avd/#{avd_name}.avd"
+ unless File.exists? avd_home
puts "Creating AVD #{avd_name}"
puts `echo n | android create avd -a -n #{avd_name} -t android-#{sdk_level} #{abi_opt} -c 64M -s HVGA`
if $? != 0
puts 'Failed to create AVD.'
exit 3
end
- avd_config_file_name = "#{ENV['HOME']}/.android/avd/#{avd_name}.avd/config.ini"
+ avd_config_file_name = "#{avd_home}/config.ini"
old_avd_config = File.read(avd_config_file_name)
- heap_size = (File.read('AndroidManifest.xml') =~ /largeHeap/) ? 256 : 48
+ manifest_file = 'AndroidManifest.xml'
+ heap_size = (File.exists?(manifest_file) && File.read(manifest_file) =~ /largeHeap/) ? 256 : 48
new_avd_config = old_avd_config.gsub(/vm.heapSize=([0-9]*)/) { |m| p m; m.to_i < heap_size ? "vm.heapSize=#{heap_size}" : m }
File.write(avd_config_file_name, new_avd_config) if new_avd_config != old_avd_config
new_snapshot = true
end
@@ -161,10 +164,10 @@
(
set +e
for i in 1 2 3 4 5 6 7 8 9 10 ; do
sleep 6
adb shell input keyevent 82 >/dev/null 2>&1
- if [ "$?" == "0" ] ; then
+ if [ "$?" = "0" ] ; then
set -e
adb shell input keyevent 82 >/dev/null 2>&1
adb shell input keyevent 4 >/dev/null 2>&1
exit 0
fi