| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 from skypy.skyserver import SkyServer | 6 from skypy.skyserver import SkyServer |
| 7 import argparse | 7 import argparse |
| 8 import json | 8 import json |
| 9 import logging | 9 import logging |
| 10 import os | 10 import os |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 ]) | 168 ]) |
| 169 | 169 |
| 170 sky_server = self._sky_server_for_args(args, packages_root) | 170 sky_server = self._sky_server_for_args(args, packages_root) |
| 171 pids['sky_server_pid'] = sky_server.start() | 171 pids['sky_server_pid'] = sky_server.start() |
| 172 pids['sky_server_port'] = sky_server.port | 172 pids['sky_server_port'] = sky_server.port |
| 173 pids['sky_server_root'] = sky_server.root | 173 pids['sky_server_root'] = sky_server.root |
| 174 | 174 |
| 175 pids['build_dir'] = os.path.abspath(args.build_dir) | 175 pids['build_dir'] = os.path.abspath(args.build_dir) |
| 176 | 176 |
| 177 if args.install: | 177 if args.install: |
| 178 subprocess.check_call([ADB_PATH, 'install', '-r', apk_path]) | 178 # -r to replace an existing apk, -d to allow version downgrade. |
| 179 subprocess.check_call([ADB_PATH, 'install', '-r', '-d', apk_path]) |
| 179 | 180 |
| 180 port_string = 'tcp:%s' % sky_server.port | 181 port_string = 'tcp:%s' % sky_server.port |
| 181 subprocess.check_call([ | 182 subprocess.check_call([ |
| 182 ADB_PATH, 'reverse', port_string, port_string | 183 ADB_PATH, 'reverse', port_string, port_string |
| 183 ]) | 184 ]) |
| 184 pids['remote_sky_server_port'] = sky_server.port | 185 pids['remote_sky_server_port'] = sky_server.port |
| 185 | 186 |
| 186 subprocess.check_call([ADB_PATH, 'shell', | 187 subprocess.check_call([ADB_PATH, 'shell', |
| 187 'am', 'start', | 188 'am', 'start', |
| 188 '-a', 'android.intent.action.VIEW', | 189 '-a', 'android.intent.action.VIEW', |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 args = parser.parse_args() | 312 args = parser.parse_args() |
| 312 pids = Pids.read_from(PID_FILE_PATH, PID_FILE_KEYS) | 313 pids = Pids.read_from(PID_FILE_PATH, PID_FILE_KEYS) |
| 313 exit_code = args.func(args, pids) | 314 exit_code = args.func(args, pids) |
| 314 # We could do this with an at-exit handler instead? | 315 # We could do this with an at-exit handler instead? |
| 315 pids.write_to(PID_FILE_PATH) | 316 pids.write_to(PID_FILE_PATH) |
| 316 sys.exit(exit_code) | 317 sys.exit(exit_code) |
| 317 | 318 |
| 318 | 319 |
| 319 if __name__ == '__main__': | 320 if __name__ == '__main__': |
| 320 SkyShellRunner().main() | 321 SkyShellRunner().main() |
| OLD | NEW |