| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Utility script to install APKs from the command line quickly.""" | 7 """Utility script to install APKs from the command line quickly.""" |
| 8 | 8 |
| 9 import optparse | 9 import optparse |
| 10 import os | 10 import os |
| 11 import sys | 11 import sys |
| 12 | 12 |
| 13 from pylib import android_commands | 13 from pylib import android_commands |
| 14 from pylib import constants | 14 from pylib import constants |
| 15 from pylib.device import device_utils | 15 from pylib.device import device_utils |
| 16 from pylib.utils import apk_helper | |
| 17 | 16 |
| 18 | 17 |
| 19 def AddInstallAPKOption(option_parser): | 18 def AddInstallAPKOption(option_parser): |
| 20 """Adds apk option used to install the APK to the OptionParser.""" | 19 """Adds apk option used to install the APK to the OptionParser.""" |
| 21 option_parser.add_option('--apk', | 20 option_parser.add_option('--apk', |
| 22 help=('DEPRECATED The name of the apk containing the' | 21 help=('DEPRECATED The name of the apk containing the' |
| 23 ' application (with the .apk extension).')) | 22 ' application (with the .apk extension).')) |
| 24 option_parser.add_option('--apk_package', | 23 option_parser.add_option('--apk_package', |
| 25 help=('The package name used by the apk containing ' | 24 help=('DEPRECATED The package name used by the apk ' |
| 26 'the application.')) | 25 'containing the application.')) |
| 27 option_parser.add_option('--keep_data', | 26 option_parser.add_option('--keep_data', |
| 28 action='store_true', | 27 action='store_true', |
| 29 default=False, | 28 default=False, |
| 30 help=('Keep the package data when installing ' | 29 help=('Keep the package data when installing ' |
| 31 'the application.')) | 30 'the application.')) |
| 32 option_parser.add_option('--debug', action='store_const', const='Debug', | 31 option_parser.add_option('--debug', action='store_const', const='Debug', |
| 33 dest='build_type', | 32 dest='build_type', |
| 34 default=os.environ.get('BUILDTYPE', 'Debug'), | 33 default=os.environ.get('BUILDTYPE', 'Debug'), |
| 35 help='If set, run test suites under out/Debug. ' | 34 help='If set, run test suites under out/Debug. ' |
| 36 'Default is env var BUILDTYPE or Debug') | 35 'Default is env var BUILDTYPE or Debug') |
| (...skipping 30 matching lines...) Expand all Loading... |
| 67 elif len(args) > 2: | 66 elif len(args) > 2: |
| 68 parser.error("Too many arguments.") | 67 parser.error("Too many arguments.") |
| 69 | 68 |
| 70 constants.SetBuildType(options.build_type) | 69 constants.SetBuildType(options.build_type) |
| 71 ValidateInstallAPKOption(parser, options, args) | 70 ValidateInstallAPKOption(parser, options, args) |
| 72 | 71 |
| 73 devices = android_commands.GetAttachedDevices() | 72 devices = android_commands.GetAttachedDevices() |
| 74 if not devices: | 73 if not devices: |
| 75 raise Exception('Error: no connected devices') | 74 raise Exception('Error: no connected devices') |
| 76 | 75 |
| 77 if not options.apk_package: | 76 device_utils.DeviceUtils.parallel(devices).Install( |
| 78 options.apk_package = apk_helper.GetPackageName(options.apk) | 77 options.apk, reinstall=options.keep_data) |
| 79 | |
| 80 device_utils.DeviceUtils.parallel(devices).old_interface.ManagedInstall( | |
| 81 options.apk, options.keep_data, options.apk_package).pFinish(None) | |
| 82 | 78 |
| 83 | 79 |
| 84 if __name__ == '__main__': | 80 if __name__ == '__main__': |
| 85 sys.exit(main(sys.argv)) | 81 sys.exit(main(sys.argv)) |
| 86 | 82 |
| OLD | NEW |