From c8e61aa02dc2fb3afa6d818f2e14dbaaf11f7cdd Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Fri, 13 Jul 2018 11:28:11 +0200 Subject: [PATCH] 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 --- fdroidserver/update.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fdroidserver/update.py b/fdroidserver/update.py index 15b055e0..e1e095fc 100644 --- a/fdroidserver/update.py +++ b/fdroidserver/update.py @@ -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: