浏览代码

Fix android rake task to work with multiple devices attached to adb.

Yao Wei Tjong 姚伟忠 10 年之前
父节点
当前提交
31e0f09999
共有 1 个文件被更改,包括 8 次插入6 次删除
  1. 8 6
      Rakefile

+ 8 - 6
Rakefile

@@ -191,7 +191,7 @@ task :android do
   if install
     system "cd \"#{build_tree}\" && ant -Dadb.device.arg='-s #{$specific_device}' installd" or abort 'Failed to install APK'
   end
-  android_test_run parameter, intent, package, success_indicator, payload or abort "Failed to test run #{package}/#{intent}, make sure the APK has been installed"
+  android_test_run parameter, intent, package, success_indicator, payload or abort "Failed to test run #{package}/#{intent}"
 end
 
 # Usage: NOT intended to be used manually
@@ -592,14 +592,16 @@ end
 def android_find_device api = nil, abi = nil
   # Return the previously found matching device or if not found yet then try to find the matching device now
   return $specific_device if $specific_device
-  wait = api ? '' : 'wait-for-device'
   $specific_api = api.to_s if api
   $specific_abi = abi.to_s if abi
-  for i in `adb #{wait} devices |tail -n +2`.split "\n"
-    device = i.split.first
-    if `adb -s #{device} wait-for-device shell getprop ro.build.version.sdk`.chomp == $specific_api && `adb -s #{device} shell getprop ro.product.cpu.abi`.chomp == $specific_abi
-      return $specific_device = device
+  loop do
+    for i in `adb devices |tail -n +2`.split "\n"
+      device = i.split.first
+      if `adb -s #{device} wait-for-device shell getprop ro.build.version.sdk`.chomp == $specific_api && `adb -s #{device} shell getprop ro.product.cpu.abi`.chomp == $specific_abi
+        return $specific_device = device
+      end
     end
+    break if api
   end
   nil
 end