Class: EmuCtl::ADB
- Inherits:
-
Object
- Object
- EmuCtl::ADB
- Defined in:
- lib/emu_ctl/adb.rb
Class Method Summary collapse
- .boot_complete?(emu_qual = nil) ⇒ Boolean
- .cli_opt(emu_qual) ⇒ Object
- .devices ⇒ Object
- .emu_info(emu_qual = nil) ⇒ Object
- .kill_emu(emu_qual) ⇒ Object
- .unlock_emulator(emu_qual = nil) ⇒ Object
Class Method Details
.boot_complete?(emu_qual = nil) ⇒ Boolean
26 27 28 29 30 |
# File 'lib/emu_ctl/adb.rb', line 26 def self.boot_complete?(emu_qual=nil) cmd = "adb #{cli_opt(emu_qual)} shell getprop dev.bootcomplete" _, stdout, stderr = Open3.popen3(cmd) return stderr.gets.nil? end |
.cli_opt(emu_qual) ⇒ Object
3 4 5 |
# File 'lib/emu_ctl/adb.rb', line 3 def self.cli_opt(emu_qual) "#{"-s #{emu_qual}" unless emu_qual.nil?}" end |
.devices ⇒ Object
7 8 9 10 11 12 |
# File 'lib/emu_ctl/adb.rb', line 7 def self.devices _, stdout, _ = Open3.popen3('adb devices -l') lines = [] stdout.each_line { |l| lines.push(l) if l.include?('emulator') } lines.map{ |em| /(emulator-\d+)/.match(em)[1] }.map{ |qual| emu_info(qual) } end |
.emu_info(emu_qual = nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/emu_ctl/adb.rb', line 14 def self.emu_info(emu_qual=nil) _, stdout, _ = Open3.popen3("adb #{cli_opt(emu_qual)} shell getprop") pattern = /\[.+\]: \[(.+)\]/ api_lvl, os_version, sdk = nil, nil, nil stdout.each_line do |l| api_lvl = pattern.match(l)[1] if l.include?('ro.build.version.sdk') os_version = pattern.match(l)[1] if l.include?('ro.build.version.release') sdk = pattern.match(l)[1] if l.include?('ro.product.name') end return Emulator.new(emu_qual, api_lvl, os_version, sdk) end |
.kill_emu(emu_qual) ⇒ Object
38 39 40 41 42 |
# File 'lib/emu_ctl/adb.rb', line 38 def self.kill_emu(emu_qual) cmd = "adb #{cli_opt(emu_qual)} emu kill" puts cmd Open3.popen3(cmd) end |
.unlock_emulator(emu_qual = nil) ⇒ Object
32 33 34 35 36 |
# File 'lib/emu_ctl/adb.rb', line 32 def self.unlock_emulator(emu_qual=nil) tag = cli_opt(emu_qual) system "adb #{tag} shell input keyevent 82" system "adb #{tag} shell input keyevent 4" end |