mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-10-08 10:21:05 +03:00
implement common.get_apk_id() using androguard
This commit is contained in:
parent
98a2f70e38
commit
27a5cce832
4 changed files with 66 additions and 37 deletions
|
@ -1181,27 +1181,6 @@ def scan_apk_aapt(apk, apkfile):
|
|||
apk['icons_src'] = _get_apk_icons_src(apkfile, icon_name)
|
||||
|
||||
|
||||
def _ensure_final_value(packageName, arsc, value):
|
||||
"""Ensure incoming value is always the value, not the resid
|
||||
|
||||
androguard will sometimes return the Android "resId" aka
|
||||
Resource ID instead of the actual value. This checks whether
|
||||
the value is actually a resId, then performs the Android
|
||||
Resource lookup as needed.
|
||||
|
||||
"""
|
||||
if value:
|
||||
returnValue = value
|
||||
if value[0] == '@':
|
||||
try: # can be a literal value or a resId
|
||||
res_id = int(value.replace("@", "0x"), 16)
|
||||
res_id = arsc.get_id(packageName, res_id)[1]
|
||||
returnValue = arsc.get_string(packageName, res_id)[1]
|
||||
except ValueError:
|
||||
pass
|
||||
return returnValue
|
||||
|
||||
|
||||
def _sanitize_sdk_version(value):
|
||||
"""Sanitize the raw values from androguard to handle bad values
|
||||
|
||||
|
@ -1250,8 +1229,8 @@ def scan_apk_androguard(apk, apkfile):
|
|||
apk['versionCode'] = int(apkobject.get_androidversion_code())
|
||||
apk['name'] = apkobject.get_app_name()
|
||||
|
||||
apk['versionName'] = _ensure_final_value(apk['packageName'], arsc,
|
||||
apkobject.get_androidversion_name())
|
||||
apk['versionName'] = common.ensure_final_value(apk['packageName'], arsc,
|
||||
apkobject.get_androidversion_name())
|
||||
|
||||
minSdkVersion = _sanitize_sdk_version(apkobject.get_min_sdk_version())
|
||||
if minSdkVersion is not None:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue