def resolve_package_from_target(self): # pylint: disable=too-many-branches self.logger.debug('Resolving package on target') if self.package_name: if not self.target.package_is_installed(self.package_name): return else: installed_versions = [] for package in self.owner.package_names: if self.target.package_is_installed(package): installed_versions.append(package) if self.version: matching_packages = [] for package in installed_versions: package_version = self.target.get_package_version(package) for v in list_or_string(self.version): if loose_version_matching(v, package_version): matching_packages.append(package) if len(matching_packages) == 1: self.package_name = matching_packages[0] elif len(matching_packages) > 1: msg = 'Multiple matches for version "{}" found on device.' self.error_msg = msg.format(self.version) else: if len(installed_versions) == 1: self.package_name = installed_versions[0] elif len(installed_versions) > 1: self.error_msg = 'Package version not set and multiple versions found on device.' if self.package_name: self.logger.debug('Found matching package on target; Pulling to host.') self.apk_file = self.pull_apk(self.package_name)
def apk_version_matches(path, version): version = list_or_string(version) info = ApkInfo(path) for v in version: if info.version_name == v or info.version_code == v: return True if loose_version_matching(v, info.version_name): return True return False
def apk_version_matches(path, version): version = list_or_string(version) info = get_cacheable_apk_info(path) for v in version: if v in (info.version_name, info.version_code): return True if loose_version_matching(v, info.version_name): return True return False
def apk_abi_matches(path, supported_abi, exact_abi=False): supported_abi = list_or_string(supported_abi) info = ApkInfo(path) # If no native code present, suitable for all devices. if not info.native_code: return True if exact_abi: # Only check primary return supported_abi[0] in info.native_code else: for abi in supported_abi: if abi in info.native_code: return True return False
def apk_abi_matches(path, supported_abi, exact_abi=False): supported_abi = list_or_string(supported_abi) info = ApkInfo(path) # If no native code present, suitable for all devices. if not info.native_code: return True if exact_abi: # Only check primary return supported_abi[0] in info.native_code else: for abi in supported_abi: if abi in info.native_code: return True return False