OLD | NEW |
---|---|
(Empty) | |
1 # Copyright 2017 The Chromium Authors. All rights reserved. | |
2 # Use of this source code is governed by a BSD-style license that can be | |
3 # found in the LICENSE file. | |
4 | |
5 import os | |
6 import subprocess | |
7 | |
8 def FindKeyboardDevice(dut_ip): | |
9 # find the device support events EV=120013 | |
bccheng
2017/05/19 09:09:14
find if the device supports event "EV=120013"
deanliao_goog
2017/05/19 09:49:46
Comment should be English sentence, which means it
vovoy
2017/05/22 03:54:07
Done.
| |
10 cmd = ['ssh', 'root@' + dut_ip, 'cat', '/proc/bus/input/devices'] | |
11 p = subprocess.Popen(cmd, stdout=subprocess.PIPE) | |
12 out = p.communicate()[0] | |
13 for line in out.splitlines(): | |
14 handler_prefix = 'H: Handlers=' | |
15 if line.startswith(handler_prefix): | |
16 handlers = line[len(handler_prefix):].split() | |
17 kbd_event = 'B: EV=120013' | |
18 if line.startswith(kbd_event): | |
19 for handler in handlers: | |
20 if handler.startswith('event'): | |
21 return '/dev/input/' + handler | |
22 raise Exception('keyboard device not found') | |
23 | |
24 def SetupKeyDispatch(dut_ip): | |
25 cur_dir=os.path.dirname(os.path.abspath(__file__)) | |
bccheng
2017/05/19 09:09:14
space around =
vovoy
2017/05/22 03:54:07
Done.
| |
26 send_key_filename = cur_dir + '/data/send_key_tab_switch' | |
27 log_key_filename = cur_dir + '/data/log_key_tab_switch' | |
28 | |
29 kbd_dev = FindKeyboardDevice(dut_ip) | |
30 send_key_content = '#!/bin/bash\n' | |
31 send_key_content += ('evemu-play --insert-slot0 ' + kbd_dev + | |
32 ' < /home/root/log_key_tab_switch') | |
33 with open(send_key_filename, 'w') as f: | |
34 f.write(send_key_content) | |
35 os.chmod(send_key_filename, 0774) | |
36 | |
37 os.system('scp -q %s root@%s:/usr/local/tmp/' % (log_key_filename, dut_ip)) | |
38 os.system('scp -q %s root@%s:/usr/local/tmp/' % (send_key_filename, dut_ip)) | |
39 | |
40 def SwitchTab(platform_backend): | |
41 platform_backend.RunCommand('/usr/local/tmp/send_key_tab_switch') | |
42 | |
43 def NoScreenOff(platform_backend): | |
44 platform_backend.RunCommand('set_power_policy --ac_screen_off_delay=3600') | |
45 platform_backend.RunCommand('set_power_policy --ac_screen_dim_delay=3500') | |
OLD | NEW |