-
Notifications
You must be signed in to change notification settings - Fork 0
/
record.py
44 lines (38 loc) · 1.55 KB
/
record.py
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
import logging
import argparse
from utils import find_touchscreen, get_api_version
from exec_cmd import execute_intercept
from adbhelper import keep_device_connected
# outfile=None: return result(str)
# outfile=f: (i.e. sys.stdout) send output to f, result =''
def record(outfile=None):
# Try to solve tap missing issue: use exec-out on higher level api
if option.event == "":
touch_screen_event = find_touchscreen()
else:
touch_screen_event = option.event
logging.debug('Found touchscreen: ' + touch_screen_event)
if get_api_version() < 23:
cmd_string = 'adb shell getevent -t ' + touch_screen_event
else:
cmd_string = 'adb exec-out getevent -t ' + touch_screen_event
print("Start recording, press ENTER to stop")
res = execute_intercept(cmd_string, outfile)
print("Finish recording")
return str(res)
if __name__ == '__main__':
# parsing arguments
parser = argparse.ArgumentParser(description="bandori chart record")
parser.add_argument('-t', '--trace', action="store", default="", help="path of tracefile")
parser.add_argument('-n', '--name', action="store", default="", help="device name (shown in adb)")
parser.add_argument('-e', '--event', action="store", default="", help="touch screen event")
parser.add_argument('--debug', action="store_true", default=False, help="show verbose details")
option = parser.parse_args()
# keep adb happy
if option.name != '':
keep_device_connected(option.name)
with open(option.trace, 'w') as f:
print('Press ENTER, then start playing DIRECTLY')
input()
record(outfile=f)
print("Saving to", f.name)