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

Unified Diff: build/android/pylib/apk_info.py

Issue 11365004: Android: makes "apk_package" optional in adb_install_apk.py (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix docstring Created 8 years, 2 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/adb_install_apk.py ('k') | build/android/pylib/test_options_parser.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/apk_info.py
diff --git a/build/android/pylib/apk_info.py b/build/android/pylib/apk_info.py
index 13b338f1c27cb170c6aae5bcde1cbe58736224af..6b0b7f63e68430d02eca6a264a4ea3b50717993f 100644
--- a/build/android/pylib/apk_info.py
+++ b/build/android/pylib/apk_info.py
@@ -11,6 +11,18 @@ import re
import cmd_helper
+def GetPackageNameForApk(apk_path):
+ """Returns the package name of the apk file."""
+ aapt_output = cmd_helper.GetCmdOutput(
+ ['aapt', 'dump', 'badging', apk_path]).split('\n')
+ package_name_re = re.compile(r'package: .*name=\'(\S*)\'')
+ for line in aapt_output:
+ m = package_name_re.match(line)
+ if m:
+ return m.group(1)
+ raise Exception('Failed to determine package name of %s' % apk_path)
+
+
class ApkInfo(object):
"""Helper class for inspecting APKs."""
@@ -26,7 +38,6 @@ class ApkInfo(object):
self._PROGUARD_ANNOTATION_CONST_RE = (
re.compile(r'\s*?- Constant element value.*$'))
self._PROGUARD_ANNOTATION_VALUE_RE = re.compile(r'\s*?- \S+? \[(.*)\]$')
- self._AAPT_PACKAGE_NAME_RE = re.compile(r'package: .*name=\'(\S*)\'')
if not os.path.exists(apk_path):
raise Exception('%s not found, please build it' % apk_path)
@@ -99,13 +110,7 @@ class ApkInfo(object):
def GetPackageName(self):
"""Returns the package name of this APK."""
- aapt_output = cmd_helper.GetCmdOutput(
- ['aapt', 'dump', 'badging', self._apk_path]).split('\n')
- for line in aapt_output:
- m = self._AAPT_PACKAGE_NAME_RE.match(line)
- if m:
- return m.group(1)
- raise Exception('Failed to determine package name of %s' % self._apk_path)
+ return GetPackageNameForApk(self._apk_path)
def GetTestAnnotations(self, test):
"""Returns a list of all annotations for the given |test|. May be empty."""
« no previous file with comments | « build/android/adb_install_apk.py ('k') | build/android/pylib/test_options_parser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698