Chromium Code Reviews| Index: build/android/adb_install_apk.py |
| diff --git a/build/android/adb_install_apk.py b/build/android/adb_install_apk.py |
| index 1e370f8fa8ea4c765a5bb003b94a666473c9d08b..a58bcbd8648706579aa842bf3eed922879b88e12 100755 |
| --- a/build/android/adb_install_apk.py |
| +++ b/build/android/adb_install_apk.py |
| @@ -7,6 +7,7 @@ |
| """Utility script to install APKs from the command line quickly.""" |
| import argparse |
| +import glob |
| import logging |
| import os |
| import sys |
| @@ -15,9 +16,9 @@ from pylib import constants |
| from pylib.device import device_blacklist |
| from pylib.device import device_errors |
| from pylib.device import device_utils |
| +from pylib.utils import apk_helper |
| from pylib.utils import run_tests_helper |
| - |
| def main(): |
| parser = argparse.ArgumentParser() |
| @@ -30,6 +31,9 @@ def main(): |
| # TODO(jbudorick): Remove once no clients pass --apk_package |
| parser.add_argument('--apk_package', help='DEPRECATED unused') |
| + parser.add_argument('--splits', |
| + nargs='*', |
|
jbudorick
2015/06/29 15:49:01
I'm not sure how well this combines with the apk_p
mikecase (-- gone --)
2015/06/29 20:06:21
Changed this argument back to use action='append'
|
| + help='A list of globs for the apk splits.') |
| parser.add_argument('--keep_data', |
| action='store_true', |
| default=False, |
| @@ -62,6 +66,24 @@ def main(): |
| if not os.path.exists(apk): |
| parser.error('%s not found.' % apk) |
| + if args.splits: |
|
jbudorick
2015/06/26 23:26:59
Is there any way we can detect which apk of a list
agrieve
2015/06/26 23:53:03
It'll be the only one without a split="foo" attrib
mikecase (-- gone --)
2015/06/27 00:21:22
If you're going to pass in a glob like Chrome*.apk
jbudorick
2015/06/29 15:49:01
Hmm, right.
|
| + splits = [] |
| + base_apk_package = apk_helper.ApkHelper(apk).GetPackageName() |
| + for split_pattern in args.splits: |
| + if not split_pattern.endswith('.apk'): |
| + split_pattern += '.apk' |
| + apks = glob.glob(split_pattern) |
| + if not apks: |
| + apks = glob.glob(os.path.join(constants.GetOutDirectory(), |
| + 'apks', split_pattern)) |
| + if not apks: |
| + logging.warning('No apks matched for %s.' % split_pattern) |
| + for f in apks: |
| + helper = apk_helper.ApkHelper(f) |
| + if (helper.GetPackageName() == base_apk_package |
| + and helper.GetSplitName() is not None): |
| + splits.append(f) |
| + |
| devices = device_utils.DeviceUtils.HealthyDevices() |
| if args.device: |
| @@ -73,7 +95,10 @@ def main(): |
| def blacklisting_install(device): |
| try: |
| - device.Install(apk, reinstall=args.keep_data) |
| + if args.splits: |
| + device.InstallSplitApk(apk, splits, reinstall=args.keep_data) |
| + else: |
| + device.Install(apk, reinstall=args.keep_data) |
| except device_errors.CommandFailedError: |
| logging.exception('Failed to install %s', args.apk) |
| device_blacklist.ExtendBlacklist([str(device)]) |