build: reuse common methods for getting metadata from APKs

This splits out the code that gets the list of native ABIs supported, then
uses the standard methods for the rest.
This commit is contained in:
Hans-Christoph Steiner 2018-09-17 22:44:53 +02:00
parent 487c4d02f3
commit 807bf3d26b
4 changed files with 109 additions and 79 deletions

View file

@ -2128,6 +2128,19 @@ def get_apk_id_aapt(apkfile):
.format(apkfilename=apkfile))
def get_native_code(apkfile):
"""aapt checks if there are architecture folders under the lib/ folder
so we are simulating the same behaviour"""
arch_re = re.compile("^lib/(.*)/.*$")
archset = set()
with ZipFile(apkfile) as apk:
for filename in apk.namelist():
m = arch_re.match(filename)
if m:
archset.add(m.group(1))
return sorted(list(archset))
def get_minSdkVersion_aapt(apkfile):
"""Extract the minimum supported Android SDK from an APK using aapt