update: handle random drawable folder names when parsing icons

The app com.android.acehk.aceapp37423 had this invalid stuff in it:

     6165  2014-03-28 12:52   res/drawable-320dpi/ic_launcher.png
This commit is contained in:
Hans-Christoph Steiner 2018-07-13 11:28:11 +02:00
parent 997bcb7b3d
commit 53b906d00a

View file

@ -1081,6 +1081,11 @@ def scan_apk(apk_file):
def _get_apk_icons_src(apkfile, icon_name):
"""Extract the paths to the app icon in all available densities
The folder name is normally generated by the Android Tools, but
there is nothing that prevents people from using whatever DPI
names they make up. Android will just ignore them, so we should
too.
"""
icons_src = dict()
density_re = re.compile(r'^res/(.*)/{}\.(png|xml)$'.format(icon_name))
@ -1089,9 +1094,9 @@ def _get_apk_icons_src(apkfile, icon_name):
m = density_re.match(filename)
if m:
folder = m.group(1).split('-')
if len(folder) > 1 and folder[1].endswith('dpi'):
try:
density = screen_resolutions[folder[1]]
else:
except Exception:
density = '160'
icons_src[density] = m.group(0)
if icons_src.get('-1') is None and '160' in icons_src: