| OLD | NEW |
| (Empty) |
| 1 # Copyright 2015 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 """This module wraps the Android Asset Packaging Tool.""" | |
| 6 | |
| 7 import os | |
| 8 | |
| 9 from pylib import cmd_helper | |
| 10 from pylib import constants | |
| 11 from pylib.utils import timeout_retry | |
| 12 | |
| 13 _AAPT_PATH = os.path.join(constants.ANDROID_SDK_TOOLS, 'aapt') | |
| 14 | |
| 15 def _RunAaptCmd(args): | |
| 16 """Runs an aapt command. | |
| 17 | |
| 18 Args: | |
| 19 args: A list of arguments for aapt. | |
| 20 | |
| 21 Returns: | |
| 22 The output of the command. | |
| 23 """ | |
| 24 cmd = [_AAPT_PATH] + args | |
| 25 status, output = cmd_helper.GetCmdStatusAndOutput(cmd) | |
| 26 if status != 0: | |
| 27 raise Exception('Failed running aapt command: "%s" with output "%s".' % | |
| 28 (' '.join(cmd), output)) | |
| 29 return output | |
| 30 | |
| 31 def Dump(what, apk, assets=None): | |
| 32 """Returns the output of the aapt dump command. | |
| 33 | |
| 34 Args: | |
| 35 what: What you want to dump. | |
| 36 apk: Path to apk you want to dump information for. | |
| 37 assets: List of assets in apk you want to dump information for. | |
| 38 """ | |
| 39 assets = assets or [] | |
| 40 if isinstance(assets, basestring): | |
| 41 assets = [assets] | |
| 42 return _RunAaptCmd(['dump', what, apk] + assets).splitlines() | |
| OLD | NEW |