Sha256: fca2084022a78bdb9a59b98bc72d12a94e7da9ea74d7d6207da44d285a9d0ef4

Contents?: true

Size: 1.57 KB

Versions: 3

Compression:

Stored size: 1.57 KB

Contents

require 'HTTParty'
require 'optimus-runner/clients/mdb_client'
require 'os'
require 'nenv'

class DeviceDetails


  def get_device_details
    device_names = self.process_android_devices
    android_device_details = find_android_devices(device_names)
    ios_device_details = process_ios_devices
    puts "ios details #{ios_device_details}"
    puts "android details #{android_device_details}"
    device_details = android_device_details+ios_device_details
    puts "device_details #{device_details}"
    device_details
  end

  def process_android_devices
    if(Nenv.android?) 
      devices = `adb devices`
    else 
      devices = []
    end
    return MDBClient.new.format_android_devices devices
  end

  def process_ios_devices
    if(OS.mac? && Nenv.ios?) 
     devices = `instruments -s devices | grep 'iPhone'`
     return [] if devices.length == 0
      return MDBClient.new.format_ios_devices devices
    end
    return []
  end

  def find_android_devices(device_names)
    device_details = []
    if(Nenv.android?)
      device_names.each do |a|
        puts "adb -s #{a['udid']} shell getprop ro.product.model"
        device_model =  `adb -s #{a['udid']} shell getprop ro.product.model`
        device_os_version =  `adb -s #{a['udid']} shell getprop ro.build.version.release`
        a['deviceName'] = device_model.to_s.rstrip
        a['platformVersion'] = device_os_version.to_s.rstrip
        a["platform"] = "ANDROID"
        device_details.push(a)
      end
    end
    device_details
  end

end

div_details = DeviceDetails.new
details = div_details.get_device_details
p details

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
optimus-runner-1.2.0 lib/optimus-runner/DeviceDetails.rb
optimus-runner-1.1.4 lib/optimus-runner/DeviceDetails.rb
optimus-runner-1.1.3 lib/optimus-runner/DeviceDetails.rb