| OLD | NEW |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 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 """Module containing utilities for apk packages.""" | 5 """Module containing utilities for apk packages.""" |
| 6 | 6 |
| 7 import re | 7 import re |
| 8 | 8 |
| 9 from pylib import cmd_helper | 9 from pylib import cmd_helper |
| 10 | 10 |
| 11 | 11 |
| 12 def GetPackageName(apk_path): | 12 def GetPackageName(android_sdk_tools, apk_path): |
| 13 """Returns the package name of the apk.""" | 13 """Returns the package name of the apk.""" |
| 14 aapt = os.path.join(android_sdk_tools, 'aapt') |
| 14 aapt_output = cmd_helper.GetCmdOutput( | 15 aapt_output = cmd_helper.GetCmdOutput( |
| 15 ['aapt', 'dump', 'badging', apk_path]).split('\n') | 16 [aapt, 'dump', 'badging', apk_path]).split('\n') |
| 16 package_name_re = re.compile(r'package: .*name=\'(\S*)\'') | 17 package_name_re = re.compile(r'package: .*name=\'(\S*)\'') |
| 17 for line in aapt_output: | 18 for line in aapt_output: |
| 18 m = package_name_re.match(line) | 19 m = package_name_re.match(line) |
| 19 if m: | 20 if m: |
| 20 return m.group(1) | 21 return m.group(1) |
| 21 raise Exception('Failed to determine package name of %s' % apk_path) | 22 raise Exception('Failed to determine package name of %s' % apk_path) |
| OLD | NEW |