mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-02 09:10:11 +02:00
remove aapt version of common.is_apk_and_debuggable()
This commit is contained in:
parent
b5cd850abe
commit
27b90a13bf
@ -2389,19 +2389,15 @@ def ensure_final_value(packageName, arsc, value):
|
||||
return ''
|
||||
|
||||
|
||||
def is_apk_and_debuggable_aapt(apkfile):
|
||||
p = SdkToolsPopen(['aapt', 'dump', 'xmltree', apkfile, 'AndroidManifest.xml'],
|
||||
output=False)
|
||||
if p.returncode != 0:
|
||||
raise FDroidException(_("Failed to get APK manifest information"))
|
||||
for line in p.output.splitlines():
|
||||
if 'android:debuggable' in line and not line.endswith('0x0'):
|
||||
return True
|
||||
return False
|
||||
def is_apk_and_debuggable(apkfile):
|
||||
"""Returns True if the given file is an APK and is debuggable
|
||||
|
||||
Parse only <application android:debuggable=""> from the APK.
|
||||
|
||||
def is_apk_and_debuggable_androguard(apkfile):
|
||||
"""Parse only <application android:debuggable=""> from the APK"""
|
||||
:param apkfile: full path to the apk to check"""
|
||||
|
||||
if get_file_extension(apkfile) != 'apk':
|
||||
return False
|
||||
from androguard.core.bytecodes.axml import AXMLParser, format_value, START_TAG
|
||||
with ZipFile(apkfile) as apk:
|
||||
with apk.open('AndroidManifest.xml') as manifest:
|
||||
@ -2423,20 +2419,6 @@ def is_apk_and_debuggable_androguard(apkfile):
|
||||
return False
|
||||
|
||||
|
||||
def is_apk_and_debuggable(apkfile):
|
||||
"""Returns True if the given file is an APK and is debuggable
|
||||
|
||||
:param apkfile: full path to the apk to check"""
|
||||
|
||||
if get_file_extension(apkfile) != 'apk':
|
||||
return False
|
||||
|
||||
if use_androguard():
|
||||
return is_apk_and_debuggable_androguard(apkfile)
|
||||
else:
|
||||
return is_apk_and_debuggable_aapt(apkfile)
|
||||
|
||||
|
||||
def get_apk_id(apkfile):
|
||||
"""Extract identification information from APK.
|
||||
|
||||
|
@ -148,11 +148,6 @@ class CommonTest(unittest.TestCase):
|
||||
config = dict()
|
||||
fdroidserver.common.fill_config_defaults(config)
|
||||
fdroidserver.common.config = config
|
||||
self._set_build_tools()
|
||||
try:
|
||||
config['aapt'] = fdroidserver.common.find_sdk_tools_cmd('aapt')
|
||||
except fdroidserver.exception.FDroidException:
|
||||
pass # aapt is not required if androguard is present
|
||||
|
||||
# these are set debuggable
|
||||
testfiles = []
|
||||
@ -160,15 +155,8 @@ class CommonTest(unittest.TestCase):
|
||||
testfiles.append(os.path.join(self.basedir, 'urzip-badsig.apk'))
|
||||
testfiles.append(os.path.join(self.basedir, 'urzip-badcert.apk'))
|
||||
for apkfile in testfiles:
|
||||
debuggable = fdroidserver.common.is_apk_and_debuggable(apkfile)
|
||||
self.assertTrue(debuggable,
|
||||
self.assertTrue(fdroidserver.common.is_apk_and_debuggable(apkfile),
|
||||
"debuggable APK state was not properly parsed!")
|
||||
if 'aapt' in config:
|
||||
self.assertTrue(fdroidserver.common.is_apk_and_debuggable_aapt(apkfile),
|
||||
'aapt parsing missed <application android:debuggable="">!')
|
||||
if fdroidserver.common.use_androguard():
|
||||
self.assertTrue(fdroidserver.common.is_apk_and_debuggable_androguard(apkfile),
|
||||
'androguard missed <application android:debuggable="">!')
|
||||
|
||||
# these are set NOT debuggable
|
||||
testfiles = []
|
||||
@ -176,15 +164,8 @@ class CommonTest(unittest.TestCase):
|
||||
testfiles.append(os.path.join(self.basedir, 'urzip-release-unsigned.apk'))
|
||||
testfiles.append(os.path.join(self.basedir, 'v2.only.sig_2.apk'))
|
||||
for apkfile in testfiles:
|
||||
debuggable = fdroidserver.common.is_apk_and_debuggable(apkfile)
|
||||
self.assertFalse(debuggable,
|
||||
self.assertFalse(fdroidserver.common.is_apk_and_debuggable(apkfile),
|
||||
"debuggable APK state was not properly parsed!")
|
||||
if 'aapt' in config:
|
||||
self.assertFalse(fdroidserver.common.is_apk_and_debuggable_aapt(apkfile),
|
||||
'aapt parsing missed <application android:debuggable="">!')
|
||||
if fdroidserver.common.use_androguard():
|
||||
self.assertFalse(fdroidserver.common.is_apk_and_debuggable_androguard(apkfile),
|
||||
'androguard missed <application android:debuggable="">!')
|
||||
|
||||
VALID_STRICT_PACKAGE_NAMES = [
|
||||
"An.stop",
|
||||
|
Loading…
Reference in New Issue
Block a user