1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-09-02 11:22:41 +01:00

Implement caching of ApkInfo

Allow caching of ApkInfo to prevent the requirement of re-parsing
of APK files.
This commit is contained in:
Marc Bonnici
2020-06-01 10:35:18 +01:00
committed by setrofim
parent 4557da2f80
commit 1425a6f6c9
5 changed files with 87 additions and 26 deletions

View File

@@ -16,16 +16,14 @@ import logging
import os
import re
from devlib.utils.android import ApkInfo
from wa.framework import pluginloader
from wa.framework.plugin import Plugin
from wa.framework.exception import ResourceError
from wa.framework.configuration import settings
from wa.utils import log
from wa.utils.android import get_cacheable_apk_info
from wa.utils.misc import get_object_name
from wa.utils.types import enum, list_or_string, prioritylist, version_tuple
from wa.utils.misc import lock_file
SourcePriority = enum(['package', 'remote', 'lan', 'local',
@@ -281,8 +279,7 @@ class ResourceResolver(object):
def apk_version_matches(path, version):
version = list_or_string(version)
with lock_file(path):
info = ApkInfo(path)
info = get_cacheable_apk_info(path)
for v in version:
if info.version_name == v or info.version_code == v:
return True
@@ -292,8 +289,7 @@ def apk_version_matches(path, version):
def apk_version_matches_range(path, min_version=None, max_version=None):
with lock_file(path):
info = ApkInfo(path)
info = get_cacheable_apk_info(path)
return range_version_matching(info.version_name, min_version, max_version)
@@ -336,21 +332,18 @@ def file_name_matches(path, pattern):
def uiauto_test_matches(path, uiauto):
with lock_file(path):
info = ApkInfo(path)
info = get_cacheable_apk_info(path)
return uiauto == ('com.arm.wa.uiauto' in info.package)
def package_name_matches(path, package):
with lock_file(path):
info = ApkInfo(path)
info = get_cacheable_apk_info(path)
return info.package == package
def apk_abi_matches(path, supported_abi, exact_abi=False):
supported_abi = list_or_string(supported_abi)
with lock_file(path):
info = ApkInfo(path)
info = get_cacheable_apk_info(path)
# If no native code present, suitable for all devices.
if not info.native_code:
return True