mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-11-13 02:30:11 +01:00
common.get_androguard_APK() is no longer private to the module
This commit is contained in:
parent
a742df3758
commit
cdc7c98707
@ -2647,7 +2647,7 @@ def use_androguard():
|
||||
use_androguard.show_path = True # type: ignore
|
||||
|
||||
|
||||
def _get_androguard_APK(apkfile):
|
||||
def get_androguard_APK(apkfile):
|
||||
try:
|
||||
from androguard.core.bytecodes.apk import APK
|
||||
except ImportError as exc:
|
||||
@ -2793,7 +2793,7 @@ def get_apk_id_androguard(apkfile):
|
||||
.format(path=apkfile))
|
||||
|
||||
if not versionName or versionName[0] == '@':
|
||||
a = _get_androguard_APK(apkfile)
|
||||
a = get_androguard_APK(apkfile)
|
||||
versionName = ensure_final_value(a.package, a.get_android_resources(), a.get_androidversion_name())
|
||||
if not versionName:
|
||||
versionName = '' # versionName is expected to always be a str
|
||||
@ -3160,7 +3160,7 @@ def get_first_signer_certificate(apkpath):
|
||||
cert_encoded = get_certificate(apk.read(cert_files[0]))
|
||||
|
||||
if not cert_encoded and use_androguard():
|
||||
apkobject = _get_androguard_APK(apkpath)
|
||||
apkobject = get_androguard_APK(apkpath)
|
||||
certs = apkobject.get_certificates_der_v2()
|
||||
if len(certs) > 0:
|
||||
logging.debug(_('Using APK Signature v2'))
|
||||
|
@ -902,7 +902,7 @@ class CommonTest(unittest.TestCase):
|
||||
self.assertTrue(os.path.isfile(signed))
|
||||
self.assertFalse(os.path.isfile(unsigned))
|
||||
self.assertTrue(fdroidserver.common.verify_apk_signature(signed))
|
||||
self.assertEqual('18', fdroidserver.common._get_androguard_APK(signed).get_min_sdk_version())
|
||||
self.assertEqual('18', fdroidserver.common.get_androguard_APK(signed).get_min_sdk_version())
|
||||
|
||||
shutil.copy(os.path.join(self.basedir, 'minimal_targetsdk_30_unsigned.apk'), self.testdir)
|
||||
unsigned = os.path.join(self.testdir, 'minimal_targetsdk_30_unsigned.apk')
|
||||
@ -915,7 +915,7 @@ class CommonTest(unittest.TestCase):
|
||||
self.assertFalse(os.path.isfile(unsigned))
|
||||
self.assertTrue(fdroidserver.common.verify_apk_signature(signed))
|
||||
# verify it has a v2 signature
|
||||
self.assertTrue(fdroidserver.common._get_androguard_APK(signed).is_signed_v2())
|
||||
self.assertTrue(fdroidserver.common.get_androguard_APK(signed).is_signed_v2())
|
||||
|
||||
shutil.copy(os.path.join(self.basedir, 'no_targetsdk_minsdk30_unsigned.apk'), self.testdir)
|
||||
unsigned = os.path.join(self.testdir, 'no_targetsdk_minsdk30_unsigned.apk')
|
||||
@ -923,7 +923,7 @@ class CommonTest(unittest.TestCase):
|
||||
|
||||
fdroidserver.common.sign_apk(unsigned, signed, config['keyalias'])
|
||||
self.assertTrue(fdroidserver.common.verify_apk_signature(signed))
|
||||
self.assertTrue(fdroidserver.common._get_androguard_APK(signed).is_signed_v2())
|
||||
self.assertTrue(fdroidserver.common.get_androguard_APK(signed).is_signed_v2())
|
||||
|
||||
shutil.copy(os.path.join(self.basedir, 'no_targetsdk_minsdk1_unsigned.apk'), self.testdir)
|
||||
unsigned = os.path.join(self.testdir, 'no_targetsdk_minsdk1_unsigned.apk')
|
||||
@ -1146,11 +1146,11 @@ class CommonTest(unittest.TestCase):
|
||||
"""This is a sanity test that androguard isn't broken"""
|
||||
|
||||
def get_minSdkVersion(apkfile):
|
||||
apk = fdroidserver.common._get_androguard_APK(apkfile)
|
||||
apk = fdroidserver.common.get_androguard_APK(apkfile)
|
||||
return fdroidserver.common.get_min_sdk_version(apk)
|
||||
|
||||
def get_targetSdkVersion(apkfile):
|
||||
apk = fdroidserver.common._get_androguard_APK(apkfile)
|
||||
apk = fdroidserver.common.get_androguard_APK(apkfile)
|
||||
return apk.get_effective_target_sdk_version()
|
||||
|
||||
self.assertEqual(4, get_minSdkVersion('bad-unicode-πÇÇ现代通用字-български-عربي1.apk'))
|
||||
|
Loading…
Reference in New Issue
Block a user