Ejemplo n.º 1
0
    def resolve_package(self, context):
        if not self.owner.package_names and not self.package_name:
            msg = 'Cannot Resolve package; No package name(s) specified'
            raise WorkloadError(msg)

        self.error_msg = None
        if self.prefer_host_package:
            self.resolve_package_from_host(context)
            if not self.apk_file:
                self.resolve_package_from_target()
        else:
            self.resolve_package_from_target()
            if not self.apk_file:
                self.resolve_package_from_host(context)

        if self.apk_file:
            self.apk_info = ApkInfo(self.apk_file)
        else:
            if self.error_msg:
                raise WorkloadError(self.error_msg)
            else:
                if self.package_name:
                    message = 'Package "{package}" not found for workload {name} '\
                              'on host or target.'
                elif self.version:
                    message = 'No matching package found for workload {name} '\
                              '(version {version}) on host or target.'
                else:
                    message = 'No matching package found for workload {name} on host or target'
                raise WorkloadError(message.format(name=self.owner.name, version=self.version,
                                                   package=self.package_name))
Ejemplo n.º 2
0
    def __init__(self, target, apk=None, service='.TrafficMetricsService'):
        """
        Additional paramerter:

        :apk: Path to the APK file that contains ``com.arm.devlab.netstats``
              package. If not specified, it will be assumed that an APK with
              name "netstats.apk" is located in the same directory as the
              Python module for the instrument.
        :service: Name of the service to be launched. This service must be
                  present in the APK.

        """
        if target.os != 'android':
            raise TargetError(
                'netstats insturment only supports Android targets')
        if apk is None:
            apk = os.path.join(THIS_DIR, 'netstats.apk')
        if not os.path.isfile(apk):
            raise HostError(
                'APK for netstats instrument does not exist ({})'.format(apk))
        super(NetstatsInstrument, self).__init__(target)
        self.apk = apk
        self.package = ApkInfo(self.apk).package
        self.service = service
        self.tag = None
        self.command = None
        self.stop_command = 'am kill {}'.format(self.package)

        for package in self.target.list_packages():
            self.add_channel(package, 'tx')
            self.add_channel(package, 'rx')
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
 def setup(self, context):
     if hasattr(context.workload, 'apk_file'):
         self.apk_info = ApkInfo(context.workload.apk_file)
     else:
         self.apk_info = None
Ejemplo n.º 6
0
def package_name_matches(path, package):
    info = ApkInfo(path)
    return info.package == package
Ejemplo n.º 7
0
def uiauto_test_matches(path, uiauto):
    info = ApkInfo(path)
    return uiauto == ('com.arm.wa.uiauto' in info.package)
Ejemplo n.º 8
0
def apk_version_matches_range(path, min_version=None, max_version=None):
    info = ApkInfo(path)
    return range_version_matching(info.version_name, min_version, max_version)
Ejemplo n.º 9
0
 def init_resources(self, resolver):
     self.uiauto_file = resolver.get(ApkFile(self.owner, uiauto=True))
     if not self.uiauto_package:
         uiauto_info = ApkInfo(self.uiauto_file)
         self.uiauto_package = uiauto_info.package
Ejemplo n.º 10
0
def package_name_matches(path, package):
    with lock_file(path):
        info = ApkInfo(path)
    return info.package == package