-
Notifications
You must be signed in to change notification settings - Fork 26
/
scan.rb
executable file
·52 lines (41 loc) · 1006 Bytes
/
scan.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env ruby
#
# Android Cluster Toolkit
#
# scan.rb - scan for new android devices (not in $devices)
#
# (c) 2012-2015 Joshua J. Drake (jduck)
#
bfn = __FILE__
while File.symlink?(bfn)
bfn = File.expand_path(File.readlink(bfn), File.dirname(bfn))
end
$:.unshift(File.join(File.dirname(bfn), 'lib'))
# load connected set of devices
require 'devices'
load_connected(true)
# get a list of devices via 'adb devices'
require 'madb'
adb_devices = adb_scan(true)
# intersect this with $devices
new_devices = []
adb_devices.each { |port,serial|
found = false
$devices[:connected].each { |dev|
if dev[:serial] == serial
found = true
break
end
}
new_devices << [ port, serial ] if not found
}
$stderr.puts "[*] Found #{new_devices.length} new device#{plural(new_devices.length)}!"
# print any new ones in the format used to add to devices-orig.rb
new_devices.each { |port,serial|
puts %Q|
{
:name => 'name', # description
:serial => '#{serial}',
},
|
}