Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved major iOS version retrieval (fixes #95) #107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 33 additions & 12 deletions lib/lib/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,33 +71,54 @@ def initialize(username, password, hostname, port)

@ops.execute"touch /tmp/daniel"

if @ops.file_exists? @application_state_ios_10
str_ios_version = @ops.execute("sw_vers | grep ProductVersion | cut -d' ' -f2 | cut -d'.' -f1")
str_ios_version = str_ios_version.gsub!(/[\s\n]+/, "")
@ios_version = str_ios_version.to_i

# failover in case the sw_vers method fails to return a valid major version
if @ios_version.to_s != str_ios_version

# this check is buggy: FrontBoard found in 9.3.3
# FIXME: would removing the FrontBoard check cause problems later?
# e.g. assuming version 9 or later (and setting up ios_version = 9)
# when @apps_dir_ios_9 dir exists
if @ops.file_exists? @application_state_ios_10
@ios_version = 10

elsif @ops.directory? @apps_dir_ios_9
@ios_version = 9

elsif @ops.directory? @apps_dir_ios_8
@ios_version = 8

elsif @ops.directory? @apps_dir_ios_pre8
@ios_version = 7 # 7 or earlier

else
$log.error "Unsupported iOS Version."
raise
end
end

if @ios_version >= 10
$log.info "iOS Version: 10 or newer"
@ios_version = 10
@apps_dir = @apps_dir_ios_9
@data_dir = @data_dir_ios_9

elsif @ops.directory? @apps_dir_ios_9
elsif @ios_version == 9
$log.info "iOS Version: 9"
@ios_version = 9
@apps_dir = @apps_dir_ios_9
@data_dir = @data_dir_ios_9

elsif @ops.directory? @apps_dir_ios_8
elsif @ios_version == 8
$log.info "iOS Version: 8"
@ios_version = 8
@apps_dir = @apps_dir_ios_8
@data_dir = @data_dir_ios_8

elsif @ops.directory? @apps_dir_ios_pre8
else
$log.info "iOS Version: 7 or earlier"
@ios_version = 7 # 7 or earlier
@apps_dir = @apps_dir_ios_pre8
@data_dir = @apps_dir_ios_pre8

else
$log.error "Unsupported iOS Version."
raise
end
$log.info "iOS Version: #{@ios_version} with apps dir: #{@apps_dir} and data dir: #{@data_dir}"

Expand Down