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

Side by Side Diff: build/android/pylib/utils/apk_info.py

Issue 11780003: [Android] Revert 175082 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 """Gathers information about APKs."""
6
7 import logging
8 import os
9 import re
10
11 # TODO(frankf): Move cmd_helper to utils.
12 from pylib import cmd_helper
13
14
15 def GetPackageNameForApk(apk_path):
16 """Returns the package name of this APK."""
17 aapt_output = cmd_helper.GetCmdOutput(
18 ['aapt', 'dump', 'badging', apk_path]).split('\n')
19 package_name_re = re.compile(r'package: .*name=\'(\S*)\'')
20 for line in aapt_output:
21 m = package_name_re.match(line)
22 if m:
23 return m.group(1)
24 raise Exception('Failed to determine package name of %s' % apk_path)
25
26
27 class ApkInfo(object):
28 """Helper class for inspecting APKs."""
29
30 def __init__(self, apk_path):
31 if not os.path.exists(apk_path):
32 raise Exception('%s not found, please build it' % apk_path)
33 self._apk_path = apk_path
34
35 def GetApkPath(self):
36 return self._apk_path
37
38 def GetPackageName(self):
39 """Returns the package name of this APK."""
40 return GetPackageNameForApk(self._apk_path)
41
OLDNEW
« 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