Adjust some values in xml 53/109553/12 accepted/tizen/3.0/common/20170120.102132 accepted/tizen/3.0/ivi/20170119.225313 accepted/tizen/3.0/mobile/20170119.225224 accepted/tizen/3.0/tv/20170119.225241 accepted/tizen/3.0/wearable/20170119.225255 submit/tizen_3.0/20170118.065338
authorJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 10 Jan 2017 11:04:04 +0000 (20:04 +0900)
committerJunghyun Yeon <jungh.yeon@samsung.com>
Tue, 17 Jan 2017 02:13:04 +0000 (11:13 +0900)
- Onboot and autorestart features of service application
has removed since 2.3.1 in wearable, 2.4 in all other profiles
- So change modified xml files if needed

Change-Id: I1bc03b72b1b0133da88f36d0b28696397e25ab62
Signed-off-by: Junghyun Yeon <jungh.yeon@samsung.com>
CMakeLists.txt
packaging/tpk-backend.spec
src/tpk/CMakeLists.txt
src/tpk/step/pkgmgr/step_manifest_adjustment.cc

index 79d54e4..c01246f 100644 (file)
@@ -49,6 +49,7 @@ PKG_CHECK_MODULES(PKGMGR_TYPES_DEPS REQUIRED pkgmgr-types)
 PKG_CHECK_MODULES(TPK_MANIFEST_HANDLERS_DEPS REQUIRED tpk-manifest-handlers)
 PKG_CHECK_MODULES(MANIFEST_PARSER_DEPS REQUIRED manifest-parser)
 PKG_CHECK_MODULES(VCONF_DEPS REQUIRED vconf)
+PKG_CHECK_MODULES(CAPI_SYSTEM_INFO_DEPS REQUIRED capi-system-info)
 
 FIND_PACKAGE(Boost REQUIRED COMPONENTS system filesystem regex program_options)
 FIND_PACKAGE(GTest REQUIRED)
index c00c9ac..f9b1c24 100644 (file)
@@ -17,7 +17,7 @@ BuildRequires:  pkgconfig(pkgmgr)
 BuildRequires:  pkgconfig(pkgmgr-types)
 BuildRequires:  pkgconfig(tpk-manifest-handlers)
 BuildRequires:  pkgconfig(vconf)
-
+BuildRequires:  pkgconfig(capi-system-info)
 %description
 Backend for tizen package files
 
index f512064..e26f122 100644 (file)
@@ -20,6 +20,7 @@ APPLY_PKG_CONFIG(${TARGET_LIBNAME_TPK} PUBLIC
   PKGMGR_DEPS
   MANIFEST_PARSER_DEPS
   TPK_MANIFEST_HANDLERS_DEPS
+  CAPI_SYSTEM_INFO_DEPS
   Boost
 )
 
index 2c2a1a4..ee5ccae 100644 (file)
@@ -4,6 +4,10 @@
 
 #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 {
 
@@ -87,6 +102,54 @@ common_installer::Step::Status StepManifestAdjustment::process() {
     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);