device_api-android 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7dfe569584ed7b09ceb48bb274a0c974798f10f6
4
- data.tar.gz: 8269d27b46ae49ff8bf354f06dfa8abb8bc713ce
3
+ metadata.gz: 24478f4505667886d868853cf59a63cfcf9b7853
4
+ data.tar.gz: 97885cb308584d1443e7520df7f382c17c24e747
5
5
  SHA512:
6
- metadata.gz: 95d0ded27c12b01421de3d766a7373ef79d18effc903ae420a5091e81af378fed9a7ef845998db7d25496826c7d8f5d9e4d2a7b22fb85ee4481185c90eb9d3de
7
- data.tar.gz: 4ae9c1c9b96d4df37ad18cbb41ef01344e47204baf03c92cbeab6231f5b9aa60356d7eb53c34e8e21cfedd8dabff876dfe3fd91d9b9c8f3993298643e51617cd
6
+ metadata.gz: b4f53c262ba558dd8b63fd501a752d32dc1b334cf3af4567c77c0645e591ad62d82ea8aab244b1148f8e16cd914a8119b3e42a3238e4a81d5f159a1b111118c2
7
+ data.tar.gz: 3eedf4979a134ae4521a421a9db11faf4f742c71304ff59203bc4bd8d3fa5492f882e13b5cca9386f4570dfa7e3de06aa3db007a93eadf9cba2c20f2376ee411
@@ -71,6 +71,15 @@ module DeviceAPI
71
71
  process_dumpsys('(.*):\s+(.*)', lines)
72
72
  end
73
73
 
74
+ # Get the network information
75
+ def self.get_network_info(serial)
76
+ lines = execute("adb -s #{serial} shell netcfg")
77
+ lines.stdout.split("\n").map do |a|
78
+ b = a.split(" ")
79
+ { name: b[0], ip: b[2].split('/')[0], mac: b[4] }
80
+ end
81
+ end
82
+
74
83
  # Processes the results from dumpsys to format them into a hash
75
84
  # @param [String] regex_string regex string used to separate the results from the keys
76
85
  # @param [Array] data data returned from dumpsys
@@ -195,7 +195,8 @@ module DeviceAPI
195
195
  # Check if the devices screen is currently turned on
196
196
  # @return [Boolean] true if the screen is on, otherwise false
197
197
  def screen_on?
198
- return true if get_powerinfo['mScreenOn'].to_s.downcase == 'true'
198
+ power = get_powerinfo
199
+ return true if power['mScreenOn'].to_s.downcase == 'true' || power['Display Power: state'].to_s.downcase == 'on'
199
200
  false
200
201
  end
201
202
 
@@ -252,9 +253,27 @@ module DeviceAPI
252
253
  def uptime
253
254
  ADB.get_uptime(serial)
254
255
  end
256
+
257
+ # Returns the Wifi IP address
258
+ def ip_address
259
+ network = get_network_info
260
+ wlan0 = network.detect { |a| a[:name] == 'wlan0' }
261
+ wlan0[:ip]
262
+ end
263
+
264
+ # Returns the Wifi mac address
265
+ def wifi_mac_address
266
+ network = get_network_info
267
+ wifi = network.detect { |a| a[:name] == 'wlan0' }
268
+ wifi[:mac]
269
+ end
255
270
 
256
271
  private
257
272
 
273
+ def get_network_info
274
+ ADB.get_network_info(serial)
275
+ end
276
+
258
277
  def get_disk_info
259
278
  @diskstat = DeviceAPI::Android::Plugin::Disk.new(serial: serial) unless @diskstat
260
279
  @diskstat.process_stats
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: device_api-android
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Buckhurst
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-10-19 00:00:00.000000000 Z
14
+ date: 2015-11-30 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: device_api