Sfoglia il codice sorgente

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

Yao Wei Tjong 姚伟忠 10 anni fa
parent
commit
31e0f09999
1 ha cambiato i file con 8 aggiunte e 6 eliminazioni
  1. 8 6
      Rakefile

+ 8 - 6
Rakefile

@@ -191,7 +191,7 @@ task :android do
   if install
   if install
     system "cd \"#{build_tree}\" && ant -Dadb.device.arg='-s #{$specific_device}' installd" or abort 'Failed to install APK'
     system "cd \"#{build_tree}\" && ant -Dadb.device.arg='-s #{$specific_device}' installd" or abort 'Failed to install APK'
   end
   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
 end
 
 
 # Usage: NOT intended to be used manually
 # Usage: NOT intended to be used manually
@@ -592,14 +592,16 @@ end
 def android_find_device api = nil, abi = nil
 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 the previously found matching device or if not found yet then try to find the matching device now
   return $specific_device if $specific_device
   return $specific_device if $specific_device
-  wait = api ? '' : 'wait-for-device'
   $specific_api = api.to_s if api
   $specific_api = api.to_s if api
   $specific_abi = abi.to_s if abi
   $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
     end
+    break if api
   end
   end
   nil
   nil
 end
 end