Module: DeviceAPI::Android

Defined in:
lib/device_api/android/adb.rb,
lib/device_api/android.rb,
lib/device_api/android/aapt.rb,
lib/device_api/android/device.rb,
lib/device_api/android/signing.rb,
lib/device_api/android/device/kindle.rb,
lib/device_api/android/plugins/memory.rb

Overview

Android component of DeviceAPI

Defined Under Namespace

Modules: Plugin Classes: AAPT, ADB, ADBCommandError, Device, Kindle, Signing, SigningCommandError

Class Method Summary collapse

Class Method Details

.device(serial) ⇒ Object

Retrieve an Device object by serial id


24
25
26
27
28
29
30
# File 'lib/device_api/android.rb', line 24

def self.device(serial)
  if serial.to_s.empty?
    raise DeviceAPI::BadSerialString.new("serial was '#{serial.nil? ? 'nil' : serial}'")
  end
  state = ADB.get_state(serial)
  DeviceAPI::Android::Device.create( self.get_device_type(serial),  { serial: serial, state: state })
end

.devicesObject

Returns array of connected android devices


15
16
17
18
19
20
21
# File 'lib/device_api/android.rb', line 15

def self.devices
  ADB.devices.map do |d|
    if d.keys.first && !d.keys.first.include?('?')
      DeviceAPI::Android::Device.create( self.get_device_type(d.keys.first), { serial: d.keys.first, state: d.values.first } )
    end
  end
end

.get_device_type(serial) ⇒ Object

Return the device type used in determining which Device Object to create


33
34
35
36
37
38
39
40
41
42
# File 'lib/device_api/android.rb', line 33

def self.get_device_type(serial)
  return :default if Device.new(serial: serial).manufacturer.nil?
  case Device.new(serial: serial).manufacturer.downcase
    when 'amazon'
      type = :kindle
    else
      type = :default
  end
  type
end