+ ' is not a valid minSdkVersion!')
else:
apk['minSdkVersion'] = m.group(1)
+ # if target not set, default to min
+ if 'targetSdkVersion' not in apk:
+ apk['targetSdkVersion'] = m.group(1)
+ elif line.startswith("targetSdkVersion:"):
+ m = re.match(sdkversion_pat, line)
+ if m is None:
+ logging.error(line.replace('targetSdkVersion:', '')
+ + ' is not a valid targetSdkVersion!')
+ else:
+ apk['targetSdkVersion'] = m.group(1)
elif line.startswith("maxSdkVersion:"):
apk['maxSdkVersion'] = re.match(sdkversion_pat, line).group(1)
elif line.startswith("native-code:"):
for mirror in config.get('mirrors', []):
addElement('mirror', urllib.parse.urljoin(mirror, urlbasepath), doc, repoel)
- repoel.setAttribute("version", "15")
+ repoel.setAttribute("version", "16")
repoel.setAttribute("timestamp", str(int(time.time())))
nosigningkey = False
addElement('sig', apk['sig'], doc, apkel)
addElement('size', str(apk['size']), doc, apkel)
addElement('sdkver', str(apk['minSdkVersion']), doc, apkel)
+ if 'targetSdkVersion' in apk:
+ addElement('targetSdkVersion', str(apk['targetSdkVersion']), doc, apkel)
if 'maxSdkVersion' in apk:
addElement('maxsdkver', str(apk['maxSdkVersion']), doc, apkel)
if 'added' in apk:
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()