lib/calabash-android/operations.rb in calabash-android-0.5.15.pre1 vs lib/calabash-android/operations.rb in calabash-android-0.5.15
- old
+ new
@@ -289,10 +289,14 @@
forward_cmd = "#{adb_command} forward tcp:#{@server_port} tcp:#{@test_server_port}"
log forward_cmd
log `#{forward_cmd}`
end
+ def _sdk_version
+ `#{adb_command} shell getprop ro.build.version.sdk`.to_i
+ end
+
def reinstall_apps
uninstall_app(package_name(@app_path))
uninstall_app(package_name(@test_server_path))
install_app(@app_path)
install_app(@test_server_path)
@@ -302,11 +306,16 @@
uninstall_app(package_name(@test_server_path))
install_app(@test_server_path)
end
def install_app(app_path)
- cmd = "#{adb_command} install \"#{app_path}\""
+ if _sdk_version >= 23
+ cmd = "#{adb_command} install -g \"#{app_path}\""
+ else
+ cmd = "#{adb_command} install \"#{app_path}\""
+ end
+
log "Installing: #{app_path}"
result = `#{cmd}`
log result
pn = package_name(app_path)
succeeded = `#{adb_command} shell pm list packages`.lines.map{|line| line.chomp.sub("package:", "")}.include?(pn)
@@ -316,10 +325,15 @@
raise "#{pn} did not get installed. Reason: '#{result.lines.last.chomp}'. Aborting!"
end
end
def update_app(app_path)
- cmd = "#{adb_command} install -r \"#{app_path}\""
+ if _sdk_version >= 23
+ cmd = "#{adb_command} install -rg \"#{app_path}\""
+ else
+ cmd = "#{adb_command} install -r \"#{app_path}\""
+ end
+
log "Updating: #{app_path}"
result = `#{cmd}`
log "result: #{result}"
succeeded = result.include?("Success")