Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUp(self):
file_path = os.path.abspath(os.path.join(
os.path.dirname(__file__), "..", 'data', 'test'))
with zipfile.ZipFile(file_path, mode="r") as zf:
data = zf.read('resources.arsc')
self.arscobj = ARSCParser(data)
self.package = self.arscobj.get_packages_names()[0]
def _init_app_icon(self):
files = self.get_files()
result = re.search(r':icon="@(.*?)"', self.get_org_manifest())
ids = '0x' + result.groups()[0].lower()
try:
with apkfile.ZipFile(self.apk_path, 'r') as z:
data = z.read('resources.arsc')
self.arscobj = ARSCParser(data)
self.package = self.arscobj.get_packages_names()[0]
datas = xmltodict.parse(
self.arscobj.get_public_resources(self.package))
for item in datas['resources']['public']:
if ids != item['@id']:
continue
for f in files:
name = f['name']
if item['@type'] in name and item['@name'] in name:
self.app_icon = name
except Exception as ex:
raise ex
def _init_arsc(self):
ARSC_NAME = 'resources.arsc'
try:
with apkfile.ZipFile(self.apk_path, mode="r") as zf:
if ARSC_NAME in zf.namelist():
data = zf.read(ARSC_NAME)
self.arsc = ARSCParser(data)
except Exception as e:
raise e
def get_resolved_res_configs(self, rid, config=None):
resolver = ARSCParser.ResourceResolver(self, config)
return resolver.resolve(rid)