Index: build/android/pylib/utils/apk_helper.py |
diff --git a/build/android/pylib/utils/apk_helper.py b/build/android/pylib/utils/apk_helper.py |
index 6dd209e3dc17960691937220c68c4f1cbadd28ff..5bbbf5e5853756bb8a308d96267d42a27cd4c5e2 100644 |
--- a/build/android/pylib/utils/apk_helper.py |
+++ b/build/android/pylib/utils/apk_helper.py |
@@ -13,7 +13,7 @@ from pylib import constants |
_AAPT_PATH = os.path.join(constants.ANDROID_SDK_TOOLS, 'aapt') |
_MANIFEST_ATTRIBUTE_RE = re.compile( |
- r'\s*A: ([^\(\)= ]*)\([^\(\)= ]*\)="(.*)" \(Raw: .*\)$') |
+ r'\s*A: ([^\(\)= ]*)(\([^\(\)= ]*\))?="(.*)" \(Raw: .*\)$') |
mikecase (-- gone --)
2015/06/26 18:59:33
This regex would previously only match attributes
|
_MANIFEST_ELEMENT_RE = re.compile(r'\s*(?:E|N): (\S*) .*$') |
@@ -59,7 +59,7 @@ def _ParseManifestFromApk(apk_path): |
if m: |
if not m.group(1) in node: |
node[m.group(1)] = [] |
- node[m.group(1)].append(m.group(2)) |
+ node[m.group(1)].append(m.group(3)) |
continue |
return parsed_manifest |
@@ -69,7 +69,6 @@ class ApkHelper(object): |
def __init__(self, apk_path): |
self._apk_path = apk_path |
self._manifest = None |
- self._package_name = None |
def GetActivityName(self): |
"""Returns the name of the Activity in the apk.""" |
@@ -97,18 +96,19 @@ class ApkHelper(object): |
def GetPackageName(self): |
"""Returns the package name of the apk.""" |
- if self._package_name: |
- return self._package_name |
- |
- aapt_cmd = [_AAPT_PATH, 'dump', 'badging', self._apk_path] |
- aapt_output = cmd_helper.GetCmdOutput(aapt_cmd).split('\n') |
- package_name_re = re.compile(r'package: .*name=\'(\S*)\'') |
- for line in aapt_output: |
- m = package_name_re.match(line) |
- if m: |
- self._package_name = m.group(1) |
- return self._package_name |
- raise Exception('Failed to determine package name of %s' % self._apk_path) |
+ manifest_info = self._GetManifest() |
jbudorick
2015/06/26 23:26:59
Why did we switch the implementation here? Does aa
mikecase (-- gone --)
2015/06/27 00:21:22
I changed this impl to be consistent with the rest
jbudorick
2015/06/29 15:49:01
This was intentional. Parsing the output of aapt d
mikecase (-- gone --)
2015/06/29 20:06:21
Changed GetPackageName back to old implementation.
|
+ try: |
+ return manifest_info['manifest']['package'][0] |
+ except KeyError: |
+ raise Exception('Failed to determine package name of %s' % self._apk_path) |
+ |
+ def GetSplitName(self): |
+ """Returns the split attribute of the apk.""" |
+ manifest_info = self._GetManifest() |
+ try: |
+ return manifest_info['manifest']['split'][0] |
+ except KeyError: |
+ return None |
def _GetManifest(self): |
if not self._manifest: |