ruboto 0.11.0 → 0.12.0.rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +1 -1
- data/README.md +7 -5
- data/Rakefile +3 -4
- data/assets/rakelib/ruboto.rake +138 -87
- data/assets/samples/sample_broadcast_receiver.rb +1 -1
- data/assets/src/InheritingActivity.java +0 -6
- data/assets/src/RubotoActivity.java +4 -1
- data/assets/src/RubotoBroadcastReceiver.java +2 -11
- data/assets/src/RubotoService.java +6 -52
- data/assets/src/org/ruboto/EntryPointActivity.java +276 -36
- data/assets/src/org/ruboto/JRubyAdapter.java +5 -152
- data/assets/src/org/ruboto/Script.java +1 -1
- data/assets/src/org/ruboto/ScriptLoader.java +26 -44
- data/assets/src/org/ruboto/test/InstrumentationTestRunner.java +4 -21
- data/bin/ruboto +0 -6
- data/lib/ruboto/commands/base.rb +58 -48
- data/lib/ruboto/sdk_locations.rb +23 -0
- data/lib/ruboto/sdk_versions.rb +1 -19
- data/lib/ruboto/util/build.rb +32 -32
- data/lib/ruboto/util/setup.rb +240 -0
- data/lib/ruboto/util/update.rb +12 -25
- data/lib/ruboto/util/verify.rb +7 -4
- data/lib/ruboto/util/xml_element.rb +62 -76
- data/lib/ruboto/version.rb +1 -1
- data/test/activity/image_button_activity_test.rb +2 -2
- data/test/activity/image_button_and_button_activity_test.rb +2 -2
- data/test/activity/json_activity.rb +1 -1
- data/test/activity/navigation_activity.rb +12 -12
- data/test/activity/navigation_activity_test.rb +7 -7
- data/test/activity/option_menu_activity.rb +0 -1
- data/test/activity/option_menu_activity_test.rb +2 -2
- data/test/activity/stack_activity_test.rb +10 -20
- data/test/app_test_methods.rb +0 -4
- data/test/broadcast_receiver_test.rb +16 -6
- data/test/minimal_app_test.rb +4 -12
- data/test/rake_test.rb +37 -23
- data/test/ruboto_gen_test.rb +12 -15
- data/test/sqldroid_test.rb +3 -6
- data/test/test_helper.rb +2 -0
- data/test/update_test_methods.rb +9 -9
- metadata +7 -11
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -42,7 +42,7 @@ Command-line Tools
|
|
42
42
|
### Application generator
|
43
43
|
|
44
44
|
$ ruboto gen app --package com.yourdomain.whatever --path path/to/where/you/want/the/app --name NameOfApp --target android-version --min-sdk another-android-version --activity MainActivityName
|
45
|
-
Version values must be specified using'android-' and the sdk level number (e.g., android-
|
45
|
+
Version values must be specified using'android-' and the sdk level number (e.g., android-10 is gingerbread).
|
46
46
|
|
47
47
|
<a name="class_generator"></a>
|
48
48
|
### Class generator
|
@@ -165,7 +165,7 @@ You generate an app with the option `--activity FooActivity`, which means that r
|
|
165
165
|
|
166
166
|
The arguments passed to the methods are the same as the arguments that the java methods take. Consult the Android documentation.
|
167
167
|
|
168
|
-
Activities also have some special methods defined to make things easier. The easiest way to get an idea of what they are is looking over the [demo scripts](http://github.com/ruboto/ruboto-irb/tree/master/assets/demo-scripts/). You can also read the [ruboto.rb file](http://github.com/ruboto/ruboto/blob/master/
|
168
|
+
Activities also have some special methods defined to make things easier. The easiest way to get an idea of what they are is looking over the [demo scripts](http://github.com/ruboto/ruboto-irb/tree/master/assets/demo-scripts/). You can also read the [ruboto.rb file](http://github.com/ruboto/ruboto-irb/blob/master/src/ruboto.rb) where everything is defined.
|
169
169
|
|
170
170
|
Testing
|
171
171
|
-------
|
@@ -231,12 +231,14 @@ Tips & Tricks
|
|
231
231
|
|
232
232
|
### Emulators
|
233
233
|
|
234
|
+
You can start an emulator corresponding to the api level of your project with `rake emulator`. The emulator will be created for you and will be called after the android version of you rproject, like "Android_4.0.3".
|
235
|
+
|
234
236
|
If you're doing a lot of Android development, you'll probably find yourself typing `emulator -avd name_of_emulator` a lot to open emulators. It can be convenient to alias these to shorter commands.
|
235
237
|
|
236
238
|
For example, in your `~/.bashrc`, `~/.zshrc`, or similar file, you might put
|
237
|
-
alias
|
238
|
-
alias
|
239
|
-
If you have an "
|
239
|
+
alias ics="emulator -avd Android_4.0.3"
|
240
|
+
alias jellyb="emulator -avd Android_4.1.2"
|
241
|
+
If you have an "Android_4.0.3" emulator that runs Android 4..0.1 and a "Android_4.1.2" one that runs Android 4.1.2.
|
240
242
|
|
241
243
|
|
242
244
|
Alternatives
|
data/Rakefile
CHANGED
@@ -4,6 +4,7 @@ require 'rexml/document'
|
|
4
4
|
require 'ruboto/version'
|
5
5
|
require 'ruboto/description'
|
6
6
|
require 'ruboto/sdk_versions'
|
7
|
+
require 'ruboto/sdk_locations'
|
7
8
|
require 'uri'
|
8
9
|
require 'net/https'
|
9
10
|
|
@@ -15,7 +16,7 @@ PLATFORM_CURRENT_RELEASE_APK = File.expand_path('tmp/RubotoCore-release.apk', Fi
|
|
15
16
|
MANIFEST_FILE = 'AndroidManifest.xml'
|
16
17
|
GEM_FILE = "ruboto-#{Ruboto::VERSION}.gem"
|
17
18
|
GEM_SPEC_FILE = 'ruboto.gemspec'
|
18
|
-
EXAMPLE_FILE = File.expand_path("examples/RubotoTestApp_#{Ruboto::VERSION}_tools_r#{Ruboto::
|
19
|
+
EXAMPLE_FILE = File.expand_path("examples/RubotoTestApp_#{Ruboto::VERSION}_tools_r#{Ruboto::SdkLocations::ANDROID_TOOLS_REVISION}.tgz", File.dirname(__FILE__))
|
19
20
|
|
20
21
|
CLEAN.include('ruboto-*.gem', 'tmp')
|
21
22
|
|
@@ -330,11 +331,9 @@ namespace :platform do
|
|
330
331
|
desc 'Download the current RubotoCore platform release apk'
|
331
332
|
file PLATFORM_CURRENT_RELEASE_APK do
|
332
333
|
puts 'Downloading the current RubotoCore platform release apk'
|
333
|
-
uri = URI('
|
334
|
+
uri = URI('http://ruboto.org/downloads/RubotoCore-release.apk')
|
334
335
|
begin
|
335
336
|
http = Net::HTTP.new(uri.host, uri.port)
|
336
|
-
http.use_ssl = true
|
337
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
338
337
|
content = http.request(Net::HTTP::Get.new(uri.request_uri)).body
|
339
338
|
File.open(PLATFORM_CURRENT_RELEASE_APK, 'w') { |f| f << content }
|
340
339
|
rescue Exception, SystemExit
|
data/assets/rakelib/ruboto.rake
CHANGED
@@ -4,6 +4,7 @@ require 'time'
|
|
4
4
|
require 'rake/clean'
|
5
5
|
require 'rexml/document'
|
6
6
|
require 'timeout'
|
7
|
+
require 'net/telnet'
|
7
8
|
|
8
9
|
ON_WINDOWS = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw/i)
|
9
10
|
|
@@ -42,18 +43,34 @@ new_dx_content = File.read(dx_filename).dup
|
|
42
43
|
# set defaultXmx=-Xmx1024M
|
43
44
|
|
44
45
|
xmx_pattern = /^defaultMx="-Xmx(\d+)(M|m|G|g|T|t)"/
|
46
|
+
MINIMUM_DX_HEAP_SIZE = 2048
|
45
47
|
if new_dx_content =~ xmx_pattern &&
|
46
|
-
($1.to_i * 1024 ** {'M' => 2, 'G' => 3, 'T' => 4}[$2.upcase]) <
|
47
|
-
puts "Increasing max heap space from #$1#$2 to
|
48
|
-
new_dx_content.sub!(xmx_pattern,
|
48
|
+
($1.to_i * 1024 ** {'M' => 2, 'G' => 3, 'T' => 4}[$2.upcase]) < MINIMUM_DX_HEAP_SIZE*1024**2
|
49
|
+
puts "Increasing max heap space from #$1#$2 to #{MINIMUM_DX_HEAP_SIZE}M in #{dx_filename}"
|
50
|
+
new_dx_content.sub!(xmx_pattern, %Q{defaultMx="-Xmx#{MINIMUM_DX_HEAP_SIZE}M"})
|
49
51
|
File.open(dx_filename, 'w') { |f| f << new_dx_content } rescue puts "\n!!! Unable to increase dx heap size !!!\n\n"
|
52
|
+
puts new_dx_content.lines.grep(xmx_pattern)
|
50
53
|
end
|
51
54
|
|
52
|
-
def manifest;
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
def
|
55
|
+
def manifest;
|
56
|
+
@manifest ||= REXML::Document.new(File.read(MANIFEST_FILE))
|
57
|
+
end
|
58
|
+
|
59
|
+
def package;
|
60
|
+
manifest.root.attribute('package')
|
61
|
+
end
|
62
|
+
|
63
|
+
def build_project_name;
|
64
|
+
@build_project_name ||= REXML::Document.new(File.read('build.xml')).elements['project'].attribute(:name).value
|
65
|
+
end
|
66
|
+
|
67
|
+
def scripts_path;
|
68
|
+
@sdcard_path ||= "/mnt/sdcard/Android/data/#{package}/files/scripts"
|
69
|
+
end
|
70
|
+
|
71
|
+
def app_files_path;
|
72
|
+
@app_files_path ||= "/data/data/#{package}/files"
|
73
|
+
end
|
57
74
|
|
58
75
|
PROJECT_DIR = File.expand_path('..', File.dirname(__FILE__))
|
59
76
|
UPDATE_MARKER_FILE = File.join(PROJECT_DIR, 'bin', 'LAST_UPDATE')
|
@@ -63,7 +80,7 @@ MANIFEST_FILE = File.expand_path 'AndroidManifest.xml'
|
|
63
80
|
PROJECT_PROPS_FILE = File.expand_path 'project.properties'
|
64
81
|
RUBOTO_CONFIG_FILE = File.expand_path 'ruboto.yml'
|
65
82
|
GEM_FILE = File.expand_path 'Gemfile.apk'
|
66
|
-
GEM_LOCK_FILE =
|
83
|
+
GEM_LOCK_FILE = "#{GEM_FILE}.lock"
|
67
84
|
RELEASE_APK_FILE = File.expand_path "bin/#{build_project_name}-release.apk"
|
68
85
|
APK_FILE = File.expand_path "bin/#{build_project_name}-debug.apk"
|
69
86
|
TEST_APK_FILE = File.expand_path "test/bin/#{build_project_name}Test-debug.apk"
|
@@ -74,6 +91,10 @@ RUBY_SOURCE_FILES = Dir[File.expand_path 'src/**/*.rb']
|
|
74
91
|
APK_DEPENDENCIES = [MANIFEST_FILE, RUBOTO_CONFIG_FILE, BUNDLE_JAR] + JRUBY_JARS + JAVA_SOURCE_FILES + RESOURCE_FILES + RUBY_SOURCE_FILES
|
75
92
|
KEYSTORE_FILE = (key_store = File.readlines('ant.properties').grep(/^key.store=/).first) ? File.expand_path(key_store.chomp.sub(/^key.store=/, '').sub('${user.home}', '~')) : "#{build_project_name}.keystore"
|
76
93
|
KEYSTORE_ALIAS = (key_alias = File.readlines('ant.properties').grep(/^key.alias=/).first) ? key_alias.chomp.sub(/^key.alias=/, '') : build_project_name
|
94
|
+
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+(.*)$/
|
95
|
+
# -rw-r--r-- system system 7487556 2013-04-21 14:01 org.ruboto.example.gps-1.apk
|
96
|
+
# -rw-r--r-- 1 1000 1000 59252 Aug 15 2010 /data/app/org.update_test-1.apk
|
97
|
+
# -rw-r--r-- 1 1000 1000 59265 Aug 15 01:11 /data/app/org.update2_test-1.apk
|
77
98
|
|
78
99
|
CLEAN.include('bin', 'gen', 'test/bin', 'test/gen')
|
79
100
|
|
@@ -161,9 +182,9 @@ task :tag do
|
|
161
182
|
sh 'git push origin master --tags'
|
162
183
|
end
|
163
184
|
|
164
|
-
desc 'Start the emulator
|
185
|
+
desc 'Start the emulator'
|
165
186
|
task :emulator do
|
166
|
-
start_emulator
|
187
|
+
start_emulator(sdk_level)
|
167
188
|
end
|
168
189
|
|
169
190
|
desc 'Start the application on the device/emulator.'
|
@@ -258,39 +279,44 @@ file BUNDLE_JAR => [GEM_FILE, GEM_LOCK_FILE] do
|
|
258
279
|
next unless File.exists? GEM_FILE
|
259
280
|
puts "Generating #{BUNDLE_JAR}"
|
260
281
|
require 'bundler'
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
282
|
+
if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new('1.3.5')
|
283
|
+
require 'bundler/vendored_thor'
|
284
|
+
|
285
|
+
# Store original RubyGems/Bundler environment
|
286
|
+
platforms = Gem.platforms
|
287
|
+
ruby_engine = defined?(RUBY_ENGINE) && RUBY_ENGINE
|
288
|
+
gem_paths = {'GEM_HOME' => Gem.path, 'GEM_PATH' => Gem.dir}
|
289
|
+
|
290
|
+
# Override RUBY_ENGINE (we can bundle from MRI for JRuby)
|
291
|
+
Gem.platforms = [Gem::Platform::RUBY, Gem::Platform.new("universal-dalvik-#{sdk_level}"), Gem::Platform.new('universal-java')]
|
292
|
+
Gem.paths = {'GEM_HOME' => BUNDLE_PATH, 'GEM_PATH' => BUNDLE_PATH}
|
293
|
+
old_verbose, $VERBOSE = $VERBOSE, nil
|
294
|
+
begin
|
295
|
+
Object.const_set('RUBY_ENGINE', 'jruby')
|
296
|
+
ensure
|
297
|
+
$VERBOSE = old_verbose
|
298
|
+
end
|
277
299
|
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
300
|
+
ENV['BUNDLE_GEMFILE'] = GEM_FILE
|
301
|
+
Bundler.ui = Bundler::UI::Shell.new
|
302
|
+
Bundler.bundle_path = Pathname.new BUNDLE_PATH
|
303
|
+
definition = Bundler.definition
|
304
|
+
definition.validate_ruby!
|
305
|
+
Bundler::Installer.install(Bundler.root, definition)
|
284
306
|
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
307
|
+
# Restore RUBY_ENGINE (limit the scope of this hack)
|
308
|
+
old_verbose, $VERBOSE = $VERBOSE, nil
|
309
|
+
begin
|
310
|
+
Object.const_set('RUBY_ENGINE', ruby_engine)
|
311
|
+
ensure
|
312
|
+
$VERBOSE = old_verbose
|
313
|
+
end
|
314
|
+
Gem.platforms = platforms
|
315
|
+
Gem.paths = gem_paths
|
316
|
+
else
|
317
|
+
# Bundler.settings[:platform] = Gem::Platform::DALVIK
|
318
|
+
sh "bundle install --gemfile #{GEM_FILE} --path=#{BUNDLE_PATH} --platform=dalvik#{sdk_level}"
|
291
319
|
end
|
292
|
-
Gem.platforms = platforms
|
293
|
-
Gem.paths = gem_paths
|
294
320
|
|
295
321
|
gem_paths = Dir["#{BUNDLE_PATH}/gems"]
|
296
322
|
raise 'Gem path not found' if gem_paths.empty?
|
@@ -482,36 +508,41 @@ end
|
|
482
508
|
# Return nil if the package is not installed.
|
483
509
|
def package_installed?(test = false)
|
484
510
|
package_name = "#{package}#{'.tests' if test}"
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
return false
|
511
|
-
end
|
512
|
-
end
|
511
|
+
loop do
|
512
|
+
path_line = `adb shell pm path #{package_name}`.chomp
|
513
|
+
|
514
|
+
# FIXME(uwe): Debug travis CI. Remove when Travis CI is OK.
|
515
|
+
puts '*' * 80
|
516
|
+
puts 'Output from pm path'
|
517
|
+
puts '*' * 80
|
518
|
+
puts $?.inspect
|
519
|
+
puts '*' * 80
|
520
|
+
puts path_line
|
521
|
+
puts '*' * 80
|
522
|
+
# EMXIF
|
523
|
+
|
524
|
+
return nil if $? == 0 && path_line.empty?
|
525
|
+
break if $? == 0 && path_line =~ /^package:(.*)$/
|
526
|
+
|
527
|
+
# FIXME(uwe): Debug travis CI. Remove when Travis CI is OK.
|
528
|
+
puts '*' * 80
|
529
|
+
puts 'Unexpected output from pm path'
|
530
|
+
puts '*' * 80
|
531
|
+
puts path_line
|
532
|
+
puts '*' * 80
|
533
|
+
# EMXIF
|
534
|
+
|
535
|
+
sleep 0.5
|
513
536
|
end
|
514
|
-
|
537
|
+
|
538
|
+
path = $1
|
539
|
+
o = `adb shell ls -l #{path}`.chomp
|
540
|
+
raise "Unexpected ls output: #{o}" if o !~ APK_FILE_REGEXP
|
541
|
+
installed_apk_size = $1.to_i
|
542
|
+
installed_timestamp = Time.parse($2)
|
543
|
+
apk_file = test ? TEST_APK_FILE : APK_FILE
|
544
|
+
!File.exists?(apk_file) || (installed_apk_size == File.size(apk_file) &&
|
545
|
+
installed_timestamp >= File.mtime(apk_file))
|
515
546
|
end
|
516
547
|
|
517
548
|
def replace_faulty_code(faulty_file, faulty_code)
|
@@ -542,6 +573,8 @@ def build_apk(t, release)
|
|
542
573
|
if release
|
543
574
|
sh "#{ANT_CMD} release"
|
544
575
|
else
|
576
|
+
p RbConfig::CONFIG['host_os']
|
577
|
+
sh 'free' if RbConfig::CONFIG['host_os'] =~ /linux/
|
545
578
|
sh "#{ANT_CMD} debug"
|
546
579
|
end
|
547
580
|
true
|
@@ -561,7 +594,7 @@ def install_apk
|
|
561
594
|
install_retry_count = 0
|
562
595
|
begin
|
563
596
|
timeout 120 do
|
564
|
-
output = `adb install -r #{APK_FILE} 2>&1`
|
597
|
+
output = `adb install -r "#{APK_FILE}" 2>&1`
|
565
598
|
end
|
566
599
|
rescue Timeout::Error
|
567
600
|
puts "Installing package #{package} timed out."
|
@@ -571,7 +604,7 @@ def install_apk
|
|
571
604
|
retry
|
572
605
|
end
|
573
606
|
puts 'Trying one final time to install the package:'
|
574
|
-
output = `adb install -r #{APK_FILE} 2>&1`
|
607
|
+
output = `adb install -r "#{APK_FILE}" 2>&1`
|
575
608
|
end
|
576
609
|
if $? == 0 && output !~ failure_pattern && output =~ success_pattern
|
577
610
|
clear_update
|
@@ -594,7 +627,7 @@ def install_apk
|
|
594
627
|
install_retry_count = 0
|
595
628
|
begin
|
596
629
|
timeout 120 do
|
597
|
-
output = `adb install #{APK_FILE} 2>&1`
|
630
|
+
output = `adb install "#{APK_FILE}" 2>&1`
|
598
631
|
end
|
599
632
|
rescue Timeout::Error
|
600
633
|
puts "Installing package #{package} timed out."
|
@@ -604,7 +637,7 @@ def install_apk
|
|
604
637
|
retry
|
605
638
|
end
|
606
639
|
puts 'Trying one final time to install the package:'
|
607
|
-
output = `adb install #{APK_FILE} 2>&1`
|
640
|
+
output = `adb install "#{APK_FILE}" 2>&1`
|
608
641
|
end
|
609
642
|
puts output
|
610
643
|
raise "Install failed (#{$?}) #{$1 ? "[#$1}]" : output}" if $? != 0 || output =~ failure_pattern || output !~ success_pattern
|
@@ -646,7 +679,7 @@ def stop_app
|
|
646
679
|
output !~ /Operation not permitted/
|
647
680
|
end
|
648
681
|
|
649
|
-
def start_emulator
|
682
|
+
def start_emulator(sdk_level)
|
650
683
|
STDOUT.sync = true
|
651
684
|
# FIXME(uwe): Use RBConfig instead
|
652
685
|
if `uname -m`.chomp == 'x86_64'
|
@@ -654,7 +687,7 @@ def start_emulator
|
|
654
687
|
else
|
655
688
|
emulator_cmd = 'emulator-arm'
|
656
689
|
end
|
657
|
-
|
690
|
+
|
658
691
|
emulator_opts = '-partition-size 256'
|
659
692
|
if ENV['DISPLAY'].nil?
|
660
693
|
emulator_opts << ' -no-window -no-audio'
|
@@ -662,6 +695,24 @@ def start_emulator
|
|
662
695
|
|
663
696
|
avd_name = "Android_#{sdk_level_name}"
|
664
697
|
new_snapshot = false
|
698
|
+
|
699
|
+
if `adb devices` =~ /emulator-5554/
|
700
|
+
t = Net::Telnet.new('Host' => 'localhost', 'Port' => 5554, 'Prompt' => /^OK/)
|
701
|
+
output = ''
|
702
|
+
t.cmd('avd name') { |c| output << c }
|
703
|
+
if output =~ /OK\n(.*)\nOK/
|
704
|
+
running_avd_name = $1
|
705
|
+
if running_avd_name == avd_name
|
706
|
+
puts "Emulator #{avd_name} is already running."
|
707
|
+
return
|
708
|
+
else
|
709
|
+
puts "Emulator #{running_avd_name} is running."
|
710
|
+
end
|
711
|
+
else
|
712
|
+
puts 'No emulator is running.'
|
713
|
+
end
|
714
|
+
end
|
715
|
+
|
665
716
|
loop do
|
666
717
|
`killall -0 #{emulator_cmd} 2> /dev/null`
|
667
718
|
if $? == 0
|
@@ -703,10 +754,10 @@ def start_emulator
|
|
703
754
|
`sed -i.bak -e "s/vm.heapSize=[0-9]*/vm.heapSize=#{heap_size}/" #{ENV['HOME']}/.android/avd/#{avd_name}.avd/config.ini`
|
704
755
|
new_snapshot = true
|
705
756
|
end
|
706
|
-
|
757
|
+
|
707
758
|
puts 'Start emulator'
|
708
759
|
system "emulator -avd #{avd_name} #{emulator_opts} &"
|
709
|
-
|
760
|
+
|
710
761
|
3.times do |i|
|
711
762
|
sleep 1
|
712
763
|
`killall -0 #{emulator_cmd} 2> /dev/null`
|
@@ -716,7 +767,7 @@ def start_emulator
|
|
716
767
|
if i == 3
|
717
768
|
print 'Waiting for emulator: ...'
|
718
769
|
elsif i > 3
|
719
|
-
|
770
|
+
print '.'
|
720
771
|
end
|
721
772
|
end
|
722
773
|
puts
|
@@ -733,12 +784,12 @@ def start_emulator
|
|
733
784
|
if i == 3
|
734
785
|
print 'Waiting for emulator: ...'
|
735
786
|
elsif i > 3
|
736
|
-
|
787
|
+
print '.'
|
737
788
|
end
|
738
789
|
sleep 1
|
739
790
|
end
|
740
791
|
end
|
741
|
-
|
792
|
+
|
742
793
|
`killall -0 #{emulator_cmd} 2> /dev/null`
|
743
794
|
if $? == 0
|
744
795
|
print 'Emulator started: '
|
@@ -761,8 +812,8 @@ def start_emulator
|
|
761
812
|
puts 'Allow the emulator to calm down a bit.'
|
762
813
|
sleep 15
|
763
814
|
end
|
764
|
-
|
765
|
-
system
|
815
|
+
|
816
|
+
system '(
|
766
817
|
set +e
|
767
818
|
for i in 1 2 3 4 5 6 7 8 9 10 ; do
|
768
819
|
sleep 6
|
@@ -777,9 +828,9 @@ def start_emulator
|
|
777
828
|
echo "Failed to unlock screen"
|
778
829
|
set -e
|
779
830
|
exit 1
|
780
|
-
) &
|
781
|
-
|
782
|
-
system
|
783
|
-
|
831
|
+
) &'
|
832
|
+
|
833
|
+
system 'adb logcat > adb_logcat.log &'
|
834
|
+
|
784
835
|
puts "Emulator #{avd_name} started OK."
|
785
836
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import android.util.Log
|
2
2
|
|
3
3
|
class SampleBroadcastReceiver
|
4
|
-
#
|
4
|
+
# Will get called whenever the BroadcastReceiver receives an intent.
|
5
5
|
def onReceive(context, intent)
|
6
6
|
Log.v 'SampleBroadcastReceiver', 'Broadcast received!'
|
7
7
|
Log.v 'SampleBroadcastReceiver', intent.getExtras.to_s
|