def parse(self, apk_path): _check_env() command = [aapt, 'dump', 'badging', apk_path] logger.debug(' '.join(command)) output = subprocess.check_output(command) for line in output.split('\n'): if line.startswith('application-label:'): self.label = line.split(':')[1].strip().replace('\'', '') elif line.startswith('package:'): match = self.version_regex.search(line) if match: self.package = match.group('name') self.version_code = match.group('vcode') self.version_name = match.group('vname') elif line.startswith('launchable-activity:'): match = self.name_regex.search(line) self.activity = match.group('name') elif line.startswith('native-code'): apk_abis = [entry.strip() for entry in line.split(':')[1].split("'") if entry.strip()] mapped_abis = [] for apk_abi in apk_abis: found = False for abi, architectures in ABI_MAP.iteritems(): if apk_abi in architectures: mapped_abis.append(abi) found = True break if not found: mapped_abis.append(apk_abi) self.native_code = mapped_abis else: pass # not interested
def abi(self): value = self.execute('{} uname -m'.format(self.busybox)).strip() for abi, architectures in ABI_MAP.iteritems(): if value in architectures: result = abi break else: result = value return result
def abi(self): value = self.execute("uname -m").strip() for abi, architectures in ABI_MAP.iteritems(): if value in architectures: result = abi break else: result = value return result
def parse(self, apk_path): _check_env() command = [aapt, 'dump', 'badging', apk_path] logger.debug(' '.join(command)) try: output = subprocess.check_output(command, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: raise HostError( 'Error parsing APK file {}. `aapt` says:\n{}'.format( apk_path, e.output)) for line in output.split('\n'): if line.startswith('application-label:'): self.label = line.split(':')[1].strip().replace('\'', '') elif line.startswith('package:'): match = self.version_regex.search(line) if match: self.package = match.group('name') self.version_code = match.group('vcode') self.version_name = match.group('vname') elif line.startswith('launchable-activity:'): match = self.name_regex.search(line) self.activity = match.group('name') elif line.startswith('native-code'): apk_abis = [ entry.strip() for entry in line.split(':')[1].split("'") if entry.strip() ] mapped_abis = [] for apk_abi in apk_abis: found = False for abi, architectures in ABI_MAP.iteritems(): if apk_abi in architectures: mapped_abis.append(abi) found = True break if not found: mapped_abis.append(apk_abi) self.native_code = mapped_abis elif line.startswith('uses-permission:'): match = self.permission_regex.search(line) if match: self.permissions.append(match.group('permission')) else: pass # not interested
def parse(self, apk_path): _check_env() command = [aapt, 'dump', 'badging', apk_path] logger.debug(' '.join(command)) try: output = subprocess.check_output(command, stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: raise HostError('Error parsing APK file {}. `aapt` says:\n{}' .format(apk_path, e.output)) for line in output.split('\n'): if line.startswith('application-label:'): self.label = line.split(':')[1].strip().replace('\'', '') elif line.startswith('package:'): match = self.version_regex.search(line) if match: self.package = match.group('name') self.version_code = match.group('vcode') self.version_name = match.group('vname') elif line.startswith('launchable-activity:'): match = self.name_regex.search(line) self.activity = match.group('name') elif line.startswith('native-code'): apk_abis = [entry.strip() for entry in line.split(':')[1].split("'") if entry.strip()] mapped_abis = [] for apk_abi in apk_abis: found = False for abi, architectures in ABI_MAP.iteritems(): if apk_abi in architectures: mapped_abis.append(abi) found = True break if not found: mapped_abis.append(apk_abi) self.native_code = mapped_abis elif line.startswith('uses-permission:'): match = self.permission_regex.search(line) if match: self.permissions.append(match.group('permission')) else: pass # not interested