OLD | NEW |
| (Empty) |
1 # Copyright 2014 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 | |
7 from pylib import constants | |
8 | |
9 BIN_DIR = '%s/bin' % constants.TEST_EXECUTABLE_DIR | |
10 _FRAMEWORK_DIR = '%s/framework' % constants.TEST_EXECUTABLE_DIR | |
11 | |
12 _COMMANDS = { | |
13 'unzip': 'org.chromium.android.commands.unzip.Unzip', | |
14 } | |
15 | |
16 _SHELL_COMMAND_FORMAT = ( | |
17 """#!/system/bin/sh | |
18 base=%s | |
19 export CLASSPATH=$base/framework/chromium_commands.jar | |
20 exec app_process $base/bin %s $@ | |
21 """) | |
22 | |
23 | |
24 def Installed(device): | |
25 return all(device.FileExists('%s/%s' % (BIN_DIR, c)) for c in _COMMANDS) | |
26 | |
27 | |
28 def InstallCommands(device): | |
29 device.RunShellCommand(['mkdir', BIN_DIR, _FRAMEWORK_DIR]) | |
30 for command, main_class in _COMMANDS.iteritems(): | |
31 shell_command = _SHELL_COMMAND_FORMAT % ( | |
32 constants.TEST_EXECUTABLE_DIR, main_class) | |
33 shell_file = '%s/%s' % (BIN_DIR, command) | |
34 device.WriteTextFile(shell_file, shell_command) | |
35 device.RunShellCommand( | |
36 ['chmod', '755', shell_file], check_return=True) | |
37 | |
38 device.adb.Push( | |
39 os.path.join(constants.GetOutDirectory(), | |
40 constants.SDK_BUILD_JAVALIB_DIR, | |
41 'chromium_commands.dex.jar'), | |
42 '%s/chromium_commands.jar' % _FRAMEWORK_DIR) | |
43 | |
OLD | NEW |