/*! Returns the minimum Android API level set for the APK. Minimum API level of the kit is returned if the manifest file of the APK can not be found or parsed. */ int AndroidManager::minimumSDK(ProjectExplorer::Target *target) { QDomDocument doc; if (!openXmlFile(doc, AndroidManager::manifestSourcePath(target))) return minimumSDK(target->kit()); return parseMinSdk(doc.documentElement()); }
QString AndroidManager::packageName(const Utils::FileName &manifestFile) { QDomDocument doc; if (!openXmlFile(doc, manifestFile)) return QString(); QDomElement manifestElem = doc.documentElement(); return manifestElem.attribute(QLatin1String("package")); }
bool AndroidManager::checkForQt51Files(Utils::FileName fileName) { fileName.appendPath(QLatin1String("android")).appendPath(QLatin1String("version.xml")); if (!fileName.exists()) return false; QDomDocument dstVersionDoc; if (!openXmlFile(dstVersionDoc, fileName)) return false; return dstVersionDoc.documentElement().attribute(QLatin1String("value")).toDouble() < 5.2; }
QString AndroidManager::applicationName(ProjectExplorer::Target *target) { QDomDocument doc; if (!openXmlFile(target, doc, stringsPath(target))) return QString(); QDomElement metadataElem = doc.documentElement().firstChildElement(QLatin1String("string")); while (!metadataElem.isNull()) { if (metadataElem.attribute(QLatin1String("name")) == QLatin1String("app_name")) return metadataElem.text(); metadataElem = metadataElem.nextSiblingElement(QLatin1String("string")); } return QString(); }
/*! Returns the minimum Android API level required by the kit to compile. -1 is returned if the kit does not support Android. */ int AndroidManager::minimumSDK(const ProjectExplorer::Kit *kit) { int minSDKVersion = -1; QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(kit); if (version && version->targetDeviceTypes().contains(Constants::ANDROID_DEVICE_TYPE)) { Utils::FileName stockManifestFilePath = Utils::FileName::fromUserInput(version->qmakeProperty("QT_INSTALL_PREFIX") + QLatin1String("/src/android/templates/AndroidManifest.xml")); QDomDocument doc; if (openXmlFile(doc, stockManifestFilePath)) { minSDKVersion = parseMinSdk(doc.documentElement()); } } return minSDKVersion; }
bool AndroidManager::setApplicationName(ProjectExplorer::Target *target, const QString &name) { QDomDocument doc; Utils::FileName path = stringsPath(target); if (!openXmlFile(target, doc, path)) return false; QDomElement metadataElem = doc.documentElement().firstChildElement(QLatin1String("string")); while (!metadataElem.isNull()) { if (metadataElem.attribute(QLatin1String("name")) == QLatin1String("app_name")) { metadataElem.removeChild(metadataElem.firstChild()); metadataElem.appendChild(doc.createTextNode(name)); break; } metadataElem = metadataElem.nextSiblingElement(QLatin1String("string")); } return saveXmlFile(target, doc, path); }
static bool openManifest(ProjectExplorer::Target *target, QDomDocument &doc) { return openXmlFile(doc, AndroidManager::manifestPath(target)); }