| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import os | 5 from devil.android.sdk import build_tools |
| 6 from devil.utils import cmd_helper |
| 7 from devil.utils import lazy |
| 6 | 8 |
| 7 from devil.utils import cmd_helper | |
| 8 from pylib import constants | |
| 9 | 9 |
| 10 _DEXDUMP_PATH = os.path.join(constants.ANDROID_SDK_TOOLS, 'dexdump') | 10 _dexdump_path = lazy.WeakConstant(lambda: build_tools.GetPath('dexdump')) |
| 11 |
| 11 | 12 |
| 12 def DexDump(dexfiles, file_summary=False): | 13 def DexDump(dexfiles, file_summary=False): |
| 13 """A wrapper around the Android SDK's dexdump tool. | 14 """A wrapper around the Android SDK's dexdump tool. |
| 14 | 15 |
| 15 Args: | 16 Args: |
| 16 dexfiles: The dexfile or list of dex files to dump. | 17 dexfiles: The dexfile or list of dex files to dump. |
| 17 file_summary: Display summary information from the file header. (-f) | 18 file_summary: Display summary information from the file header. (-f) |
| 18 | 19 |
| 19 Returns: | 20 Returns: |
| 20 An iterable over the output lines. | 21 An iterable over the output lines. |
| 21 """ | 22 """ |
| 22 # TODO(jbudorick): Add support for more options as necessary. | 23 # TODO(jbudorick): Add support for more options as necessary. |
| 23 if isinstance(dexfiles, basestring): | 24 if isinstance(dexfiles, basestring): |
| 24 dexfiles = [dexfiles] | 25 dexfiles = [dexfiles] |
| 25 args = [_DEXDUMP_PATH] + dexfiles | 26 args = [_dexdump_path.read()] + dexfiles |
| 26 if file_summary: | 27 if file_summary: |
| 27 args.append('-f') | 28 args.append('-f') |
| 28 | 29 |
| 29 return cmd_helper.IterCmdOutputLines(args) | 30 return cmd_helper.IterCmdOutputLines(args) |
| 30 | 31 |
| OLD | NEW |