ruboto 1.5.0 → 1.6.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
2
  SHA1:
3
- metadata.gz: 5cf1877943572ab84d12119768dd14f3f78974f0
4
- data.tar.gz: 2ae6f50b354303637f7b7cd5274f74de10648182
3
+ metadata.gz: 722d788ed8cf384285ca9fda8e6d810dbb8f53d8
4
+ data.tar.gz: b9c965d06f1ad9e654c7dfdc812091eb9cbfa730
5
5
  SHA512:
6
- metadata.gz: 34824bba9512f51cd583fd61e51e018b636d24a12ed39923d128b2f45ddb6c86aaa5e3fdd1a3ccb5511a459e6f9bb19973279e8be2233a87a4da67a416c46a9e
7
- data.tar.gz: ef88fdcd111e94f71a4c88509b98c7e5bbdb342a736350539b1b5cff4bf3b7f8cf2c30a5d5c0eddd265f9249e1522c9d87aee2e2f22e0aa487d6bde6a5da94c4
6
+ metadata.gz: 87fafecf9b75f9f5693b0a1bc89ea745abd400c4f51dccce0e0bebd1952768323f6a9bd425ff2a38b8eab30d89befa372af1ecadcd6d0e47f1e39553007bf010
7
+ data.tar.gz: 8b70573fda9f044cdbe0ee8e3ae77219be65de682094be742bb65269db9d170d9df040d5526c0226e1812e9f665ba82a1abb399ff70adfa8b3d706c25153b9d2
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruboto (1.5.0.dev)
4
+ ruboto (1.6.0)
5
5
  main (~> 5.2)
6
6
  net-telnet (~> 0.1.1)
7
- rake (~> 11.3)
7
+ rake (>= 11.3, < 13)
8
8
  rubyzip (~> 1.0)
9
9
 
10
10
  GEM
@@ -22,13 +22,13 @@ GEM
22
22
  pry (>= 0.9)
23
23
  map (6.6.0)
24
24
  method_source (0.8.2)
25
- minitest (5.8.4)
25
+ minitest (5.10.1)
26
26
  net-telnet (0.1.1)
27
27
  pry (0.10.4)
28
28
  coderay (~> 1.1.0)
29
29
  method_source (~> 0.8.1)
30
30
  slop (~> 3.4)
31
- rake (11.3.0)
31
+ rake (12.0.0)
32
32
  rubyzip (1.2.0)
33
33
  slop (3.6.0)
34
34
 
@@ -1,11 +1,11 @@
1
- Subject: [ANN] Ruboto 1.5.0 release candidate
1
+ Subject: [ANN] Ruboto 1.6.0 release candidate
2
2
 
3
3
  Hi all!
4
4
 
5
- The Ruboto 1.5.0 release candidate is now available.
5
+ The Ruboto 1.6.0 release candidate is now available.
6
6
 
7
- We now have properly working Ruby SSL and HTTPS! You need jruby-jars
8
- 1.7.25 and Android 4.4 or better :)
7
+ In this release we add support for Android 7.0 and 7.1 "Nougat" and update
8
+ the Android SDK to level 25.
9
9
 
10
10
  As always we need your help and feedback to ensure the quality of the release. Please install the release candidate using
11
11
 
@@ -1,6 +1,6 @@
1
- Subject: [ANN] Ruboto 1.5.0 released!
1
+ Subject: [ANN] Ruboto 1.6.0 released!
2
2
 
3
- The Ruboto team is pleased to announce the release of Ruboto 1.5.0.
3
+ The Ruboto team is pleased to announce the release of Ruboto 1.6.0.
4
4
 
5
5
  Ruboto (JRuby on Android) is a platform for developing full stand-alone
6
6
  apps for Android using the Ruby language and libraries. It includes
@@ -8,59 +8,47 @@ support libraries and generators for creating projects, classes, tests,
8
8
  and more. The complete APIs of Android, Java, and Ruby are available to
9
9
  you using the Ruby language.
10
10
 
11
- New in version 1.5.0:
11
+ New in version 1.6.0:
12
12
 
13
- We now have properly working Ruby SSL and HTTPS! You need jruby-jars
14
- 1.7.25 and Android 4.4 or better :)
13
+ In this release we add support for Android 7.0 and 7.1 "Nougat" and update
14
+ the Android SDK to level 25.
15
15
 
16
16
  API Changes:
17
17
 
18
- * Issue #713 Add support for Android 5.1 Lollipop
19
- * Issue #768 Add support for Android 6.0 Marshmallow
18
+ * Issue #816 Set default api level for new apps to 19 (Android 4.4
19
+ KitKat)
20
+ * Issue #821 Update to Android SDK Tools 25
21
+ * Issue #826 Rename 'assert_matches' to 'assert_match' for Minitest
22
+ compatibility
20
23
 
21
24
  Features:
22
25
 
23
- * Issue #791 Update RubotoCore to ActiveRecord 4.2
24
- * Issue #792 Set emulator name in ruboto.yml
25
- * Issue #795 Set emulator device name in ruboto.yml
26
- * Issue #797 Set emulator skin name in ruboto.yml
27
- * Issue #798 ruboto.yml emulator config (donv)
28
- * Issue #805 Add support for the new emulator 2.0
26
+ * Issue #815 Add support for Android 7 Nougat
27
+ * Issue #817 Add support for Android 7.1
28
+ * Issue #819 Add support for concurrent-ruby gem
29
+ * Issue #820 Reload scripts with large stack during 'rake boing'
29
30
 
30
31
  Bugfixes:
31
32
 
32
- * Issue #726 Any reference to net/https throws LoadError for
33
- org/bouncycastle/bcpkix-jdk15on/1.47/bcpkix-jdk15on-1.47
34
- * Issue #793 Fix OpenSSL
35
- * Issue #796 Adds a setting in "ruboto.yml" for the desired
36
- dex_heap_size (lucasallan)
37
- * Issue #807 Fix SDK_DOWNLOAD_PAGE link (LucianoPC)
33
+ * Issue #813 ArgumentError creating new emulator image (AVD)
34
+ * Issue #818 Error when creating a new emulator image for an app with
35
+ empty ruboto.yml
38
36
 
39
37
  Support:
40
38
 
41
- * Issue #802 java.lang.UnsupportedOperationException: can't load this
42
- type of class file
43
- * Issue #803 (NoMethodError) undefined method 'current' for
44
- Java::JavaLang::Thread:Class
45
-
46
- Community:
47
-
48
- * Issue #666 Set up donations and sponsoring of the Ruboto project
49
-
50
- Pull requests:
51
-
52
- * Issue #794 Test ssl (donv)
53
- * Issue #812 Set ANDROID_EMULATOR_FORCE_32BIT to fix broken build
54
- (celeduc)
39
+ * Issue #809 [Solved] JRuby 1.7.22 and Crosswalk issue (multidex)
40
+ Verification error in java.io.File[]
41
+ org.jruby.util.JRubyFile.listRoots()
42
+ * Issue #822 How well does Ruboto work with Shoes 4?
55
43
 
56
44
  Internal:
57
45
 
58
- * Issue #775 Release 1.5.0
59
- * Issue #808 Bug fixes (donv)
46
+ * Issue #828 More test parts (donv)
47
+ * Issue #829 Use the new authenticated protocol to manage emulators
60
48
 
61
49
  You can find a complete list of issues here:
62
50
 
63
- * https://github.com/ruboto/ruboto/issues?state=closed&milestone=41
51
+ * https://github.com/ruboto/ruboto/issues?state=closed&milestone=42
64
52
 
65
53
 
66
54
  Installation:
data/Rakefile CHANGED
@@ -538,38 +538,39 @@ task :get_jruby_jars_snapshots do
538
538
  end
539
539
  end
540
540
 
541
+ def test_parts(api)
542
+ (api == 23) ? 6 : 3
543
+ end
544
+
541
545
  task '.travis.yml' do
542
546
  puts "Regenerating #{'.travis.yml'}"
543
547
  source = File.read('.travis.yml')
544
- test_parts = 3
545
548
  matrix = ''
546
549
  allow_failures = ''
547
550
 
548
- # FIXME(uwe): JRuby 1.7.13 works for Nettbuss. Keep for 2016.
549
551
  # FIXME(uwe): Test all of these that work
550
552
  [
551
553
  # ['CURRENT', [nil]], # Running standalone is the most important way now
552
554
  # ['FROM_GEM', [:MASTER, :STABLE]], # Running standalone is the most important way now
553
- ['STANDALONE', [:MASTER, :STABLE, '1.7.25', '1.7.13']],
555
+ ['STANDALONE', [:MASTER, :STABLE, '1.7.25']],
554
556
  ].each do |platform, versions|
555
557
  versions.each do |v|
556
558
  # FIXME(uwe): Test the newest and most common api levels
557
- # FIXME(uwe): Nettbuss uses api level 15. Keep for 2017.
558
559
  # FIXME(uwe): https://github.com/ruboto/ruboto/issues/426
559
- [23, 22, 21, 19, 17, 15].each do |api|
560
- (1..test_parts).each do |n|
561
- line = " - ANDROID_TARGET=#{api} RUBOTO_PLATFORM=#{platform.ljust(10)} TEST_PART=#{n}of#{test_parts}#{" JRUBY_JARS_VERSION=#{v}" if v}\n"
562
-
563
- next if api == 23 # FIXME(uwe): Remove when Android 6.0 is green. Unable to start emulator on travis.
560
+ [25, 24, 23, 22, 21, 19].each do |api|
561
+ (1..test_parts(api)).each do |n|
562
+ line = " - ANDROID_TARGET=#{api} RUBOTO_PLATFORM=#{platform.ljust(10)} TEST_PART=#{n}of#{test_parts(api)}#{" JRUBY_JARS_VERSION=#{v}" if v}\n"
563
+
564
+ next if v == :MASTER || v == :STABLE
565
+ next if api == 25 # FIXME(uwe): Remove when Android 7.1 is green. No runnable ABIs on travis.
566
+ # next if api == 24 # FIXME(uwe): Remove when Android 7.0 is green. No space left on device on travis.
567
+ next if api == 23 # FIXME(uwe): Remove when Android 7.0 is green. No space left on device on travis.
564
568
  next if api == 22 # FIXME(uwe): Remove when Android 5.1 is green. Must use slow ARM emulator due to missing HAXM.
565
569
  next if api == 22 && platform == 'STANDALONE' && v == :STABLE # FIXME(uwe): Remove when Android 5.1 is green. Must use slow ARM emulator due to missing HAXM.
566
570
  next if api == 21 # FIXME(uwe): Remove when Android 5.0 is green.
567
- next if api == 17 # FIXME(uwe): Remove when Android 4.2 is green.
568
571
 
569
- if v == :MASTER || v == :STABLE
570
- # allow_failures << line.gsub('-', '- env:')
571
- next
572
- end
572
+ (allow_failures << line.gsub('-', '- env:')) if api == 24 # FIXME(uwe): Remove when Android 6.0 is green. Unable to start emulator on travis.
573
+
573
574
  matrix << line
574
575
  end
575
576
  end
@@ -27,7 +27,7 @@ Vagrant.configure(2) do |config|
27
27
  end
28
28
 
29
29
  config.vm.define 'ubuntu' do |ubuntu|
30
- ubuntu.vm.box = 'ubuntu/trusty64'
30
+ ubuntu.vm.box = 'ubuntu/precise64'
31
31
  ubuntu.vm.provision :shell, inline: create_swap(1536)
32
32
  ubuntu.vm.provision :shell, inline: <<-SHELL
33
33
  sudo apt-get -y install git libc6-i386 lib32stdc++6 lib32gcc1 lib32ncurses5 lib32z1
@@ -36,6 +36,7 @@ Vagrant.configure(2) do |config|
36
36
  su - vagrant -c 'mkdir -p ruboto'
37
37
  su - vagrant -c 'rsync -acPuv --exclude adb_logcat.log --exclude /tmp /vagrant/* ruboto/'
38
38
  sudo apt-get -y autoremove
39
+ sudo timedatectl set-timezone #{Time.now.zone}
39
40
  SHELL
40
41
  end
41
42
 
@@ -3,7 +3,9 @@
3
3
  # Methods for package installation
4
4
  #
5
5
 
6
- APK_FILE_REGEXP = /^-rw-r--r--\s+(?:system|\d+\s+\d+)\s+(?:system|\d+)\s+(\d+)\s+(\d{4}-\d{2}-\d{2} \d{2}:\d{2}|\w{3} \d{2}\s+(?:\d{4}|\d{2}:\d{2}))\s+(.*)$/
6
+ # Android 7.1: -rw-r--r-- 1 system system 9462614 2016-11-24 13:20 /data/app/org.ruboto.test_app-1/base.apk
7
+ # Android 6.0: -rw-r--r-- system system 9462797 2016-11-24 13:05 base.apk
8
+ APK_FILE_REGEXP = /^-rw-r--r--(?:\s+\d+)?\s+(?:system|\d+\s+\d+)\s+(?:system|\d+)\s+(\d+)\s+(\d{4}-\d{2}-\d{2} \d{2}:\d{2}|\w{3} \d{2}\s+(?:\d{4}|\d{2}:\d{2}))\s+(.*)$/
7
9
  PROJECT_DIR = File.expand_path('..', File.dirname(__FILE__))
8
10
  UPDATE_MARKER_FILE = File.join(PROJECT_DIR, 'bin', 'LAST_UPDATE')
9
11
 
@@ -15,8 +17,8 @@ def package_installed?(package_name, apk_file)
15
17
  loop do
16
18
  path_line = `adb shell pm path #{package_name}`.chomp
17
19
  path_line.gsub! /^WARNING:.*$/, ''
18
- return nil if $? == 0 && path_line.empty?
19
- break if $? == 0 && path_line =~ /^package:(.*)$/
20
+ return nil if $? != 0 || path_line.empty?
21
+ break if path_line =~ /^package:(.*)$/
20
22
  puts path_line
21
23
  sleep 0.5
22
24
  end
@@ -58,8 +60,8 @@ def clear_update(package, apk_file)
58
60
  end
59
61
 
60
62
  def device_path_exists?(path)
61
- path_output =`adb shell ls #{path}`
62
- path_output.chomp !~ /No such file or directory|opendir failed, Permission denied/
63
+ path_output = `adb shell ls #{path} 2>&1`.chomp
64
+ path_output.empty? || path_output !~ /No such file or directory|opendir failed, Permission denied/
63
65
  end
64
66
 
65
67
  def wait_for_valid_device
@@ -70,73 +72,86 @@ def wait_for_valid_device
70
72
  end
71
73
  end
72
74
 
75
+ # Synchronize device system time with development system time.
76
+ def set_device_time
77
+ # TODO: (uwe) Remove when we stop supporting Android 6.0 and older
78
+ if sdk_level <= 23
79
+ return sh "adb shell date -s #{Time.now.strftime '%Y%m%d.%H%M%S'}"
80
+ end
81
+ # ODOT
82
+
83
+ sh "adb shell date +'%Y%m%d.%H%M%S' #{Time.now.strftime '%Y%m%d.%H%M%S'}"
84
+ end
85
+
73
86
  def install_apk(package, apk_file)
74
87
  wait_for_valid_device
75
-
76
88
  failure_pattern = /^Failure \[(.*)\]/
77
89
  success_pattern = /^Success/
78
- install_timeout = 900
90
+ install_timeout = 5 * 60
79
91
  case package_installed?(package, apk_file)
80
92
  when true
81
93
  puts "Package #{package} already installed."
82
94
  return
83
95
  when false
84
- puts "Package #{package} already installed, but of different size or timestamp. Replacing package."
85
- sh "adb shell date -s #{Time.now.strftime '%Y%m%d.%H%M%S'}"
86
- output = nil
87
- install_retry_count = 0
96
+ puts "Package #{package} already installed, but of different size or timestamp."
97
+ replace_apk = true
98
+ else
99
+ # Package not installed.
100
+ end
101
+
102
+ set_device_time
103
+ output = nil
104
+ 5.times do |install_retry_count|
105
+ if install_retry_count > 0
106
+ puts output
107
+ puts 'Retrying install...'
108
+ end
109
+ # replace_apk ||= install_retry_count >= 3
110
+ puts "#{replace_apk ? 'Replacing' : 'Installing'} package #{package}"
111
+
112
+ install_start = Time.now
88
113
  begin
89
114
  Timeout.timeout install_timeout do
90
- output = `adb install -r "#{apk_file}" 2>&1`
115
+ output = `adb install #{'-r' if replace_apk} "#{apk_file}" 2>&1`
91
116
  end
92
117
  rescue Timeout::Error
93
118
  puts "Installing package #{package} timed out after #{install_timeout}s."
94
- install_retry_count += 1
95
- if install_retry_count <= 3
96
- puts 'Retrying install...'
97
- retry
98
- end
99
- puts 'Trying one final time to install the package:'
100
- output = `adb install -r "#{apk_file}" 2>&1`
119
+ next
101
120
  end
121
+
102
122
  if $? == 0 && output !~ failure_pattern && output =~ success_pattern
123
+ puts "Install took #{(Time.now - install_start).to_i}s."
103
124
  clear_update(package, apk_file)
104
125
  return
105
126
  end
106
127
  case $1
107
128
  when 'INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES'
108
129
  puts 'Found package signed with different certificate. Uninstalling it and retrying install.'
130
+ when 'INSTALL_FAILED_INVALID_URI', %r{failed to copy '(?:.*)' to '(.*)/RubotoTestApp-debug.apk': Read-only file system}
131
+ push_dir = $1 || '/data/local/tmp'
132
+ puts "Maybe wrong write permissions for APK push directory #{push_dir.inspect}. Changing permissions."
133
+ puts `adb shell ls -l #{File.dirname(push_dir)}`
134
+ puts `adb shell chmod a+rwx #{push_dir}`
135
+ puts `adb shell ls -l #{File.dirname(push_dir)}`
136
+ when 'INSTALL_FAILED_ALREADY_EXISTS'
137
+ puts 'Package allready exists.'
138
+ if replace_apk
139
+ puts 'Uninstalling package.'
140
+ else
141
+ replace_apk = true
142
+ next
143
+ end
109
144
  else
110
145
  puts "'adb install' returned an unknown error: (#$?) #{$1 ? "[#$1}]" : output}."
111
146
  puts "Uninstalling #{package} and retrying install."
112
147
  end
148
+
113
149
  uninstall_apk(package, apk_file)
114
- else
115
- # Package not installed.
116
- sh "adb shell date -s #{Time.now.strftime '%Y%m%d.%H%M%S'}"
150
+ replace_apk = false
117
151
  end
118
- puts "Installing package #{package}"
119
- output = nil
120
- install_retry_count = 0
121
- begin
122
- Timeout.timeout install_timeout do
123
- output = `adb install "#{apk_file}" 2>&1`
124
- end
125
- rescue Timeout::Error
126
- puts "Installing package #{package} timed out after #{install_timeout}s."
127
- install_retry_count += 1
128
- if install_retry_count <= 3
129
- puts 'Retrying install...'
130
- retry
131
- end
132
- puts 'Trying one final time to install the package:'
133
- install_start = Time.now
134
- output = `adb install "#{apk_file}" 2>&1`
135
- puts "Install took #{(Time.now - install_start).to_i}s."
136
- end
137
- puts output
138
- raise "Install failed (#{$?}) #{$1 ? "[#$1}]" : output}" if $? != 0 || output =~ failure_pattern || output !~ success_pattern
152
+
139
153
  clear_update(package, apk_file)
154
+ raise "Install failed (#{$?}) #{$1 ? "[#$1}]" : output}"
140
155
  end
141
156
 
142
157
  def uninstall_apk(package_name, apk_file)
@@ -231,16 +231,8 @@ file File.basename(MANIFEST_FILE) => MANIFEST_FILE
231
231
  file MANIFEST_FILE => PROJECT_PROPS_FILE do
232
232
  old_manifest = File.read(MANIFEST_FILE)
233
233
  manifest = old_manifest.dup
234
-
235
- # FIXME(uwe): Remove 'L' special case when Android L has been released.
236
- if sdk_level == 21
237
- manifest.sub!(/(android:minSdkVersion=').*?(')/) { "#{$1}L#{$2}" }
238
- manifest.sub!(/(android:targetSdkVersion=').*?(')/) { "#{$1}L#{$2}" }
239
- else
240
- manifest.sub!(/(android:minSdkVersion=').*?(')/) { "#{$1}#{sdk_level}#{$2}" }
241
- manifest.sub!(/(android:targetSdkVersion=').*?(')/) { "#{$1}#{sdk_level}#{$2}" }
242
- end
243
- # EMXIF
234
+ manifest.sub!(/(android:minSdkVersion=').*?(')/) { "#{$1}#{sdk_level}#{$2}" }
235
+ manifest.sub!(/(android:targetSdkVersion=').*?(')/) { "#{$1}#{sdk_level}#{$2}" }
244
236
 
245
237
  if manifest != old_manifest
246
238
  puts "\nUpdating #{File.basename MANIFEST_FILE} with target from #{File.basename PROJECT_PROPS_FILE}\n\n"
@@ -820,6 +812,24 @@ rescue Exception
820
812
  puts $!
821
813
  puts $!.backtrace.join("\n")
822
814
  raise
815
+ end
816
+ END_CODE
817
+ elsif jar =~ %r{concurrent_ruby_ext.jar$}
818
+ puts "Adding JRuby extension library initialization."
819
+ jar_load_code = <<-END_CODE
820
+ require 'jruby'
821
+ puts 'Starting ConcurrentRubyExtService'
822
+ public
823
+ begin
824
+ with_large_stack(2048) do
825
+ Java::ConcurrentRubyExtService.new.basicLoad(JRuby.runtime)
826
+ end
827
+ rescue Exception
828
+ puts "Exception starting ConcurrentRubyExtService"
829
+ puts "\#{$!.class} \#{$!.message}"
830
+ puts $!
831
+ puts $!.backtrace.join("\n")
832
+ raise
823
833
  end
824
834
  END_CODE
825
835
  else
@@ -920,7 +930,7 @@ end
920
930
  # Methods
921
931
 
922
932
  def sdk_level
923
- File.read(PROJECT_PROPS_FILE).scan(/(?:target=android-)(\d+)/)[0][0].to_i
933
+ File.read(PROJECT_PROPS_FILE).scan(/(?:target=(?:android|google_apis)-)(\d+)/)[0][0].to_i
924
934
  end
925
935
 
926
936
  def strings(name)
@@ -259,22 +259,6 @@ def cleanup_jars
259
259
  Java::json.ext.ParserService.new.basicLoad(JRuby.runtime)
260
260
  END_CODE
261
261
  elsif j =~ %r{jopenssl.jar$}
262
- # FIXME(uwe): Use our own patched version of OpenSSL until jruby-openssl 0.9.16 is released
263
- # FIXME(uwe): Remove before Ruboto release!
264
- # FIXME(uwe): Remove after jruby-openssl 0.9.16 is added to the jruby-1_7 branch
265
- if File.exists? 'org/jruby/ext/openssl/OpenSSL.class'
266
- puts '*' * 80
267
- puts 'Patching OpenSSL'
268
- FileUtils.rm 'org/jruby/ext/openssl/OpenSSL.class'
269
- FileUtils.mkdir_p '../../../src/org/jruby/ext/openssl'
270
- # require 'ruboto'
271
- # FileUtils.cp "#{Ruboto::ASSETS}/src/org/jruby/ext/openssl/OpenSSL.java",
272
- # '../../../src/org/jruby/ext/openssl/OpenSSL.java'
273
- FileUtils.cp File.expand_path('../../../assets/src/org/jruby/ext/openssl/OpenSSL.java', File.dirname(__FILE__)),
274
- '../../../src/org/jruby/ext/openssl/OpenSSL.java'
275
- puts '*' * 80
276
- end
277
- # EMXIF
278
262
  jar_load_code = <<-END_CODE
279
263
  require 'jruby'
280
264
  puts 'Starting JOpenSSL Service'
@@ -44,9 +44,11 @@ module Ruboto::Activity::Reload
44
44
  if file_string
45
45
  scripts_dir = @activity.getExternalFilesDir(nil).absolute_path + '/scripts'
46
46
  files = file_string.split(/(?<!&);/).map { |f| f.gsub(/&(.)/) { |m| m[1] } }
47
- files.each do |file|
48
- Log.d "load file: #{scripts_dir}/#{file}"
49
- load "#{scripts_dir}/#{file}"
47
+ with_large_stack(size: 256) do
48
+ files.each do |file|
49
+ Log.d "load file: #{scripts_dir}/#{file}"
50
+ load "#{scripts_dir}/#{file}"
51
+ end
50
52
  end
51
53
  Log.d 'restart activity'
52
54
  if @activity.intent.action == android.content.Intent::ACTION_MAIN ||
@@ -31,8 +31,8 @@ class Thread
31
31
  block_with_logging = proc do
32
32
  begin
33
33
  block.call
34
- rescue Exception
35
- STDERR.puts "Exception in #{name}: #{$!}\n#{$!.backtrace.join("\n")}"
34
+ rescue Exception => e
35
+ STDERR.puts "Exception in #{name}: #{e.class} #{e}\n#{e.backtrace.join("\n")}"
36
36
  raise
37
37
  end
38
38
  end
@@ -16,6 +16,10 @@ def assert_less_than_or_equal(limit, actual, message = nil)
16
16
  raise "#{"#{message}\n" if message}Expected '#{actual}' to be less than or equal to '#{limit}'" unless actual <= limit
17
17
  end
18
18
 
19
- def assert_matches(pattern, actual, message = nil)
19
+ def assert_match(pattern, actual, message = nil)
20
20
  raise "#{"#{message}\n" if message}'#{pattern}' expected, but got '#{actual}'" unless pattern =~ actual
21
21
  end
22
+ def assert_matches(*args)
23
+ warn '"assert_matches" is deprecated. Use "assert_match" instead, for Minitest compatibility.'
24
+ assert_match(*args)
25
+ end
@@ -19,10 +19,10 @@ module Ruboto
19
19
  include Ruboto::SdkVersions
20
20
  include Ruboto::Util::Verify
21
21
 
22
- # FIXME(uwe): Remove "L" special case
23
- API_LEVEL_PATTERN = /^android-(\d+|L)$/
24
- API_NUMBER_PATTERN = /(\d+|L)/
25
- # EMXIF
22
+ API_LEVEL_PATTERN = /^(android|google_apis)-(\d+)$/
23
+ API_NUMBER_PATTERN = /(\d+)/
24
+ VERSION_HELP_TEXT = "(e.g., 'android-19' or '19' for kitkat, " \
25
+ "'google_apis-23' for Android 6.0 with Google APIs)"
26
26
 
27
27
  def self.main
28
28
  Main do
@@ -51,17 +51,16 @@ module Ruboto
51
51
  argument :required
52
52
  description 'Path to where you want your app. Defaults to the last part of the package name.'
53
53
  }
54
- # FIXME(uwe): Change to cast to integer for better comparison
55
54
  option('target', 't') {
56
55
  argument :required
57
56
  defaults DEFAULT_TARGET_SDK
58
- description "Android version to target (e.g., 'android-19' or '19' for kitkat)"
57
+ description "Android version to target #{VERSION_HELP_TEXT}"
59
58
  cast { |t| t =~ API_NUMBER_PATTERN ? "android-#$1" : t }
60
59
  validate { |t| t =~ API_LEVEL_PATTERN }
61
60
  }
62
61
  option('min-sdk') {
63
62
  argument :required
64
- description "Minimum android version supported. (e.g., 'android-19' or '19' for kitkat)"
63
+ description "Minimum android version supported. #{VERSION_HELP_TEXT}"
65
64
  cast { |t| t =~ API_NUMBER_PATTERN ? "android-#$1" : t }
66
65
  validate { |t| t =~ API_LEVEL_PATTERN }
67
66
  }
@@ -95,11 +94,13 @@ module Ruboto
95
94
  force = params['force'].value
96
95
 
97
96
  abort "Path (#{path}) must be to a directory that does not yet exist. It will be created." if !force && File.exists?(path)
98
- abort "Target must match android-<number>: got #{target}" unless target =~ API_LEVEL_PATTERN
97
+ unless target =~ API_LEVEL_PATTERN
98
+ abort "Target must match #{API_LEVEL_PATTERN}: got #{target}"
99
+ end
99
100
 
100
- # FIXME(uwe): Remove the 'L' special case when Android L has been released
101
- abort "Minimum Android api level is #{MINIMUM_SUPPORTED_SDK}: got #{target}" unless $1 == 'L' || $1.to_i >= MINIMUM_SUPPORTED_SDK_LEVEL
102
- # EMXIF
101
+ if $2.to_i < MINIMUM_SUPPORTED_SDK_LEVEL
102
+ abort "Minimum Android api level is #{MINIMUM_SUPPORTED_SDK}: got #{target}"
103
+ end
103
104
 
104
105
  root = File.expand_path(path)
105
106
  puts "\nGenerating Android app #{name} in #{root}..."
@@ -359,7 +360,7 @@ module Ruboto
359
360
  # FIXME(uwe): Change to cast to integer for better comparison
360
361
  option('target', 't') {
361
362
  argument :required
362
- description "Android version to target (e.g., 'android-19' or '19' for kitkat)"
363
+ description "Android version to target #{VERSION_HELP_TEXT}"
363
364
  cast { |t| t =~ API_NUMBER_PATTERN ? "android-#$1" : t }
364
365
  validate { |t| t =~ API_LEVEL_PATTERN }
365
366
  }
@@ -387,11 +388,13 @@ module Ruboto
387
388
  end
388
389
 
389
390
  if (target = params['target'].value)
390
- abort "Target must match android-<number>: got #{target}" unless target =~ API_LEVEL_PATTERN
391
+ unless target =~ API_LEVEL_PATTERN
392
+ abort "Target must match #{API_LEVEL_PATTERN}: got #{target}"
393
+ end
391
394
 
392
- # FIXME(uwe): Remove the 'L' special case when Android L has been released.
393
- abort "Minimum Android api level is #{MINIMUM_SUPPORTED_SDK}: got #{target}" unless $1 == 'L' || $1.to_i >= MINIMUM_SUPPORTED_SDK_LEVEL
394
- # EMXIF
395
+ unless $2.to_i >= MINIMUM_SUPPORTED_SDK_LEVEL
396
+ abort "Minimum Android api level is #{MINIMUM_SUPPORTED_SDK}: got #{target}"
397
+ end
395
398
 
396
399
  target_level = target[API_NUMBER_PATTERN]
397
400
  update_android(target_level)
@@ -437,7 +440,7 @@ module Ruboto
437
440
  include Ruboto::Util::Setup
438
441
 
439
442
  option('target', 't') {
440
- description 'sets the target Android API level to set up for (example: -t android-16)'
443
+ description "sets the target Android API level to set up for #{VERSION_HELP_TEXT}"
441
444
  argument :required
442
445
  default DEFAULT_TARGET_SDK
443
446
  arity -1
@@ -482,11 +485,10 @@ module Ruboto
482
485
  argument :required
483
486
  default(api_level) if api_level
484
487
  cast { |t| t =~ API_NUMBER_PATTERN ? "android-#$1" : t }
485
- validate { |t| t =~ API_LEVEL_PATTERN && sdk_level_name($1.to_i) }
488
+ validate { |t| t =~ API_LEVEL_PATTERN && sdk_level_name($2.to_i) }
486
489
  }
487
490
 
488
491
  option('no-snapshot', 's') {
489
- extend Ruboto::Util::Emulator
490
492
  description 'do not use a snapshot when starting the emulator'
491
493
  }
492
494
 
@@ -7,17 +7,17 @@ module Ruboto
7
7
  '3.0' => 11, '3.1' => 12, '3.2' => 13, '4.0.1' => 14, '4.0.3' => 15,
8
8
  '4.0.4' => 15, '4.1' => 16, '4.1.1' => 16, '4.1.2' => 16, '4.2' => 17,
9
9
  '4.2.2' => 17, '4.3' => 18, '4.3.1' => 18, '4.4.2' => 19, '5.0.1' => 21,
10
- '5.1' => 22, '6.0' => 23
10
+ '5.1' => 22, '6.0' => 23, '7.0' => 24, '7.1.1' => 25
11
11
  }
12
12
  API_LEVEL_TO_VERSION = {
13
13
  10 => '2.3.3', 11 => '3.0', 12 => '3.1', 13 => '3.2', 14 => '4.0',
14
14
  15 => '4.0.3', 16 => '4.1.2', 17 => '4.2.2', 18 => '4.3.1',
15
- 19 => '4.4.2', 21 => '5.0.1', 22 => '5.1', 23 => '6.0'
15
+ 19 => '4.4.2', 21 => '5.0.1', 22 => '5.1', 23 => '6.0', 24 => '7.0', 25 => '7.1.1'
16
16
  }
17
17
 
18
18
  MINIMUM_SUPPORTED_SDK_LEVEL = 15
19
19
  MINIMUM_SUPPORTED_SDK = "android-#{MINIMUM_SUPPORTED_SDK_LEVEL}"
20
- DEFAULT_TARGET_SDK_LEVEL = 16
20
+ DEFAULT_TARGET_SDK_LEVEL = 19
21
21
  DEFAULT_TARGET_SDK = "android-#{DEFAULT_TARGET_SDK_LEVEL}"
22
22
  end
23
23
  end
@@ -10,7 +10,6 @@ module Ruboto
10
10
  ON_WINDOWS = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw/i)
11
11
  ON_MAC_OS_X = RbConfig::CONFIG['host_os'] =~ /^darwin/
12
12
  ON_LINUX = RbConfig::CONFIG['host_os'] =~ /linux/
13
- ON_TRAVIS = ENV['TRAVIS'] == 'true'
14
13
 
15
14
  def sdk_level_name(sdk_level)
16
15
  Ruboto::SdkVersions::API_LEVEL_TO_VERSION[sdk_level.to_i] || sdk_level
@@ -21,7 +20,7 @@ module Ruboto
21
20
  STDOUT.sync = true
22
21
  if RbConfig::CONFIG['host_cpu'] == 'x86_64'
23
22
  if ON_MAC_OS_X
24
- emulator_cmd = '-m "emulator64-(crash-service|arm|x86)"'
23
+ emulator_cmd = '-m "emulator64-(crash-service|arm|x86)|qemu-system-x86_64"'
25
24
  elsif ON_LINUX
26
25
  emulator_cmd = '-r "emulator64-(arm|x86)"'
27
26
  else
@@ -36,24 +35,45 @@ module Ruboto
36
35
  android_device = (emulator_config && emulator_config['device']) || "Nexus One"
37
36
  new_snapshot = false
38
37
 
39
- if `adb devices` =~ /emulator-5554/
40
- t = Net::Telnet.new('Host' => 'localhost', 'Port' => 5554, 'Prompt' => /^OK\n|^KO:/)
41
- t.waitfor(/Android Console:/)
42
- output = ''
43
- t.cmd('avd name') { |c| output << c }
44
- t.close
45
- if output =~ /(.*)\nOK\n/
46
- running_avd_name = $1
47
- if running_avd_name == avd_name
48
- puts "Emulator #{avd_name} is already running."
49
- return
38
+ running_emulators = `adb devices`.scan(/emulator-(\d+)/)
39
+ if running_emulators.any?
40
+ desired_emulator_is_running = false
41
+ running_emulators.each do |port, _|
42
+ t = Net::Telnet.new('Host' => 'localhost', 'Port' => port, 'Prompt' => /^OK\n|^KO:/)
43
+ begin
44
+ intro = t.waitfor(/^OK\n/)
45
+ rescue Net::ReadTimeout
46
+ puts "Timeout waiting for emulator intro."
47
+ kill_emulator(t)
48
+ next
49
+ end
50
+ if %r{Android Console: you can find your <auth_token> in\s+'(?<auth_file>.*)'} =~ intro
51
+ auth_token = File.read auth_file
52
+ t.cmd("auth #{auth_token}")
53
+ end
54
+ output = t.cmd('avd name')
55
+ if output =~ /(.*)\nOK\n/
56
+ running_avd_name = $1
57
+ if running_avd_name == avd_name
58
+ if desired_emulator_is_running
59
+ puts "Stopping duplicate #{running_avd_name} emulator."
60
+ kill_emulator(t)
61
+ else
62
+ puts "Emulator #{avd_name} is already running."
63
+ desired_emulator_is_running = true
64
+ end
65
+ else
66
+ puts "Stopping #{running_avd_name} emulator."
67
+ kill_emulator(t)
68
+ end
50
69
  else
51
- puts "Emulator #{running_avd_name} is running."
70
+ puts "Unexpected response from emulator: #{output.inspect}"
71
+ puts 'Assuming wrong emulator is running.'
72
+ kill_emulator(t)
52
73
  end
53
- else
54
- puts "Unexpected response from emulator: #{output.inspect}"
55
- puts 'Assuming wrong emulator is running.'
74
+ t.close
56
75
  end
76
+ return if desired_emulator_is_running
57
77
  else
58
78
  puts 'No emulator is running.'
59
79
  end
@@ -64,32 +84,11 @@ module Ruboto
64
84
  emulator_opts << ' -noskin' unless android_device
65
85
  emulator_opts << ' -no-snapshot' if no_snapshot
66
86
  if !ON_MAC_OS_X && !ON_WINDOWS && ENV['DISPLAY'].nil?
67
- emulator_opts << ' -no-window -no-audio'
87
+ emulator_opts << ' -no-window'
88
+ ENV['QEMU_AUDIO_DRV'] = 'none'
68
89
  end
69
90
 
70
- `killall -0 #{emulator_cmd} 2> /dev/null`
71
- if $? == 0
72
- `killall #{emulator_cmd}`
73
- 10.times do |i|
74
- `killall -0 #{emulator_cmd} 2> /dev/null`
75
- if $? != 0
76
- break
77
- end
78
- if i == 3
79
- print 'Waiting for emulator to die: ...'
80
- elsif i > 3
81
- print '.'
82
- end
83
- sleep 1
84
- end
85
- puts
86
- `killall -0 #{emulator_cmd} 2> /dev/null`
87
- if $? == 0
88
- puts 'Emulator still running.'
89
- `killall -9 #{emulator_cmd}`
90
- sleep 1
91
- end
92
- end
91
+ kill_all_emulators(emulator_cmd)
93
92
 
94
93
  avd_home = "#{ENV['HOME'].gsub('\\', '/')}/.android/avd/#{avd_name}.avd"
95
94
  manifest_file = 'AndroidManifest.xml'
@@ -104,7 +103,13 @@ module Ruboto
104
103
  end
105
104
 
106
105
  puts "Start emulator #{avd_name}#{' without snapshot' if no_snapshot}"
107
- system "emulator -avd #{avd_name} #{emulator_opts} #{'&' unless ON_WINDOWS}"
106
+ start_cmd = "emulator -avd #{avd_name} #{emulator_opts} #{'&' unless ON_WINDOWS}"
107
+
108
+ # FIXME: (uwe) Remove debug
109
+ puts start_cmd
110
+ # EMXIF
111
+
112
+ system start_cmd
108
113
  return if ON_WINDOWS
109
114
 
110
115
  3.times do |i|
@@ -193,6 +198,40 @@ EOF
193
198
  puts "Emulator #{avd_name} started OK."
194
199
  end
195
200
 
201
+ def kill_emulator(telnet)
202
+ begin
203
+ telnet.cmd('kill')
204
+ rescue Errno::ECONNRESET
205
+ puts "Emulator reset connection."
206
+ end
207
+ end
208
+
209
+ def kill_all_emulators(emulator_cmd)
210
+ `killall -0 #{emulator_cmd} 2> /dev/null`
211
+ if $? == 0
212
+ `killall #{emulator_cmd}`
213
+ 10.times do |i|
214
+ `killall -0 #{emulator_cmd} 2> /dev/null`
215
+ if $? != 0
216
+ break
217
+ end
218
+ if i == 3
219
+ print 'Waiting for emulator to die: ...'
220
+ elsif i > 3
221
+ print '.'
222
+ end
223
+ sleep 1
224
+ end
225
+ puts
226
+ `killall -0 #{emulator_cmd} 2> /dev/null`
227
+ if $? == 0
228
+ puts 'Emulator still running.'
229
+ `killall -9 #{emulator_cmd}`
230
+ sleep 1
231
+ end
232
+ end
233
+ end
234
+
196
235
  def create_avd(avd_home, avd_name, android_device, heap_size, sdk_level)
197
236
  puts "Creating AVD #{avd_name}"
198
237
 
@@ -206,6 +245,7 @@ EOF
206
245
  end
207
246
 
208
247
  abis = target.slice(/(?<=ABIs : ).*/).split(', ')
248
+ puts "Available abis: #{abis.inspect}"
209
249
  has_x86 = abis.find { |a| a =~ /x86/ }
210
250
  has_x86_64 = has_x86 && abis.find { |a| a =~ /x86_64/ }
211
251
 
@@ -213,23 +253,28 @@ EOF
213
253
  # FIXME(uwe): or the x86(_64) emulators don't require HAXM anymore
214
254
  # Newer Android SDK tools (V24) require HAXM to run x86 emulators.
215
255
  # HAXM is not available on travis-ci.
216
- if ON_TRAVIS && sdk_level.to_i >= 22
217
- abi_opt = '--abi armeabi-v7a'
218
- # EMXIF
219
- elsif has_x86
256
+ avoid_x86 = ON_TRAVIS && sdk_level.to_i >= 22
257
+ if avoid_x86
258
+ abis.reject!{|a| a =~ /x86/}
259
+ has_x86_64 = nil
260
+ has_x86 = nil
261
+ end
262
+ # EMXIF
263
+
264
+ if has_x86
220
265
  if has_x86_64
221
- abi_opt = '--abi x86_64'
266
+ abi_opt = "--abi #{has_x86_64}"
222
267
  else
223
- abi_opt = '--abi x86'
268
+ abi_opt = "--abi #{has_x86}"
224
269
  end
225
270
  else
226
- abi_opt = '--abi armeabi-v7a'
271
+ abi_opt = "--abi #{abis.first || 'armeabi-v7a'}"
227
272
  end
228
273
 
229
274
  ruboto_config_filename = 'ruboto.yml'
230
275
  if File.exists?(ruboto_config_filename)
231
276
  ruboto_config = YAML.load_file(ruboto_config_filename)
232
- skin = ruboto_config['emulator'] && ruboto_config['emulator']['skin']
277
+ skin = ruboto_config && ruboto_config['emulator'] && ruboto_config['emulator']['skin']
233
278
  end
234
279
  skin ||= '768x1280'
235
280
  # skin_filename = "#{Ruboto::SdkLocations::ANDROID_HOME}/platforms/android-#{sdk_level}/skins/#{skin}/hardware.ini"
@@ -241,7 +286,7 @@ EOF
241
286
  # File.write(skin_filename, new_skin_config) if new_skin_config != old_skin_config
242
287
  # end
243
288
 
244
- puts `echo no | android create avd -a -n #{avd_name} -t android-#{sdk_level} #{abi_opt} -c 64M #{"-s #{skin}" if skin} -d "#{android_device}"`
289
+ puts `echo no | android create avd #{'-a' unless avoid_x86} -n #{avd_name} -t android-#{sdk_level} #{abi_opt} -c 64M #{"-s #{skin}" if skin} -d "#{android_device}"`
245
290
 
246
291
  if $? != 0
247
292
  puts 'Failed to create AVD.'
@@ -265,7 +310,7 @@ EOF
265
310
  end
266
311
  end
267
312
 
268
- def patch_config_ini(avd_home, heap_size, no_snapshot)
313
+ def patch_config_ini(avd_home, heap_size, no_snapshot = nil)
269
314
  avd_config_file_name = "#{avd_home}/config.ini"
270
315
  old_avd_config = File.read(avd_config_file_name)
271
316
  new_avd_config = old_avd_config.dup
@@ -276,12 +321,14 @@ EOF
276
321
  # add_property(new_avd_config, 'hw.lcd.density', '160')
277
322
  add_property(new_avd_config, 'hw.mainKeys', 'no')
278
323
  # add_property(new_avd_config, 'hw.sdCard', 'yes')
279
- add_property(new_avd_config, 'snapshot.present', (!no_snapshot).to_s)
324
+ unless no_snapshot.nil?
325
+ add_property(new_avd_config, 'snapshot.present', (!no_snapshot).to_s)
326
+ end
280
327
  File.write(avd_config_file_name, new_avd_config) if new_avd_config != old_avd_config
281
328
  end
282
329
 
283
330
  def device_ready?
284
- `adb get-state`.gsub(/^WARNING:.*$/, '').chomp == 'device'
331
+ `adb get-state 2>&1`.gsub(/^WARNING:.*$/, '').chomp == 'device'
285
332
  end
286
333
 
287
334
  def read_property(config, property_name)
@@ -268,6 +268,8 @@ module Ruboto
268
268
  def check_for_android_sdk
269
269
  @android_loc = check_for('android', 'Android Package Installer',
270
270
  File.join(android_package_directory, 'tools', windows? ? 'android.bat' : 'android'))
271
+ check_for('sdkmanager', 'Android SDK Manager',
272
+ File.join(android_package_directory, 'tools', 'bin', windows? ? 'sdkmanager.bat' : 'sdkmanager'))
271
273
  end
272
274
 
273
275
  def check_for(cmd, pretty_name=nil, alt_dir=nil)
@@ -617,7 +619,7 @@ module Ruboto
617
619
  end
618
620
  if accept_all || a == 'Y' || a.empty?
619
621
  android_cmd = windows? ? 'android.bat' : 'android'
620
- update_cmd = "#{android_cmd} --silent update sdk --no-ui --filter build-tools-#{get_tools_version('build-tool')},extra-intel-Hardware_Accelerated_Execution_Manager,platform-tool,tool -a"
622
+ update_cmd = "#{android_cmd} --silent update sdk --no-ui --filter build-tools-#{get_tools_version('build-tool')[0]},extra-intel-Hardware_Accelerated_Execution_Manager,platform-tool,tool -a"
621
623
  update_sdk(update_cmd, accept_all)
622
624
  check_for_build_tools
623
625
  check_for_platform_tools
@@ -707,8 +709,14 @@ module Ruboto
707
709
  if accept_all || a == 'Y' || a.empty?
708
710
  android_cmd = windows? ? 'android.bat' : 'android'
709
711
 
710
- # FIXME(uwe): Does this pattern work for all api levels?
711
- update_cmd = "#{android_cmd} update sdk --no-ui --filter #{api_level},sys-img-x86-#{api_level.downcase},sys-img-x86_64-#{api_level.downcase},sys-img-armeabi-v7a-#{api_level.downcase} --all"
712
+ # FIXME: (uwe) Change to only install the best image for this system corresponding to the abi chosen when creating an emulator
713
+ level = api_level[/\d+/]
714
+ arches = %w(x86 x86_64 armeabi-v7a arm64-v8a)
715
+ arches -= %w(x86 x86_64) if ON_TRAVIS && level.to_i >= 22 # TODO: (uwe) Remove when travis can run x86 images
716
+ abi_list = arches.product(%w(android google_apis))
717
+ .map{|arch, vendor| "sys-img-#{arch}-#{vendor}-#{level}"}
718
+ puts "Installing #{abi_list}"
719
+ update_cmd = "#{android_cmd} update sdk --no-ui --filter #{api_level},#{abi_list.join(',')} --all"
712
720
  # EMXIF
713
721
 
714
722
  update_sdk(update_cmd, accept_all)
@@ -457,7 +457,7 @@ module Ruboto
457
457
  raise "Unpacking jruby-core jar failed: #$?" unless $? == 0
458
458
  File.delete jruby_core
459
459
  gem_version = Gem::Version.new(jruby_core_version.to_s.tr('-', '.'))
460
- if gem_version >= Gem::Version.new('9.0.5.0.SNAPSHOT')
460
+ if gem_version >= Gem::Version.new('9.0.5.0')
461
461
  #noinspection RubyLiteralArrayInspection
462
462
  excluded_core_packages = [
463
463
 
@@ -4,15 +4,18 @@ require 'yaml'
4
4
  module Ruboto
5
5
  module Util
6
6
  module Verify
7
+ ON_TRAVIS = ENV['TRAVIS'] == 'true' # TODO: (uwe) Maybe check "/dev/kvm" ?
8
+
7
9
  ###########################################################################
8
10
  #
9
11
  # Verify the presence of important components
10
12
  #
11
13
 
12
- def verify_manifest
13
- return @manifest if @manifest
14
- abort "cannot find your AndroidManifest.xml to extract info from it. Make sure you're in the root directory of your app" unless
15
- File.exists? 'AndroidManifest.xml'
14
+ def verify_manifest(reload: false)
15
+ return @manifest if @manifest && !reload
16
+ unless File.exists? 'AndroidManifest.xml'
17
+ abort "cannot find your AndroidManifest.xml to extract info from it. Make sure you're in the root directory of your app"
18
+ end
16
19
  @manifest = REXML::Document.new(File.read('AndroidManifest.xml')).root
17
20
  end
18
21
 
@@ -1,4 +1,4 @@
1
1
  module Ruboto
2
- VERSION = '1.5.0'
2
+ VERSION = '1.6.0'
3
3
  UPDATE_VERSION_LIMIT = '0.7.0'
4
4
  end
@@ -12,6 +12,6 @@ end
12
12
 
13
13
  test('distanceBetween') do |activity|
14
14
  assert_equal '12531.119140625', activity.find_view_by_id(42).text.to_s
15
- assert_equal '27.2149505615234', activity.find_view_by_id(43).text.to_s
16
- assert_equal '27.3007125854492', activity.find_view_by_id(44).text.to_s
15
+ assert_match /27.2149505615234/, activity.find_view_by_id(43).text.to_s
16
+ assert_match /27.3007125854492/, activity.find_view_by_id(44).text.to_s
17
17
  end
@@ -91,6 +91,7 @@ def start_activity_by_button(activity, button_id, activity_class_name = 'org.rub
91
91
  waitForIdleSync
92
92
  puts 'wait_for_monitor_with_timeout'
93
93
  current_activity = monitor.wait_for_activity_with_timeout(10000)
94
+ puts "current_activity: #{current_activity.inspect}"
94
95
  ensure
95
96
  removeMonitor(monitor)
96
97
  end
@@ -29,7 +29,7 @@ class SslActivity
29
29
  @open_uri_thread.join
30
30
  run_on_ui_thread { @response_view.text = 'open-uri loaded OK!' }
31
31
  puts 'before open'
32
- open('https://google.com/', ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE) do |f|
32
+ open('https://www.google.com/', ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE) do |f|
33
33
  puts 'inside open'
34
34
  body = f.read
35
35
  puts 'body'
@@ -39,7 +39,7 @@ class SslActivity
39
39
  run_on_ui_thread { @response_view.text = heading }
40
40
  end
41
41
  rescue Exception
42
- puts "Exception resdum: #{$!.class} #{$!.message}"
42
+ puts "Exception resume: #{$!.class} #{$!.message}"
43
43
  run_on_ui_thread { @response_view.text = $!.to_s }
44
44
  end
45
45
  end
@@ -20,12 +20,13 @@ end
20
20
  # ANDROID: 21, PLATFORM: 1.0.2, JRuby: 1.7.12 '[28, 33, 44, 61]' expected, but got '[28, 33, 43, 60]'
21
21
  # ANDROID: 22, PLATFORM: STANDALONE, JRuby: 1.7.20 '[28, 33, 44, 61]' expected, but got '[28, 33, 43, 60]'
22
22
  # ANDROID: 23, PLATFORM: STANDALONE, JRuby: 1.7.19 '[28, 33, 43, 60]' expected, but got '[26, 31, 40, 57]'
23
+ # ANDROID: 25, PLATFORM: STANDALONE, JRuby: 1.7.25 '[28, 33, 43, 60]' expected, but got '[26, 31, 40, 57]
23
24
  test('stack depth') do |activity|
24
25
  os_offset =
25
26
  case android.os.Build::VERSION::SDK_INT
26
27
  when 13 then [1, 1, 1, 1]
27
28
  when (15..19) then [0, 0, 1, 1]
28
- when 23 then [-2, -2, -3, -3]
29
+ when (23..25) then [-2, -2, -3, -3]
29
30
  else [0, 0, 0, 0]
30
31
  end
31
32
  jruby_offset =
@@ -72,6 +72,14 @@ module AppTestMethods
72
72
  next if file =~ /button|fragment|margins|navigation|psych|rss|spinner|startup_exception|subclass/ && has_stupid_crash
73
73
  # EMXIF
74
74
 
75
+ # FIXME(uwe): Crash when compiling proxy classes...investigate!
76
+ next if file =~ /dialog_fragment|ssl|subclass/ && ANDROID_OS == 24
77
+ # EMXIF
78
+
79
+ # FIXME(uwe): Remove when we stop testing Android <= 5.0
80
+ next if file =~ /ssl/ && ANDROID_OS <= 21
81
+ # EMXIF
82
+
75
83
  if file =~ /_test.rb$/
76
84
  next unless file =~ /#{ENV['ACTIVITY_TEST_PATTERN']}/
77
85
  snake_name = file.chomp('_test.rb')
@@ -121,4 +121,4 @@ EOF
121
121
  # https://github.com/jruby/jruby/issues/3401
122
122
  JRUBY_JARS_VERSION == Gem::Version.new('1.7.22')
123
123
  # EMXIF
124
- end
124
+ end unless RubotoTest::ANDROID_OS == 24 # FIXME: (uwe) remove check when crash is fixed or we stop supporting Android 7.0
@@ -1,4 +1,4 @@
1
- require File.expand_path('test_helper', File.dirname(__FILE__))
1
+ require_relative 'test_helper'
2
2
  require_relative '../assets/rakelib/ruboto.device'
3
3
 
4
4
  class RakeTest < Minitest::Test
@@ -2,23 +2,25 @@ require File.expand_path('test_helper', File.dirname(__FILE__))
2
2
 
3
3
  class RubotoActivityTest < Minitest::Test
4
4
  def setup
5
+ super
5
6
  generate_app
6
7
  end
7
8
 
8
9
  def teardown
9
10
  cleanup_app
11
+ super
10
12
  end
11
13
 
12
14
  def test_ruboto_activity_as_entry_point
13
15
  check_platform_installation
14
16
  Dir.chdir APP_DIR do
15
- #java_source_file = 'src/org/ruboto/test_app/RubotoTestAppActivity.java'
16
- #source = File.read(java_source_file)
17
- #assert source.gsub!(/extends org.ruboto.EntryPointActivity/, 'extends org.ruboto.RubotoActivity')
18
- #File.open(java_source_file, 'w') { |f| f << source }
17
+ package = 'org.ruboto.test_app'
18
+ app_element = verify_manifest(reload: true).elements['application']
19
+ activity_element = app_element.elements["activity[@android:name='org.ruboto.RubotoActivity']"]
20
+ activity_element.attributes['android:exported'] = true
21
+ save_manifest
19
22
  system 'rake install'
20
- #system "adb shell am start -a android.intent.action.MAIN -n org.ruboto.example_test_app/.RubotoActivity"
21
- system "adb shell am start -n org.ruboto.test_app/org.ruboto.RubotoActivity -e ClassName RubotoTestAppActivity"
23
+ system "adb shell am start -n #{package}/org.ruboto.RubotoActivity -e ClassName RubotoTestAppActivity"
22
24
  assert_equal 0, $?, "tests failed with return code #$?"
23
25
  # FIXME(uwe): Assert that the activity was started correctly.
24
26
  end
@@ -86,7 +86,8 @@ class RubotoGenTest < Minitest::Test
86
86
  # APK was 7006.1KB. PLATFORM: STANDALONE, ANDROID_TARGET: 15, JRuby: 1.7.23
87
87
  # APK was 7083.4KB. PLATFORM: STANDALONE, ANDROID_TARGET: 15, JRuby: 1.7.24
88
88
  # APK was 8596.6KB. PLATFORM: STANDALONE, ANDROID_TARGET: 19, JRuby: 1.7.24
89
- # APK was 7081.8KB. PLATFORM: STANDALONE, ANDROID_TARGET: 15, JRuby: 1.7.25.dev
89
+ # APK was 7081.8KB. PLATFORM: STANDALONE, ANDROID_TARGET: 15, JRuby: 1.7.25
90
+ # APK was 8730.8KB. PLATFORM: STANDALONE, ANDROID_TARGET: 19, JRuby: 1.7.25
90
91
  # APK was 4633.2KB. PLATFORM: STANDALONE, ANDROID_TARGET: 22, JRuby: 9.0.0.0.SNAPSHOT
91
92
  # APK was 8762.6KB. PLATFORM: STANDALONE, ANDROID_TARGET: 23, JRuby: 9.0.5.0.SNAPSHOT
92
93
  LIMITS = {
@@ -1,9 +1,10 @@
1
- require File.expand_path('test_helper', File.dirname(__FILE__))
1
+ require_relative 'test_helper'
2
2
  require 'net/http'
3
3
 
4
4
  class RubotoSetupTest < Minitest::Test
5
5
  include Ruboto::Util::Setup
6
6
 
7
+ # TODO: (uwe) The following tests verify internals of Ruboto setup. Should test API instead.
7
8
  def test_if_sdk_page_still_exists?
8
9
  uri = URI.parse(SDK_DOWNLOAD_PAGE)
9
10
  res = Net::HTTP.get_response(uri)
@@ -26,10 +27,10 @@ class RubotoSetupTest < Minitest::Test
26
27
  end
27
28
 
28
29
  def test_if_regex_still_applies_to_sdk
29
- regex = '(\>installer_.*.exe)'
30
+ regex = '(\>tools_r.*.zip)'
30
31
  page_content = Net::HTTP.get(URI.parse(SDK_DOWNLOAD_PAGE))
31
32
  link = page_content.scan(/#{regex}/).to_s
32
- assert_match /\d+(\.\d+)?(\.\d+)?/, link
33
+ assert_match /\d+(\.\d+)?(\.\d+)?/, link, page_content
33
34
  end
34
35
 
35
36
  describe 'Upgrade HAXM' do
@@ -1,8 +1,5 @@
1
1
  require File.expand_path('test_helper', File.dirname(__FILE__))
2
2
 
3
- # FIXME(uwe): Remove check when we stop supporting Android < 4.0.3
4
- if RubotoTest::ANDROID_OS >= 15 || RubotoTest::RUBOTO_PLATFORM != 'STANDALONE'
5
-
6
3
  class SqldroidTest < Minitest::Test
7
4
  def setup
8
5
  generate_app :bundle => :sqldroid
@@ -74,7 +71,4 @@ EOF
74
71
  run_app_tests
75
72
  end
76
73
 
77
- end
78
-
79
- end
80
- # EMXIF
74
+ end if RubotoTest::ANDROID_OS != 24 # FIXME: (uwe) Remove check when the proxy compile is fixed
@@ -44,29 +44,12 @@ module RubotoTest
44
44
  TMP_DIR = File.join PROJECT_DIR, 'tmp'
45
45
  APP_DIR = File.join TMP_DIR, APP_NAME
46
46
 
47
- # FIXME(uwe): Remove special case when Android L has been released.
48
- if (ENV['ANDROID_TARGET'] && ENV['ANDROID_TARGET'] =~ /(?:android-)?L/)
49
- ANDROID_TARGET = 'L'
50
- else
51
- ANDROID_TARGET = (ENV['ANDROID_TARGET'] && ENV['ANDROID_TARGET'].slice(/\d+/).to_i) || MINIMUM_SUPPORTED_SDK_LEVEL
52
- end
53
- # EMXIF
47
+ ANDROID_TARGET = (ENV['ANDROID_TARGET'] && ENV['ANDROID_TARGET'].slice(/\d+/).to_i) || MINIMUM_SUPPORTED_SDK_LEVEL
54
48
 
55
49
  def self.version_from_device
56
50
  puts 'Reading OS version from device/emulator'
57
51
  system 'adb wait-for-device'
58
- IO.popen('adb bugreport').each_line do |line|
59
- if line =~ /sdk-eng (.*?) .*? .*? test-keys/
60
- version = $1
61
- api_level = VERSION_TO_API_LEVEL[version]
62
- raise "Unknown version: #{version}" if api_level.nil?
63
- return "android-#{api_level}"
64
- end
65
- if line =~ /\[ro\.build\.version\.sdk\]: \[(\d+)\]/
66
- return $1
67
- end
68
- end
69
- raise 'Unable to read device/emulator apilevel'
52
+ `adb shell getprop ro.build.version.sdk`
70
53
  end
71
54
 
72
55
  def uninstall_jruby_jars_gem
@@ -103,10 +86,6 @@ module RubotoTest
103
86
 
104
87
  ANDROID_OS = (ENV['ANDROID_OS'] || version_from_device).slice(/\d+/).to_i
105
88
 
106
- # FIXME(uwe): Remove when Android L has been released
107
- ANDROID_OS = 21 if ANDROID_OS == 0
108
- # EMXIF
109
-
110
89
  puts "ANDROID_OS: #{ANDROID_OS}"
111
90
  puts "ANDROID_TARGET: #{ANDROID_TARGET}"
112
91
 
@@ -123,14 +102,7 @@ module RubotoTest
123
102
  elsif ENV['JRUBY_JARS_VERSION']
124
103
  JRUBY_JARS_VERSION = Gem::Version.new(ENV['JRUBY_JARS_VERSION'])
125
104
  else
126
- # FIXME(uwe): Simplify when we stop supporting rubygems < 1.8.0
127
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.8.0')
128
- gem_spec = Gem::Specification.find_by_path 'jruby-jars'
129
- else
130
- gem_spec = Gem.searcher.find('jruby-jars')
131
- end
132
- # EMXIF
133
-
105
+ gem_spec = Gem::Specification.find_by_path 'jruby-jars'
134
106
  raise StandardError.new("Can't find Gem specification jruby-jars.") unless gem_spec
135
107
  JRUBY_JARS_VERSION = gem_spec.version
136
108
  end
@@ -212,7 +184,7 @@ class Minitest::Test
212
184
  if example
213
185
  Dir.chdir TMP_DIR do
214
186
  system "tar xzf #{PROJECT_DIR}/examples/#{APP_NAME}_#{example}.tgz"
215
- Dir.chdir(APP_NAME) { system '../../bin/ruboto setup -y' }
187
+ Dir.chdir(APP_NAME) { system "#{RUBOTO_CMD} setup -y" }
216
188
  end
217
189
  Dir.chdir APP_DIR do
218
190
  File.open('local.properties', 'w') { |f| f.puts "sdk.dir=#{ANDROID_HOME}" }
@@ -256,6 +228,8 @@ class Minitest::Test
256
228
 
257
229
  Dir.chdir APP_DIR do
258
230
  write_android_manifest
231
+ sleep 1
232
+ FileUtils.touch('project.properties')
259
233
  File.write('res/layout/dummy_layout.xml', <<-EOF)
260
234
  <?xml version="1.0" encoding="utf-8"?>
261
235
  <TextView xmlns:android="http://schemas.android.com/apk/res/android"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboto
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Jackoway
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-11-17 00:00:00.000000000 Z
14
+ date: 2016-12-28 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: main
@@ -45,16 +45,22 @@ dependencies:
45
45
  name: rake
46
46
  requirement: !ruby/object:Gem::Requirement
47
47
  requirements:
48
- - - "~>"
48
+ - - ">="
49
49
  - !ruby/object:Gem::Version
50
50
  version: '11.3'
51
+ - - "<"
52
+ - !ruby/object:Gem::Version
53
+ version: '13'
51
54
  type: :runtime
52
55
  prerelease: false
53
56
  version_requirements: !ruby/object:Gem::Requirement
54
57
  requirements:
55
- - - "~>"
58
+ - - ">="
56
59
  - !ruby/object:Gem::Version
57
60
  version: '11.3'
61
+ - - "<"
62
+ - !ruby/object:Gem::Version
63
+ version: '13'
58
64
  - !ruby/object:Gem::Dependency
59
65
  name: rubyzip
60
66
  requirement: !ruby/object:Gem::Requirement