1
0
mirror of https://gitlab.com/fdroid/fdroidserver.git synced 2024-11-04 14:30:11 +01:00

Merge branch 'master' into 'master'

two update parsing fixes  when using androguard

See merge request fdroid/fdroidserver!477
This commit is contained in:
Hans-Christoph Steiner 2018-03-13 11:36:43 +00:00
commit b445fc066b
3 changed files with 16 additions and 7 deletions

View File

@ -60,6 +60,7 @@ APK_PERMISSION_PAT = \
APK_FEATURE_PAT = re.compile(".*name='([^']*)'.*") APK_FEATURE_PAT = re.compile(".*name='([^']*)'.*")
screen_densities = ['65534', '640', '480', '320', '240', '160', '120'] screen_densities = ['65534', '640', '480', '320', '240', '160', '120']
# resolutions must end with 'dpi'
screen_resolutions = { screen_resolutions = {
"xxxhdpi": '640', "xxxhdpi": '640',
"xxhdpi": '480', "xxhdpi": '480',
@ -67,7 +68,7 @@ screen_resolutions = {
"hdpi": '240', "hdpi": '240',
"mdpi": '160', "mdpi": '160',
"ldpi": '120', "ldpi": '120',
"undefined": '-1', "undefineddpi": '-1',
"anydpi": '65534', "anydpi": '65534',
"nodpi": '65535' "nodpi": '65535'
} }
@ -1090,12 +1091,12 @@ def _get_apk_icons_src(apkfile, icon_name):
m = density_re.match(filename) m = density_re.match(filename)
if m: if m:
folder = m.group(1).split('-') folder = m.group(1).split('-')
if len(folder) > 1: if len(folder) > 1 and folder[1].endswith('dpi'):
density = screen_resolutions[folder[1]] density = screen_resolutions[folder[1]]
else: else:
density = '160' density = '160'
icons_src[density] = m.group(0) 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'] icons_src['-1'] = icons_src['160']
return icons_src return icons_src
@ -1223,9 +1224,11 @@ def scan_apk_androguard(apk, apkfile):
if apkobject.get_target_sdk_version() is not None: if apkobject.get_target_sdk_version() is not None:
apk['targetSdkVersion'] = apkobject.get_target_sdk_version() apk['targetSdkVersion'] = apkobject.get_target_sdk_version()
icon_id = int(apkobject.get_element("application", "icon").replace("@", "0x"), 16) icon_id_str = apkobject.get_element("application", "icon")
icon_name = arsc.get_id(apk['packageName'], icon_id)[1] if icon_id_str:
apk['icons_src'] = _get_apk_icons_src(apkfile, icon_name) icon_id = int(icon_id_str.replace("@", "0x"), 16)
icon_name = arsc.get_id(apk['packageName'], icon_id)[1]
apk['icons_src'] = _get_apk_icons_src(apkfile, icon_name)
arch_re = re.compile("^lib/(.*)/.*$") arch_re = re.compile("^lib/(.*)/.*$")
arch = set([arch_re.match(file).group(1) for file in apkobject.get_files() if arch_re.match(file)]) arch = set([arch_re.match(file).group(1) for file in apkobject.get_files() if arch_re.match(file)])
@ -1262,7 +1265,10 @@ def scan_apk_androguard(apk, apkfile):
apk['uses-permission-sdk-23'].append(permission_sdk_23) apk['uses-permission-sdk-23'].append(permission_sdk_23)
for item in xml.findall('uses-feature'): 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" \ if feature != "android.hardware.screen.portrait" \
and feature != "android.hardware.screen.landscape": and feature != "android.hardware.screen.landscape":
if feature.startswith("android.feature."): if feature.startswith("android.feature."):

Binary file not shown.

View File

@ -333,6 +333,9 @@ class UpdateTest(unittest.TestCase):
'320': 'res/drawable-xhdpi-v4/icon.png', '320': 'res/drawable-xhdpi-v4/icon.png',
'-1': 'res/drawable-mdpi-v4/icon.png'}) '-1': 'res/drawable-mdpi-v4/icon.png'})
apk_info = fdroidserver.update.scan_apk('SpeedoMeterApp.main_1.apk')
self.assertEqual(apk_info['icons_src'], {})
def test_scan_apk_no_sig(self): def test_scan_apk_no_sig(self):
config = dict() config = dict()
fdroidserver.common.fill_config_defaults(config) fdroidserver.common.fill_config_defaults(config)