Class: Ash::Adb::Device
- Inherits:
-
Object
- Object
- Ash::Adb::Device
- Defined in:
- lib/ash/adb/device.rb
Instance Attribute Summary collapse
-
#packages ⇒ Object
readonly
Returns the value of attribute packages.
-
#qualifiers ⇒ Object
readonly
Returns the value of attribute qualifiers.
-
#serial_number ⇒ Object
readonly
Returns the value of attribute serial_number.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #adb_over_wifi ⇒ Object
- #adb_port_forward(local, remote, remote_protocol = "tcp") ⇒ Object
- #features ⇒ Object
- #generate_bugreport ⇒ Object
-
#initialize(serial_number, state, qualifiers = nil) ⇒ Device
constructor
A new instance of Device.
- #libraries ⇒ Object
- #parse_device_package_list ⇒ Object
- #permission_groups ⇒ Object
- #save_bugreport(path = "/tmp/bugreport.txt") ⇒ Object
Constructor Details
#initialize(serial_number, state, qualifiers = nil) ⇒ Device
Returns a new instance of Device.
5 6 7 8 9 10 |
# File 'lib/ash/adb/device.rb', line 5 def initialize(serial_number, state, qualifiers=nil) @serial_number = serial_number @state = state @qualifiers = qualifiers @packages = parse_device_package_list end |
Instance Attribute Details
#packages ⇒ Object (readonly)
Returns the value of attribute packages.
3 4 5 |
# File 'lib/ash/adb/device.rb', line 3 def packages @packages end |
#qualifiers ⇒ Object (readonly)
Returns the value of attribute qualifiers.
3 4 5 |
# File 'lib/ash/adb/device.rb', line 3 def qualifiers @qualifiers end |
#serial_number ⇒ Object (readonly)
Returns the value of attribute serial_number.
3 4 5 |
# File 'lib/ash/adb/device.rb', line 3 def serial_number @serial_number end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
3 4 5 |
# File 'lib/ash/adb/device.rb', line 3 def state @state end |
Instance Method Details
#adb_over_wifi ⇒ Object
24 25 26 |
# File 'lib/ash/adb/device.rb', line 24 def adb_over_wifi Ash::Adb::Client.run("adb -s #{@serial_number} tcpip 5555") end |
#adb_port_forward(local, remote, remote_protocol = "tcp") ⇒ Object
20 21 22 |
# File 'lib/ash/adb/device.rb', line 20 def adb_port_forward(local, remote, remote_protocol="tcp") Ash::Adb::Client.run("adb -s #{@serial_number} forward tcp:#{local} #{remote_protocol}:#{remote}") end |
#features ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/ash/adb/device.rb', line 36 def features adb_command = "adb -s #{@serial_number} shell pm list features" raw_features_output = Ash::Adb::Client.run(adb_command) raw_features_output.split("\r\n").map do |feature| feature.split(":").last end end |
#generate_bugreport ⇒ Object
12 13 14 |
# File 'lib/ash/adb/device.rb', line 12 def generate_bugreport Ash::Adb::Client.run("adb -s #{@serial_number} shell bugreport") end |
#libraries ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/ash/adb/device.rb', line 44 def libraries adb_command = "adb -s #{@serial_number} shell pm list libraries" raw_library_output = Ash::Adb::Client.run(adb_command) raw_library_output.split("\r\n").map do |library| library.split(":").last end end |
#parse_device_package_list ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/ash/adb/device.rb', line 52 def parse_device_package_list Ash::Adb::Client.run("adb -s #{@serial_number} shell pm list packages -f").split("\r\n").map do |package_line| package_line = package_line.split(":").last.split("=") package_path = package_line.first package_name = package_line.last Ash::Adb::Package.new(package_path, package_name) end end |
#permission_groups ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/ash/adb/device.rb', line 28 def adb_command = "adb -s #{@serial_number} shell pm list permission-groups" raw_pg_output = Ash::Adb::Client.run(adb_command) raw_pg_output.split("\r\n").map do || .split(":").last end end |
#save_bugreport(path = "/tmp/bugreport.txt") ⇒ Object
16 17 18 |
# File 'lib/ash/adb/device.rb', line 16 def save_bugreport(path = "/tmp/bugreport.txt") File.open(path, 'w') {|f| f.write(generate_bugreport) } end |