From cdc7c98707d7b3fba8f25e9a7e10e88c035cc98e Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 1 Apr 2024 11:42:23 +0200 Subject: [PATCH] common.get_androguard_APK() is no longer private to the module --- fdroidserver/common.py | 6 +++--- tests/common.TestCase | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/fdroidserver/common.py b/fdroidserver/common.py index c7c4c5c2..3c7d7dc0 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -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')) diff --git a/tests/common.TestCase b/tests/common.TestCase index 543e8eb6..925d61e0 100755 --- a/tests/common.TestCase +++ b/tests/common.TestCase @@ -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'))