Module: Mobo::Android

Defined in:
lib/mobo/android.rb

Defined Under Namespace

Modules: Avd, Targets Classes: Adb, Emulator

Class Method Summary collapse

Class Method Details

.add_to_pathObject



31
32
33
34
35
36
37
# File 'lib/mobo/android.rb', line 31

def add_to_path
  unless ENV['PATH'].match(/^#{Mobo.android_home}\/tools/)
    ENV['ANDROID_HOME'] = Mobo.android_home
    ENV['PATH'] = "#{Mobo.android_home}/tools:#{ENV['PATH']}"
    Mobo.log.debug("$PATH set to '#{ENV['PATH']}' to set up android")
  end
end

.exists?Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
# File 'lib/mobo/android.rb', line 6

def exists?
  if Dir.exists?(Mobo.home_dir) and not Dir["#{Mobo.home_dir}/**/tools/android"].empty?
    add_to_path
  end
  Mobo.cmd("which android | grep #{Mobo.home_dir}")
end

.haxm_installed?Boolean

Returns:

  • (Boolean)


47
48
49
50
51
# File 'lib/mobo/android.rb', line 47

def haxm_installed?
  if SystemCheck.osx?
    Mobo.cmd("kextstat | grep intel")
  end
end

.installObject

as a default, install in ~/.mobo



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/mobo/android.rb', line 14

def install
  unless File.exists?(Mobo.android_home)
    if SystemCheck.ubuntu?
      Mobo.cmd("curl -o #{path}/android-sdk_r24.3.4-linux.tgz http://dl.google.com/android/android-sdk_r24.3.4-linux.tgz")
      Mobo.cmd("tar -xf #{path}/android-sdk_r24.3.4-linux.tgz -C #{path}")
      Mobo.cmd("mv #{path}/android-sdk-linux #{Mobo.android_home}")
    elsif SystemCheck.osx?
      Mobo.cmd("curl -o #{path}/android-sdk_r24.3.4-macosx.zip http://dl.google.com/android/android-sdk_r24.3.4-macosx.zip")
      Mobo.cmd("unzip #{path}/android-sdk_r24.3.4-macosx.zip -d #{path}")
      Mobo.cmd("mv #{path}/android-sdk-macosx #{Mobo.android_home}")
    else
      Mobo.log.error("Platform not yet supported! Please raise a request with the project to support it.")
    end
  end
  add_to_path
end

.install_haxmObject



53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/mobo/android.rb', line 53

def install_haxm
  if SystemCheck.osx?
    install_package("extra-intel-Hardware_Accelerated_Execution_Manager")
    Mobo.cmd("hdiutil attach #{Mobo.android_home}/extras/intel/Hardware_Accelerated_Execution_Manager/IntelHAXM.dmg")
    Mobo.log.info("Using the sudo command to install haxm - Intel Hardware Accelerated Execution Manager")
    haxm_mount_point = Dir["/Volumes/IntelHAXM*"].first
    Mobo.cmd("sudo installer -pkg #{haxm_mount_point}/*.mpkg -target /")
    Mobo.cmd("hdiutil detach #{haxm_mount_point}")
  else
    raise "Platform not supported for haxm installation yet"
  end
end

.install_package(package) ⇒ Object



43
44
45
# File 'lib/mobo/android.rb', line 43

def install_package(package)
  Mobo.cmd("echo y | android update sdk --no-ui --all --filter #{package}")
end

.package_exists?(package) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/mobo/android.rb', line 39

def package_exists?(package)
  Mobo.cmd("android list sdk --extended --no-ui --all | grep '#{package}'")
end