From 879048abb2f7c3c643905d13908703850fe368e0 Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Wed, 24 Feb 2016 09:33:50 +0100 Subject: [PATCH] Processing watch application from config.xml Writes information about wgt's watch application to manifest_x and adds it to generated platform xml in wgt-backend. In tizen 2.x watch-application was not registered by wgt-installer AT ALL. This was done libwatch-application.so pkgmgr plugin parser. This behaviour should be probably removed so that only app-installer insert data into pkgmgr database. After this commit data of all applications (including watch-application) is added to pkgmgr_parser.db. Note that update installation of watch-application will work only when tizen-manifest.xml parsing changes will be introduced. Requires: - https://review.tizen.org/gerrit/#/c/60241/ Change-Id: I67f9cf1c04ecf435cfc90f5ab83d2ccebbc45a4a --- src/wgt/step/step_generate_xml.cc | 13 +++++++++++++ src/wgt/step/step_generate_xml.h | 3 ++- src/wgt/step/step_parse.cc | 31 +++++++++++++++++++++++++++---- src/wgt/step/step_parse.h | 2 +- 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/wgt/step/step_generate_xml.cc b/src/wgt/step/step_generate_xml.cc index 71d956f..176c908 100644 --- a/src/wgt/step/step_generate_xml.cc +++ b/src/wgt/step/step_generate_xml.cc @@ -87,6 +87,13 @@ void WriteWidgetApplicationAttributes( BAD_CAST app->multiple); } +void WriteWatchApplicationAttributes( + xmlTextWriterPtr writer, application_x *app) { + if (app->ambient_support) + xmlTextWriterWriteAttribute(writer, BAD_CAST "ambient-support", + BAD_CAST app->ambient_support); +} + } // namespace namespace wgt { @@ -120,6 +127,9 @@ common_installer::Step::Status StepGenerateXml::GenerateApplicationCommonXml( case AppCompType::WIDGETAPP: WriteWidgetApplicationAttributes(writer, app); break; + case AppCompType::WATCHAPP: + WriteWatchApplicationAttributes(writer, app); + break; } for (label_x* label : GListRange(app->label)) { @@ -338,6 +348,9 @@ common_installer::Step::Status StepGenerateXml::process() { } else if (strcmp(app->component_type, "widgetapp") == 0) { type = AppCompType::WIDGETAPP; xmlTextWriterStartElement(writer, BAD_CAST "widget-application"); + } else if (strcmp(app->component_type, "watchapp") == 0) { + type = AppCompType::WATCHAPP; + xmlTextWriterStartElement(writer, BAD_CAST "watch-application"); } else { LOG(ERROR) << "Unknown application component_type"; xmlFreeTextWriter(writer); diff --git a/src/wgt/step/step_generate_xml.h b/src/wgt/step/step_generate_xml.h index 5351991..0f62498 100644 --- a/src/wgt/step/step_generate_xml.h +++ b/src/wgt/step/step_generate_xml.h @@ -29,7 +29,8 @@ class StepGenerateXml : public common_installer::Step { enum class AppCompType { UIAPP, SVCAPP, - WIDGETAPP + WIDGETAPP, + WATCHAPP }; Step::Status GenerateApplicationCommonXml(application_x* app, diff --git a/src/wgt/step/step_parse.cc b/src/wgt/step/step_parse.cc index cb77e28..935b303 100644 --- a/src/wgt/step/step_parse.cc +++ b/src/wgt/step/step_parse.cc @@ -43,6 +43,10 @@ namespace bf = boost::filesystem; namespace { +const char kCategoryWearableClock[] = + "http://tizen.org/category/wearable_clock"; +const char kCategoryWatchClock[] = "com.samsung.wmanager.WATCH_CLOCK"; + const std::string kManifestVersion = "1.0.0"; const char kTizenPackageXmlNamespace[] = "http://tizen.org/ns/packages"; @@ -60,7 +64,6 @@ GList* GenerateMetadataListX(const wgt::parse::MetaDataInfo& meta_info) { } void SetApplicationXDefaults(application_x* application) { - application->ambient_support = strdup("false"); application->effectimage_type = strdup("image"); application->enabled = strdup("true"); application->guestmode_visibility = strdup("true"); @@ -234,7 +237,7 @@ bool StepParse::FillWidgetInfo(manifest_x* manifest) { return true; } -bool StepParse::FillUIApplicationInfo(manifest_x* manifest) { +bool StepParse::FillMainApplicationInfo(manifest_x* manifest) { std::shared_ptr app_info = std::static_pointer_cast( parser_->GetManifestData(app_keys::kTizenApplicationKey)); @@ -242,15 +245,34 @@ bool StepParse::FillUIApplicationInfo(manifest_x* manifest) { LOG(ERROR) << "Application info manifest data has not been found."; return false; } + bool has_watch_catergory = false; + std::shared_ptr category_info = + std::static_pointer_cast(parser_->GetManifestData( + app_keys::kTizenCategoryKey)); + if (category_info) { + has_watch_catergory = std::find_if(category_info->categories.begin(), + category_info->categories.end(), + [](const std::string& category) { + return category == kCategoryWearableClock || + category == kCategoryWatchClock; + }) != category_info->categories.end(); + } + // application data application_x* application = reinterpret_cast( calloc(1, sizeof(application_x))); - application->component_type = strdup("uiapp"); + application->component_type = + has_watch_catergory ? strdup("watchapp") : strdup("uiapp"); application->mainapp = strdup("true"); application->nodisplay = strdup("false"); application->multiple = strdup("false"); application->appid = strdup(app_info->id().c_str()); SetApplicationXDefaults(application); + if (has_watch_catergory) + application->ambient_support = + strdup(app_info->ambient_support() ? "true" : "false"); + else + application->ambient_support = strdup("false"); application->package = strdup(app_info->package().c_str()); application->exec = @@ -298,6 +320,7 @@ bool StepParse::FillServiceApplicationInfo(manifest_x* manifest) { application->autorestart = service_info.auto_restart() ? strdup("true") : strdup("false"); SetApplicationXDefaults(application); + application->ambient_support = strdup("false"); application->package = strdup(manifest->package); for (auto& pair : service_info.names()) { @@ -449,7 +472,7 @@ bool StepParse::FillExtraManifestInfo(manifest_x* manifest) { bool StepParse::FillManifestX(manifest_x* manifest) { if (!FillIconPaths(manifest)) return false; - if (!FillUIApplicationInfo(manifest)) + if (!FillMainApplicationInfo(manifest)) return false; if (!FillWidgetInfo(manifest)) return false; diff --git a/src/wgt/step/step_parse.h b/src/wgt/step/step_parse.h index 06956b0..dc723cb 100644 --- a/src/wgt/step/step_parse.h +++ b/src/wgt/step/step_parse.h @@ -50,7 +50,7 @@ class StepParse : public common_installer::Step { bool FillInstallationInfo(manifest_x* manifest); bool FillIconPaths(manifest_x* manifest); bool FillWidgetInfo(manifest_x* manifest); - bool FillUIApplicationInfo(manifest_x* manifest); + bool FillMainApplicationInfo(manifest_x* manifest); bool FillServiceApplicationInfo(manifest_x* manifest); bool FillAppControl(manifest_x* manifest); bool FillPrivileges(manifest_x* manifest); -- 2.7.4