Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1854)

Unified Diff: build/android/pylib/utils/apk_helper.py

Issue 1200543002: [Android] Add support for installing split apks with adb_install_apk. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/pylib/sdk/split_select.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a556e7b31e66806bea8a65df7d7ca3825800bea6 100644
--- a/build/android/pylib/utils/apk_helper.py
+++ b/build/android/pylib/utils/apk_helper.py
@@ -9,12 +9,15 @@ import re
from pylib import cmd_helper
from pylib import constants
+from pylib.sdk import aapt
_AAPT_PATH = os.path.join(constants.ANDROID_SDK_TOOLS, 'aapt')
_MANIFEST_ATTRIBUTE_RE = re.compile(
r'\s*A: ([^\(\)= ]*)\([^\(\)= ]*\)="(.*)" \(Raw: .*\)$')
_MANIFEST_ELEMENT_RE = re.compile(r'\s*(?:E|N): (\S*) .*$')
+_PACKAGE_NAME_RE = re.compile(r'package: .*name=\'(\S*)\'')
+_SPLIT_NAME_RE = re.compile(r'package: .*split=\'(\S*)\'')
def GetPackageName(apk_path):
@@ -30,8 +33,7 @@ def GetInstrumentationName(apk_path):
def _ParseManifestFromApk(apk_path):
- aapt_cmd = [_AAPT_PATH, 'dump', 'xmltree', apk_path, 'AndroidManifest.xml']
- aapt_output = cmd_helper.GetCmdOutput(aapt_cmd).split('\n')
+ aapt_output = aapt.Dump('xmltree', apk_path, 'AndroidManifest.xml')
parsed_manifest = {}
node_stack = [parsed_manifest]
@@ -70,6 +72,7 @@ class ApkHelper(object):
self._apk_path = apk_path
self._manifest = None
self._package_name = None
+ self._split_name = None
def GetActivityName(self):
"""Returns the name of the Activity in the apk."""
@@ -100,16 +103,27 @@ class ApkHelper(object):
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*)\'')
+ aapt_output = aapt.Dump('badging', self._apk_path)
for line in aapt_output:
- m = package_name_re.match(line)
+ 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)
+ def GetSplitName(self):
+ """Returns the name of the split of the apk."""
+ if self._split_name:
+ return self._split_name
+
+ aapt_output = aapt.Dump('badging', self._apk_path)
+ for line in aapt_output:
+ m = _SPLIT_NAME_RE.match(line)
+ if m:
+ self._split_name = m.group(1)
+ return self._split_name
+ return None
+
def _GetManifest(self):
if not self._manifest:
self._manifest = _ParseManifestFromApk(self._apk_path)
« no previous file with comments | « build/android/pylib/sdk/split_select.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698