parse targetSdkVersion from APKs

The default targetSdkVersion is minSdkVersion, according to the docs:
https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#target

https://gitlab.com/fdroid/fdroidclient/issues/682
This commit is contained in:
Hans-Christoph Steiner 2016-06-14 11:43:07 +02:00
parent 032dbc3e8d
commit 1b7a8f85fc
4 changed files with 40 additions and 1 deletions

View file

@ -83,6 +83,32 @@ class UpdateTest(unittest.TestCase):
pysig = fdroidserver.update.getsig(apkfile)
self.assertIsNone(pysig, "python sig should be None: " + str(sig))
def testScanApks(self):
os.chdir(os.path.dirname(__file__))
if os.path.basename(os.getcwd()) != 'tests':
raise Exception('This test must be run in the "tests/" subdir')
config = dict()
fdroidserver.common.fill_config_defaults(config)
config['ndk_paths'] = dict()
config['accepted_formats'] = ['json', 'txt', 'xml', 'yml']
fdroidserver.common.config = config
fdroidserver.update.config = config
fdroidserver.update.options = type('', (), {})()
fdroidserver.update.options.clean = True
alltestapps = fdroidserver.metadata.read_metadata(xref=True)
apps = dict()
apps['info.guardianproject.urzip'] = alltestapps['info.guardianproject.urzip']
knownapks = fdroidserver.common.KnownApks()
apks, cachechanged = fdroidserver.update.scan_apks(apps, {}, 'repo', knownapks, False)
self.assertEqual(len(apks), 1)
apk = apks[0]
self.assertEqual(apk['minSdkVersion'], '4')
self.assertEqual(apk['targetSdkVersion'], '18')
self.assertFalse('maxSdkVersion' in apk)
if __name__ == "__main__":
parser = optparse.OptionParser()