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 itertools | |
8 import re | 7 import re |
9 | 8 |
10 from devil import base_error | 9 from devil import base_error |
11 from devil.android.sdk import aapt | 10 from devil.android.sdk import aapt |
12 | 11 |
13 | 12 |
14 _MANIFEST_ATTRIBUTE_RE = re.compile( | 13 _MANIFEST_ATTRIBUTE_RE = re.compile( |
15 r'\s*A: ([^\(\)= ]*)(?:\([^\(\)= ]*\))?=' | 14 r'\s*A: ([^\(\)= ]*)(?:\([^\(\)= ]*\))?=' |
16 r'(?:"(.*)" \(Raw: .*\)|\(type.*?\)(.*))$') | 15 r'(?:"(.*)" \(Raw: .*\)|\(type.*?\)(.*))$') |
17 _MANIFEST_ELEMENT_RE = re.compile(r'\s*(?:E|N): (\S*) .*$') | 16 _MANIFEST_ELEMENT_RE = re.compile(r'\s*(?:E|N): (\S*) .*$') |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 manifest_info = self._GetManifest() | 181 manifest_info = self._GetManifest() |
183 try: | 182 try: |
184 return manifest_info['manifest'][0]['split'] | 183 return manifest_info['manifest'][0]['split'] |
185 except KeyError: | 184 except KeyError: |
186 return None | 185 return None |
187 | 186 |
188 def HasIsolatedProcesses(self): | 187 def HasIsolatedProcesses(self): |
189 """Returns whether any services exist that use isolatedProcess=true.""" | 188 """Returns whether any services exist that use isolatedProcess=true.""" |
190 manifest_info = self._GetManifest() | 189 manifest_info = self._GetManifest() |
191 try: | 190 try: |
192 applications = manifest_info['manifest'][0].get('application', []) | 191 application = manifest_info['manifest'][0]['application'][0] |
193 services = itertools.chain( | 192 services = application['service'] |
perezju
2017/09/28 10:24:38
what's the reason for this change from all applica
agrieve
2017/09/28 11:54:34
Just wanted to make it consistent with how GetAllM
| |
194 *(application.get('service', []) for application in applications)) | |
195 return any( | 193 return any( |
196 _ParseNumericKey(s, 'android:isolatedProcess') for s in services) | 194 _ParseNumericKey(s, 'android:isolatedProcess') for s in services) |
197 except KeyError: | 195 except KeyError: |
198 return False | 196 return False |
199 | 197 |
198 def GetAllMetadata(self): | |
199 """Returns a list meta-data tags as (name, value) tuples.""" | |
200 manifest_info = self._GetManifest() | |
201 try: | |
202 application = manifest_info['manifest'][0]['application'][0] | |
203 metadata = application['meta-data'] | |
204 return [(x.get('android:name'), x.get('android:value')) for x in metadata] | |
205 except KeyError: | |
206 return [] | |
207 | |
200 def _GetManifest(self): | 208 def _GetManifest(self): |
201 if not self._manifest: | 209 if not self._manifest: |
202 self._manifest = _ParseManifestFromApk(self._apk_path) | 210 self._manifest = _ParseManifestFromApk(self._apk_path) |
203 return self._manifest | 211 return self._manifest |
204 | 212 |
205 def _ResolveName(self, name): | 213 def _ResolveName(self, name): |
206 name = name.lstrip('.') | 214 name = name.lstrip('.') |
207 if '.' not in name: | 215 if '.' not in name: |
208 return '%s.%s' % (self.GetPackageName(), name) | 216 return '%s.%s' % (self.GetPackageName(), name) |
209 return name | 217 return name |
OLD | NEW |