-
Notifications
You must be signed in to change notification settings - Fork 3
/
adb_helpers.rb
47 lines (40 loc) · 1.29 KB
/
adb_helpers.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
module Adb
class << self
def kill_adb_pid pid
`kill #{pid} >> /dev/null 2>&1`
end
def recording_setup udid
%x(adb -s #{udid} shell 'mkdir /sdcard/recordings' >> /dev/null 2>&1)
spawn "adb -s #{udid} shell rm /sdcard/recordings/* >> /dev/null 2>&1"
end
def start_video_record udid, name
if ENV["UDID"].include? "emulator"
puts "\nNot recording. Cannot video record on emulator!\n"
return
else
recording_setup udid
puts "Recording! You have a maximum of 180 seconds record time..."
pid = spawn "adb -s #{udid} shell screenrecord --size 720x1280 /sdcard/recordings/video-#{name}.mp4", :out=> "/dev/null"
ENV["VIDEO_PID"] = pid.to_s
end
end
def stop_video_record udid, name
return if ENV["UDID"].include? "emulator"
kill_adb_pid ENV["VIDEO_PID"]
sleep 5 #delay for video to complete processing...
spawn "adb -s #{udid} pull /sdcard/recordings/video-#{name}.mp4 ./output"
end
def start_logcat udid, name
pid = spawn("adb -s #{udid} logcat -v long", :out=>"./output/logcat-#{name}.log")
ENV["LOGCAT_PID"] = pid.to_s
end
def stop_logcat
kill_adb_pid ENV["LOGCAT_PID"]
end
end
end
module Kernel
def adb
Adb
end
end