APK_FEATURE_PAT = re.compile(".*name='([^']*)'.*")
screen_densities = ['65534', '640', '480', '320', '240', '160', '120']
+# resolutions must end with 'dpi'
screen_resolutions = {
"xxxhdpi": '640',
"xxhdpi": '480',
"hdpi": '240',
"mdpi": '160',
"ldpi": '120',
- "undefined": '-1',
+ "undefineddpi": '-1',
"anydpi": '65534',
"nodpi": '65535'
}
m = density_re.match(filename)
if m:
folder = m.group(1).split('-')
- if len(folder) > 1:
+ if len(folder) > 1 and folder[1].endswith('dpi'):
density = screen_resolutions[folder[1]]
else:
density = '160'
icons_src[density] = m.group(0)
- if icons_src.get('-1') is None:
+ if icons_src.get('-1') is None and '160' in icons_src:
icons_src['-1'] = icons_src['160']
return icons_src
apk['uses-permission-sdk-23'].append(permission_sdk_23)
for item in xml.findall('uses-feature'):
- feature = str(item.attrib['{' + xml.nsmap['android'] + '}name'])
+ key = '{' + xml.nsmap['android'] + '}name'
+ if key not in item.attrib:
+ continue
+ feature = str(item.attrib[key])
if feature != "android.hardware.screen.portrait" \
and feature != "android.hardware.screen.landscape":
if feature.startswith("android.feature."):