#include "tpk/step/pkgmgr/step_manifest_adjustment.h"
+#include <system_info.h>
+#include <common/utils/glist_range.h>
+#include <manifest_parser/utils/version_number.h>
+
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <libxml/parser.h>
#include <libxml/xpathInternals.h>
#include <string>
+#include "common/utils/profile_util.h"
+#include "common/installer_context.h"
+
namespace bs = boost::system;
namespace bf = boost::filesystem;
using libxml_char = const unsigned char *;
+namespace {
+
+const xmlChar kOnBootAttributeKey[] = "on-boot";
+const xmlChar kAutoRestartAttributeKey[] = "auto-restart";
+const char kXmlXSvcAppExpr[] = "//*[local-name()='service-application']";
+
+} // namespace
+
namespace tpk {
namespace pkgmgr {
return Step::Status::ERROR;
}
+ if ((context_->privilege_level.get() !=
+ common_installer::PrivilegeLevel::PARTNER) &&
+ (context_->privilege_level.get() !=
+ common_installer::PrivilegeLevel::PLATFORM)) {
+ utils::VersionNumber api_version =
+ utils::VersionNumber(context_->manifest_data.get()->api_version);
+ utils::VersionNumber platform_version =
+ utils::VersionNumber((common_installer::GetTizenProfile() ==
+ common_installer::TizenProfile::WEARABLE) ?
+ "2.3.1" : "2.4.0");
+
+ if (api_version >= platform_version) {
+ xmlXPathContextPtr xpath_ctx = xmlXPathNewContext(doc);
+ if (!xpath_ctx) {
+ LOG(ERROR) << "Failed to create XPath context";
+ xmlFreeDoc(doc);
+ return Step::Status::ERROR;
+ }
+
+ for (auto& app : GListRange<application_x*>(
+ context_->manifest_data.get()->application)) {
+ std::string expr = std::string(kXmlXSvcAppExpr);
+ xmlXPathObjectPtr xpath_obj = xmlXPathEvalExpression(
+ (const xmlChar*)expr.c_str(), xpath_ctx);
+ if (!xpath_obj || xmlXPathNodeSetIsEmpty(xpath_obj->nodesetval)) {
+ if (xpath_obj)
+ xmlXPathFreeObject(xpath_obj);
+ continue;
+ }
+
+ for (int i = 0; i < xpath_obj->nodesetval->nodeNr; i++) {
+ xmlNodePtr node = xpath_obj->nodesetval->nodeTab[i];
+ xmlSetProp(node, kOnBootAttributeKey, (const xmlChar*)"false");
+ xmlSetProp(node, kAutoRestartAttributeKey, (const xmlChar*)"false");
+ }
+
+ if (app->autorestart)
+ free(app->autorestart);
+ app->autorestart = strdup("false");
+
+ if (app->onboot)
+ free(app->onboot);
+ app->onboot = strdup("false");
+ }
+ xmlXPathFreeContext(xpath_ctx);
+ }
+ }
+
if (xmlSaveFile(xml_path_.c_str(), doc) == -1) {
LOG(ERROR) << "Failed to modify xml file";
xmlFreeDoc(doc);