mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-05 06:50:29 +03:00
fallback to minsdk when targetsdk isn't set
Androguard already has a function always returning an int here, so let's use that. Also put in a guard against minsdk not being set.
This commit is contained in:
parent
1f7228d538
commit
7de601a5b5
4 changed files with 50 additions and 4 deletions
|
|
@ -3047,6 +3047,19 @@ def apk_extract_signatures(apkpath, outdir, manifest=True):
|
|||
out_file.write(in_apk.read(f.filename))
|
||||
|
||||
|
||||
def get_min_sdk_version(apk):
|
||||
"""
|
||||
This wraps the androguard function to always return and int and fall back to 1
|
||||
if we can't get a valid minsdk version
|
||||
:param apk: androguard apk object
|
||||
:return: minsdk as int
|
||||
"""
|
||||
try:
|
||||
return int(apk.get_min_sdk_version())
|
||||
except TypeError:
|
||||
return 1
|
||||
|
||||
|
||||
def sign_apk(unsigned_path, signed_path, keyalias):
|
||||
"""Sign and zipalign an unsigned APK, then save to a new file, deleting the unsigned
|
||||
|
||||
|
|
@ -3068,7 +3081,7 @@ def sign_apk(unsigned_path, signed_path, keyalias):
|
|||
|
||||
"""
|
||||
apk = _get_androguard_APK(unsigned_path)
|
||||
if int(apk.get_target_sdk_version()) >= 30:
|
||||
if apk.get_effective_target_sdk_version() >= 30:
|
||||
if config['keystore'] == 'NONE':
|
||||
# NOTE: apksigner doesn't like -providerName/--provider-name at all, don't use
|
||||
# apksigner documents the options as --ks-provider-class and --ks-provider-arg
|
||||
|
|
@ -3098,7 +3111,7 @@ def sign_apk(unsigned_path, signed_path, keyalias):
|
|||
os.remove(unsigned_path)
|
||||
else:
|
||||
|
||||
if int(apk.get_min_sdk_version()) < 18:
|
||||
if get_min_sdk_version(apk) < 18:
|
||||
signature_algorithm = ['-sigalg', 'SHA1withRSA', '-digestalg', 'SHA1']
|
||||
else:
|
||||
signature_algorithm = ['-sigalg', 'SHA256withRSA', '-digestalg', 'SHA-256']
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue