OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Module containing utilities for apk packages.""" | 5 """Module containing utilities for apk packages.""" |
6 | 6 |
7 import os.path | |
8 import re | 7 import re |
9 | 8 |
10 from devil.android.sdk import aapt | 9 from devil.android.sdk import aapt |
11 from pylib import constants | |
12 | 10 |
13 | 11 |
14 _AAPT_PATH = os.path.join(constants.ANDROID_SDK_TOOLS, 'aapt') | |
15 _MANIFEST_ATTRIBUTE_RE = re.compile( | 12 _MANIFEST_ATTRIBUTE_RE = re.compile( |
16 r'\s*A: ([^\(\)= ]*)\([^\(\)= ]*\)="(.*)" \(Raw: .*\)$') | 13 r'\s*A: ([^\(\)= ]*)\([^\(\)= ]*\)="(.*)" \(Raw: .*\)$') |
17 _MANIFEST_ELEMENT_RE = re.compile(r'\s*(?:E|N): (\S*) .*$') | 14 _MANIFEST_ELEMENT_RE = re.compile(r'\s*(?:E|N): (\S*) .*$') |
18 _PACKAGE_NAME_RE = re.compile(r'package: .*name=\'(\S*)\'') | 15 _PACKAGE_NAME_RE = re.compile(r'package: .*name=\'(\S*)\'') |
19 _SPLIT_NAME_RE = re.compile(r'package: .*split=\'(\S*)\'') | 16 _SPLIT_NAME_RE = re.compile(r'package: .*split=\'(\S*)\'') |
20 | 17 |
21 | 18 |
22 def GetPackageName(apk_path): | 19 def GetPackageName(apk_path): |
23 """Returns the package name of the apk.""" | 20 """Returns the package name of the apk.""" |
24 return ApkHelper(apk_path).GetPackageName() | 21 return ApkHelper(apk_path).GetPackageName() |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 if m: | 125 if m: |
129 self._split_name = m.group(1) | 126 self._split_name = m.group(1) |
130 return self._split_name | 127 return self._split_name |
131 return None | 128 return None |
132 | 129 |
133 def _GetManifest(self): | 130 def _GetManifest(self): |
134 if not self._manifest: | 131 if not self._manifest: |
135 self._manifest = _ParseManifestFromApk(self._apk_path) | 132 self._manifest = _ParseManifestFromApk(self._apk_path) |
136 return self._manifest | 133 return self._manifest |
137 | 134 |
OLD | NEW |