From: Youmin Ha Date: Wed, 27 May 2015 05:36:38 +0000 (+0900) Subject: Single app package support including service app X-Git-Tag: accepted/tizen/common/20150529.082356~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=80c5953596c651a3c790bbd1780dc966065c8c33;p=platform%2Fcore%2Fappfw%2Fapp-installers.git Single app package support including service app To run Tizen TCT packages, single-app packages having only service apps must be able to be installed. This commit enables installing app packages having only service apps. - Removed mandatory ui-application app checking routine. - Added a routine checking the existance of at least 1 ui or service app. - Additional code for attributes in step_generate_xml.cc. Change-Id: Iaac04f6fb20055fe06ca6b3a67294c9354695ec0 Signed-off-by: Youmin Ha --- diff --git a/src/common/step/step_copy.cc b/src/common/step/step_copy.cc index 58733ea..19d4cd1 100644 --- a/src/common/step/step_copy.cc +++ b/src/common/step/step_copy.cc @@ -65,12 +65,16 @@ Step::Status StepCopy::process() { context_->pkg_path.set(install_path.string()); // FIXME: correctly order app's data. - // If there is 1 app in package, app's data are stored in / - // If there are >1 apps in package, app's data are stored in + // If there is 1 app in package, the app's data are stored in + // // + // If there are >1 apps in the package, app's data are stored in // considering that multiple apps data are already separated in folders. - if (context_->manifest_data.get()->uiapplication && - !context_->manifest_data.get()->uiapplication->next) + manifest_x *m = context_->manifest_data.get(); + if ((m->uiapplication && !m->uiapplication->next && !m->serviceapplication) || + (m->serviceapplication && !m->serviceapplication->next && + !m->uiapplication)) { install_path /= bf::path(context_->manifest_data.get()->mainapp_id); + } bs::error_code error; bf::create_directories(install_path.parent_path(), error); diff --git a/src/common/step/step_generate_xml.cc b/src/common/step/step_generate_xml.cc index b0c80ff..2a0256f 100644 --- a/src/common/step/step_generate_xml.cc +++ b/src/common/step/step_generate_xml.cc @@ -27,11 +27,29 @@ namespace fs = boost::filesystem; namespace common_installer { namespace generate_xml { +static void _writeUIApplicationAttributes( + xmlTextWriterPtr writer, uiapplication_x *app) { + xmlTextWriterWriteAttribute(writer, BAD_CAST "taskmanage", + BAD_CAST "true"); +} + +static void _writeServiceApplicationAttributes( + xmlTextWriterPtr writer, serviceapplication_x *app) { + xmlTextWriterWriteAttribute(writer, BAD_CAST "auto-restart", + BAD_CAST(app->autorestart ? app->autorestart : "false")); + xmlTextWriterWriteAttribute(writer, BAD_CAST "on-boot", + BAD_CAST(app->onboot ? app->onboot : "false")); + xmlTextWriterWriteAttribute(writer, BAD_CAST "permission-type", + BAD_CAST(app->permission_type ? app->permission_type : "")); +} + template Step::Status StepGenerateXml::GenerateApplicationCommonXml(T* app, xmlTextWriterPtr writer) { fs::path default_icon( tzplatform_mkpath(TZ_SYS_RW_ICONS, "app-installers.png")); + + // common appributes among uiapplication_x and serviceapplication_x xmlTextWriterWriteAttribute(writer, BAD_CAST "appid", BAD_CAST app->appid); // binary is a symbolic link named and is located in / @@ -44,9 +62,13 @@ Step::Status StepGenerateXml::GenerateApplicationCommonXml(T* app, else xmlTextWriterWriteAttribute(writer, BAD_CAST "type", BAD_CAST "capp"); + // app-specific attributes if (std::is_same::value) - xmlTextWriterWriteAttribute(writer, BAD_CAST "taskmanage", - BAD_CAST "true"); + _writeUIApplicationAttributes( + writer, reinterpret_cast(app)); + if (std::is_same::value) + _writeServiceApplicationAttributes( + writer, reinterpret_cast(app)); label_x* label = nullptr; LISTHEAD(app->label, label); diff --git a/src/tpk/step/step_parse.cc b/src/tpk/step/step_parse.cc index a64599c..4a8435f 100644 --- a/src/tpk/step/step_parse.cc +++ b/src/tpk/step/step_parse.cc @@ -116,7 +116,7 @@ boost::filesystem::path* StepParse::GetManifestFilePath( bool StepParse::SetContextByManifestParser(XmlTree* tree) { // Get required elements XmlElement* manifest, - * ui_application, * label; + * ui_application, * service_application, * label; // manifest if (nullptr == (manifest = tree->GetRootElement())) { @@ -130,21 +130,26 @@ bool StepParse::SetContextByManifestParser(XmlTree* tree) { "' package='" << manifest->attr("package") << "' versionr='" << manifest->attr("version") << "'"; - // ui_application - if (nullptr == (ui_application = Get1stChild(tree, - manifest, "ui-application"))) { - LOG(ERROR) << "No mandatory ui-application element in manifest xml"; + // At least one of ui_application or service_application must be given + ui_application = Get1stChild(tree, manifest, "ui-application"); + service_application = Get1stChild(tree, manifest, "service-application"); + if (nullptr == ui_application && nullptr == service_application) { + LOG(ERROR) << "Neither nor " << + " element is found in manifest xml"; return false; } - if (nullptr == (label = Get1stChild(tree, ui_application, "label"))) { - LOG(ERROR) << "No mandatory label element in manifest xml"; + // label must be given + label = ui_application ? Get1stChild(tree, ui_application, "label") : + Get1stChild(tree, service_application, "label"); + if (nullptr == label) { + LOG(ERROR) << "No mandatory