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.
5 """This module wraps the Android Asset Packaging Tool."""
9 from pylib
import cmd_helper
10 from pylib
import constants
11 from pylib
.utils
import timeout_retry
13 _AAPT_PATH
= os
.path
.join(constants
.ANDROID_SDK_TOOLS
, 'aapt')
15 def _RunAaptCmd(args
):
16 """Runs an aapt command.
19 args: A list of arguments for aapt.
22 The output of the command.
24 cmd
= [_AAPT_PATH
] + args
25 status
, output
= cmd_helper
.GetCmdStatusAndOutput(cmd
)
27 raise Exception('Failed running aapt command: "%s" with output "%s".' %
28 (' '.join(cmd
), output
))
31 def Dump(what
, apk
, assets
=None):
32 """Returns the output of the aapt dump command.
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.
40 if isinstance(assets
, basestring
):
42 return _RunAaptCmd(['dump', what
, apk
] + assets
).splitlines()