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

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

Issue 11741025: Seperate apk_info and jar_info. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added TOO Created 7 years, 12 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/utils/apk_and_jar_info.py ('k') | build/android/pylib/utils/jar_info.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/utils/apk_info.py
diff --git a/build/android/pylib/utils/apk_info.py b/build/android/pylib/utils/apk_info.py
new file mode 100644
index 0000000000000000000000000000000000000000..fdcf9edc58b72efebec2bcfa94c2da25cdc67f1b
--- /dev/null
+++ b/build/android/pylib/utils/apk_info.py
@@ -0,0 +1,41 @@
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Gathers information about APKs."""
+
+import logging
+import os
+import re
+
+# TODO(frankf): Move cmd_helper to utils.
+from pylib import cmd_helper
+
+
+def GetPackageNameForApk(apk_path):
+ """Returns the package name of this APK."""
+ 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."""
+
+ def __init__(self, apk_path):
+ if not os.path.exists(apk_path):
+ raise Exception('%s not found, please build it' % apk_path)
+ self._apk_path = apk_path
+
+ def GetApkPath(self):
+ return self._apk_path
+
+ def GetPackageName(self):
+ """Returns the package name of this APK."""
+ return GetPackageNameForApk(self._apk_path)
+
« no previous file with comments | « build/android/pylib/utils/apk_and_jar_info.py ('k') | build/android/pylib/utils/jar_info.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698