Merge branch 'master' into 'master'

update: handle AndroidManifest XML namespace named other than 'android'

See merge request fdroid/fdroidserver!481
This commit is contained in:
Hans-Christoph Steiner 2018-03-15 15:23:55 +00:00
commit 4b788b3b09

View file

@ -1242,10 +1242,13 @@ def scan_apk_androguard(apk, apkfile):
apk['nativecode'].extend(sorted(list(arch))) apk['nativecode'].extend(sorted(list(arch)))
xml = apkobject.get_android_manifest_xml() xml = apkobject.get_android_manifest_xml()
xmlns = xml.nsmap.get('android')
if not xmlns:
xmlns = 'http://schemas.android.com/apk/res/android'
for item in xml.findall('uses-permission'): for item in xml.findall('uses-permission'):
name = str(item.attrib['{' + xml.nsmap['android'] + '}name']) name = str(item.attrib['{' + xmlns + '}name'])
maxSdkVersion = item.attrib.get('{' + xml.nsmap['android'] + '}maxSdkVersion') maxSdkVersion = item.attrib.get('{' + xmlns + '}maxSdkVersion')
maxSdkVersion = int(maxSdkVersion) if maxSdkVersion else None maxSdkVersion = int(maxSdkVersion) if maxSdkVersion else None
permission = UsesPermission( permission = UsesPermission(
name, name,
@ -1260,8 +1263,8 @@ def scan_apk_androguard(apk, apkfile):
apk['uses-permission'].append(permission) apk['uses-permission'].append(permission)
for item in xml.findall('uses-permission-sdk-23'): for item in xml.findall('uses-permission-sdk-23'):
name = str(item.attrib['{' + xml.nsmap['android'] + '}name']) name = str(item.attrib['{' + xmlns + '}name'])
maxSdkVersion = item.attrib.get('{' + xml.nsmap['android'] + '}maxSdkVersion') maxSdkVersion = item.attrib.get('{' + xmlns + '}maxSdkVersion')
maxSdkVersion = int(maxSdkVersion) if maxSdkVersion else None maxSdkVersion = int(maxSdkVersion) if maxSdkVersion else None
permission_sdk_23 = UsesPermissionSdk23( permission_sdk_23 = UsesPermissionSdk23(
name, name,
@ -1270,7 +1273,7 @@ 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'):
key = '{' + xml.nsmap['android'] + '}name' key = '{' + xmlns + '}name'
if key not in item.attrib: if key not in item.attrib:
continue continue
feature = str(item.attrib[key]) feature = str(item.attrib[key])
@ -1278,7 +1281,7 @@ def scan_apk_androguard(apk, apkfile):
and feature != "android.hardware.screen.landscape": and feature != "android.hardware.screen.landscape":
if feature.startswith("android.feature."): if feature.startswith("android.feature."):
feature = feature[16:] feature = feature[16:]
required = item.attrib.get('{' + xml.nsmap['android'] + '}required') required = item.attrib.get('{' + xmlns + '}required')
if required is None or required == 'true': if required is None or required == 'true':
apk['features'].append(feature) apk['features'].append(feature)