1 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache 2.0 license that can be
3 // found in the LICENSE file.
5 #include "common/step/configuration/step_parse_manifest.h"
7 #include <boost/tokenizer.hpp>
9 #include <pkgmgr/pkgmgr_parser.h>
10 #include <pkgmgr-info.h>
12 #include <tpk_manifest_handlers/appdefined_privilege_handler.h>
13 #include <tpk_manifest_handlers/application_manifest_constants.h>
14 #include <tpk_manifest_handlers/author_handler.h>
15 #include <tpk_manifest_handlers/component_based_application_handler.h>
16 #include <tpk_manifest_handlers/dependencies_handler.h>
17 #include <tpk_manifest_handlers/description_handler.h>
18 #include <tpk_manifest_handlers/feature_handler.h>
19 #include <tpk_manifest_handlers/light_user_handler.h>
20 #include <tpk_manifest_handlers/package_handler.h>
21 #include <tpk_manifest_handlers/privileges_handler.h>
22 #include <tpk_manifest_handlers/profile_handler.h>
23 #include <tpk_manifest_handlers/provides_appdefined_privileges_handler.h>
24 #include <tpk_manifest_handlers/service_application_handler.h>
25 #include <tpk_manifest_handlers/shortcut_handler.h>
26 #include <tpk_manifest_handlers/trust_anchor_handler.h>
27 #include <tpk_manifest_handlers/ui_application_handler.h>
28 #include <tpk_manifest_handlers/watch_application_handler.h>
29 #include <tpk_manifest_handlers/widget_application_handler.h>
36 #include <type_traits>
40 #include "common/feature_validator.h"
41 #include "common/installer_context.h"
42 #include "common/utils/paths.h"
43 #include "common/privileges.h"
44 #include "common/pkgmgr_registration.h"
45 #include "common/utils/pkgmgr_query.h"
46 #include "common/step/step.h"
47 #include "common/utils/glist_range.h"
48 #include "common/utils/time_util.h"
50 namespace app_keys = tpk::application_keys;
51 namespace bf = boost::filesystem;
55 const char kManifestFileName[] = "tizen-manifest.xml";
56 const char kInstalledInternally[] = "installed_internal";
57 const char kInstalledExternally[] = "installed_external";
58 const char kPortraitOrientation[] = "portrait";
59 const char kLandscapeOrientation[] = "landscape";
60 const char kOperationEffectKey[] = "operation_effect";
61 const char kLaunchEffectKey[] = "launch_effect";
62 const char kPortraitEffectImageValue[] = "portrait-effectimage";
63 const char kLandscapeEffectImageValue[] = "landscape-effectimage";
64 const char kIndicatorDisplayValue[] = "indicatordisplay";
68 namespace common_installer {
69 namespace configuration {
71 StepParseManifest::StepParseManifest(
72 InstallerContext* context, ManifestLocation manifest_location,
73 StoreLocation store_location)
75 manifest_location_(manifest_location),
76 store_location_(store_location) {
79 Step::Status StepParseManifest::precheck() {
80 switch (manifest_location_) {
81 case ManifestLocation::RECOVERY:
82 if (context_->pkgid.get().empty())
83 return Status::RECOVERY_DONE;
85 case ManifestLocation::INSTALLED:
86 if (context_->pkgid.get().empty()) {
87 LOG(ERROR) << "Package id is not set";
88 return Status::INVALID_VALUE;
91 case ManifestLocation::PACKAGE:
92 if (context_->unpacked_dir_path.get().empty()) {
93 LOG(ERROR) << "Unpacked directory doesn't exist";
94 return Status::INVALID_VALUE;
98 LOG(ERROR) << "Unknown manifest location";
99 return Status::INVALID_VALUE;
104 bool StepParseManifest::LocateConfigFile() {
105 boost::filesystem::path manifest;
106 switch (manifest_location_) {
107 case ManifestLocation::RECOVERY: {
108 bf::path backup_path = common_installer::GetBackupPathForPackagePath(
109 context_->GetPkgPath()) / kManifestFileName;
110 bf::path in_package_path = context_->GetPkgPath() / kManifestFileName;
111 bf::path install_path =
112 bf::path(getUserManifestPath(context_->uid.get(),
113 context_->is_readonly_package.get()))
114 / bf::path(context_->pkgid.get());
115 install_path += ".xml";
116 bf::path backup_install_path =
117 common_installer::GetBackupPathForManifestFile(install_path);
118 if (bf::exists(backup_install_path))
119 manifest = backup_install_path;
120 else if (bf::exists(backup_path))
121 manifest = backup_path;
122 else if (bf::exists(install_path))
123 manifest = install_path;
124 else if (bf::exists(in_package_path))
125 manifest = in_package_path;
128 case ManifestLocation::INSTALLED: {
130 bool is_readonly = context_->is_readonly_package.get();
131 PkgQueryInterface pkg_query(context_->pkgid.get(), context_->uid.get());
132 if (pkg_query.IsGlobalPackage())
133 uid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
135 uid = context_->uid.get();
137 bf::path(getUserManifestPath(uid, is_readonly))
138 / bf::path(context_->pkgid.get());
140 context_->xml_path.set(xml_path);
141 manifest = context_->xml_path.get();
142 if (!boost::filesystem::exists(manifest)) {
143 /* This routine has added for platform update */
144 manifest = context_->unpacked_dir_path.get();
145 manifest /= kManifestFileName;
149 case ManifestLocation::PACKAGE: {
150 manifest = context_->unpacked_dir_path.get();
151 manifest /= kManifestFileName;
155 LOG(ERROR) << "Unknown manifest location value";
160 LOG(DEBUG) << "manifest path: " << manifest;
162 if (!boost::filesystem::exists(manifest))
169 int StepParseManifest::GetSupportModeVal(std::string support_mode) {
171 std::size_t found = std::string::npos;
173 found = support_mode.find(APP_SUPPORT_MODE_ULTRA_POWER_SAVING_STR);
174 if (found != std::string::npos)
175 mode |= APP_SUPPORT_MODE_ULTRA_POWER_SAVING_VAL;
177 found = support_mode.find(APP_SUPPORT_MODE_COOL_DOWN_STR);
178 if (found != std::string::npos)
179 mode |= APP_SUPPORT_MODE_COOL_DOWN_VAL;
181 found = support_mode.find(APP_SUPPORT_MODE_SCREEN_READER_STR);
182 if (found != std::string::npos)
183 mode |= APP_SUPPORT_MODE_SCREEN_READER_VAL;
188 bool StepParseManifest::FillInstallationInfo(manifest_x* manifest) {
189 manifest->root_path = strdup(
190 (context_->root_application_path.get() / manifest->package).c_str());
191 manifest->installed_time = strdup(GetCurrentTime().c_str());
195 bool StepParseManifest::FillPackageInfo(manifest_x* manifest) {
196 std::shared_ptr<const tpk::parse::PackageInfo> pkg_info =
197 std::static_pointer_cast<const tpk::parse::PackageInfo>(
198 parser_->GetManifestData(app_keys::kManifestKey));
200 LOG(ERROR) << "Package info manifest data has not been found.";
204 int support_mode_val = GetSupportModeVal(pkg_info->support_mode());
206 manifest->ns = strdup(pkg_info->xmlns().c_str());
207 manifest->package = strdup(pkg_info->package().c_str());
208 manifest->nodisplay_setting = strdup(pkg_info->nodisplay_setting().c_str());
209 manifest->support_mode = strdup((std::to_string(support_mode_val)).c_str());
210 manifest->appsetting = strdup("false");
211 manifest->support_disable = strdup(pkg_info->support_disable().c_str());
212 manifest->version = strdup(pkg_info->version().c_str());
213 manifest->installlocation = strdup(pkg_info->install_location().c_str());
214 manifest->api_version = strdup(pkg_info->api_version().c_str());
215 manifest->readonly = strdup(pkg_info->readonly().c_str());
216 manifest->preload = strdup(pkg_info->preload().c_str());
217 manifest->removable = strdup(pkg_info->removable().c_str());
219 common_installer::RequestType req_type = context_->request_type.get();
220 if (pkg_info->type().empty()) {
221 if ((req_type == RequestType::ManifestDirectInstall ||
222 req_type == RequestType::ManifestDirectUpdate) &&
223 context_->is_readonly_package.get())
224 manifest->type = strdup("rpm");
226 manifest->type = strdup("tpk");
228 manifest->type = strdup(pkg_info->type().c_str());
231 for (auto& pair : pkg_info->labels()) {
232 label_x* label = reinterpret_cast<label_x*>(calloc(1, sizeof(label_x)));
234 LOG(ERROR) << "Out of memory";
237 if (!pair.first.empty())
238 label->lang = strdup(pair.first.c_str());
240 label->lang = strdup(DEFAULT_LOCALE);
241 label->text = strdup(pair.second.c_str());
242 manifest->label = g_list_append(manifest->label, label);
245 std::shared_ptr<const tpk::parse::ProfileInfo> profile_info =
246 std::static_pointer_cast<const tpk::parse::ProfileInfo>(
247 parser_->GetManifestData(tpk::parse::ProfileInfo::Key()));
249 for (auto& profile : profile_info->profiles()) {
250 manifest->deviceprofile = g_list_append(manifest->deviceprofile,
251 strdup(profile.c_str()));
255 // set installed_storage if package is installed
256 // this is internal field in package manager but after reading configuration
258 PkgQueryInterface pkg_query(manifest->package, context_->uid.get());
259 if (!manifest->installed_storage) {
260 if (manifest_location_ == ManifestLocation::INSTALLED ||
261 manifest_location_ == ManifestLocation::RECOVERY) {
262 std::string storage = pkg_query.StorageForPkgId();
263 if (storage.empty()) {
264 // Failed to query installation storage, assign internal
265 manifest->installed_storage = strdup(kInstalledInternally);
267 manifest->installed_storage = strdup(storage.c_str());
270 manifest->installed_storage = strdup(kInstalledInternally);
274 // retrieve and set plugin execution info if exists
275 if (manifest_location_ == ManifestLocation::INSTALLED ||
276 manifest_location_ == ManifestLocation::RECOVERY) {
277 std::vector<PkgQueryInterface::PluginInfo> plugin_list;
278 pkg_query.PluginExecutionInfo(&plugin_list);
280 for (const auto& plugin_info : plugin_list) {
282 reinterpret_cast<plugin_x*>(calloc(1, sizeof(plugin_x)));
284 LOG(ERROR) << "Out of memory";
288 plugin->pkgid = strdup(manifest->package);
289 plugin->appid = strdup(std::get<1>(plugin_info).c_str());
290 plugin->plugin_type = strdup(std::get<2>(plugin_info).c_str());
291 plugin->plugin_name = strdup(std::get<3>(plugin_info).c_str());
292 manifest->plugin = g_list_append(manifest->plugin, plugin);
298 bool StepParseManifest::FillAuthorInfo(manifest_x* manifest) {
299 std::shared_ptr<const tpk::parse::AuthorInfo> author_info =
300 std::static_pointer_cast<const tpk::parse::AuthorInfo>(
301 parser_->GetManifestData(tpk::parse::AuthorInfo::Key()));
306 author_x* author = reinterpret_cast<author_x*>(calloc(1, sizeof(author_x)));
308 LOG(ERROR) << "Out of memory";
311 author->text = strdup(author_info->name().c_str());
312 author->email = strdup(author_info->email().c_str());
313 author->href = strdup(author_info->href().c_str());
314 author->lang = strdup(DEFAULT_LOCALE);
315 manifest->author = g_list_append(manifest->author, author);
319 bool StepParseManifest::FillDescriptionInfo(manifest_x* manifest) {
320 std::shared_ptr<const tpk::parse::DescriptionInfoList> description_info =
321 std::static_pointer_cast<const tpk::parse::DescriptionInfoList>(
322 parser_->GetManifestData(tpk::parse::DescriptionInfoList::Key()));
324 if (!description_info)
327 for (auto& desc : description_info->descriptions) {
328 description_x* description = reinterpret_cast<description_x*>
329 (calloc(1, sizeof(description_x)));
331 LOG(ERROR) << "Out of memory";
334 description->text = strdup(desc.description().c_str());
335 description->lang = !desc.xml_lang().empty() ?
336 strdup(desc.xml_lang().c_str()) : strdup(DEFAULT_LOCALE);
337 manifest->description = g_list_append(manifest->description, description);
342 bool StepParseManifest::FillPrivileges(manifest_x* manifest) {
343 std::shared_ptr<const tpk::parse::PrivilegesInfo> perm_info =
344 std::static_pointer_cast<const tpk::parse::PrivilegesInfo>(
345 parser_->GetManifestData(app_keys::kPrivilegesKey));
349 const auto& privileges = perm_info->GetPrivileges();
350 for (auto& priv : privileges) {
351 privilege_x* privilege =
352 reinterpret_cast<privilege_x*>(calloc(1, sizeof(privilege_x)));
354 LOG(ERROR) << "Out of memory";
357 privilege->value = strdup(priv.first.c_str());
358 privilege->type = strdup(priv.second.c_str());
359 manifest->privileges = g_list_append(manifest->privileges, privilege);
362 const auto& appdef_privileges_list =
363 perm_info->GetAppDefinedPrivilegeInfoList();
364 for (auto& appdef_info : appdef_privileges_list) {
365 appdefined_privilege_x* privilege =
366 reinterpret_cast<appdefined_privilege_x*>(calloc(1,
367 sizeof(appdefined_privilege_x)));
368 if (privilege == nullptr) {
369 LOG(ERROR) << "Memory alloc failure";
372 auto& priv = appdef_info.GetAppDefinedPrivilege();
373 privilege->value = strdup(priv.privilege.c_str());
374 privilege->type = strdup(priv.type.c_str());
375 if (!priv.license.empty()) {
376 if (bf::path(priv.license).is_absolute())
377 privilege->license = strdup(priv.license.c_str());
379 privilege->license = strdup((context_->GetPkgPath()
380 / priv.license).c_str());
382 manifest->appdefined_privileges =
383 g_list_append(manifest->appdefined_privileges, privilege);
389 bool StepParseManifest::FillProvidesAppDefinedPrivileges(
390 manifest_x* manifest) {
391 std::shared_ptr<const tpk::parse::ProvidesAppDefinedPrivilegesInfo>
392 priv_info = std::static_pointer_cast<
393 const tpk::parse::ProvidesAppDefinedPrivilegesInfo>(
394 parser_->GetManifestData(
395 app_keys::kProvidesAppDefinedPrivilegesKey));
399 const auto& privileges_list = priv_info->GetAppDefinedPrivilegeInfoList();
400 for (auto& appdef_info : privileges_list) {
401 appdefined_privilege_x* privilege =
402 reinterpret_cast<appdefined_privilege_x*>(calloc(1,
403 sizeof(appdefined_privilege_x)));
404 if (privilege == nullptr) {
405 LOG(ERROR) << "Memory alloc failure";
408 auto& priv = appdef_info.GetAppDefinedPrivilege();
409 privilege->value = strdup(priv.privilege.c_str());
410 privilege->type = strdup(priv.type.c_str());
411 if (!priv.license.empty()) {
412 if (bf::path(priv.license).is_absolute())
413 privilege->license = strdup(priv.license.c_str());
415 privilege->license = strdup((context_->GetPkgPath()
416 / priv.license).c_str());
418 manifest->provides_appdefined_privileges =
419 g_list_append(manifest->provides_appdefined_privileges, privilege);
425 bool StepParseManifest::FillWidgetApplication(manifest_x* manifest) {
426 auto widget_application_list =
427 std::static_pointer_cast<const tpk::parse::WidgetApplicationInfoList>(
428 parser_->GetManifestData(app_keys::kWidgetApplicationKey));
429 if (!widget_application_list)
432 for (const auto& application : widget_application_list->items) {
433 int package_support_mode_val = atoi(manifest->support_mode);
434 int app_support_mode_val = package_support_mode_val |
435 GetSupportModeVal(application.app_info.support_mode());
437 application_x* widget_app =
438 static_cast<application_x*>(calloc(1, sizeof(application_x)));
440 LOG(ERROR) << "Out of memory";
443 widget_app->appid = strdup(application.app_info.appid().c_str());
444 widget_app->launch_mode =
445 strdup(application.app_info.launch_mode().c_str());
446 widget_app->multiple = strdup("false");
447 widget_app->nodisplay = strdup(application.app_info.nodisplay().c_str());
448 widget_app->support_mode =
449 strdup((std::to_string(app_support_mode_val)).c_str());
450 widget_app->taskmanage = strdup("false");
451 widget_app->indicatordisplay = strdup("false");
452 if (!application.app_info.type().empty())
453 widget_app->type = strdup(application.app_info.type().c_str());
455 widget_app->type = strdup("capp");
456 widget_app->component_type = strdup("widgetapp");
457 widget_app->hwacceleration =
458 strdup(application.app_info.hwacceleration().c_str());
459 widget_app->onboot = strdup("false");
460 widget_app->autorestart = strdup("false");
461 widget_app->mainapp = strdup(application.app_info.mainapp().c_str());
462 widget_app->screenreader = strdup("use-system-setting");
463 widget_app->recentimage = strdup("false");
464 widget_app->launchcondition = strdup("false");
465 widget_app->guestmode_visibility = strdup("true");
466 widget_app->permission_type = strdup("normal");
467 widget_app->support_ambient = strdup("false");
468 widget_app->effectimage_type = strdup("image");
469 widget_app->submode = strdup("false");
470 widget_app->process_pool = strdup("false");
471 widget_app->package = strdup(manifest->package);
472 widget_app->support_disable = strdup(manifest->support_disable);
473 widget_app->launch_mode = strdup("single");
474 if (!application.app_info.api_version().empty())
475 widget_app->api_version =
476 strdup(application.app_info.api_version().c_str());
478 widget_app->api_version = strdup(manifest->api_version);
479 manifest->application = g_list_append(manifest->application, widget_app);
480 if (bf::path(application.app_info.exec().c_str()).is_absolute())
481 widget_app->exec = strdup(application.app_info.exec().c_str());
483 widget_app->exec = strdup((context_->root_application_path.get()
484 / manifest->package / "bin"
485 / application.app_info.exec()).c_str());
487 if (!FillApplicationIconPaths(widget_app, application.app_icons))
489 if (!FillLabel(widget_app, application.label))
491 if (!FillImage(widget_app, application.app_images))
493 if (!FillCategories(widget_app, application.categories))
495 if (!FillMetadata(widget_app, application.meta_data))
497 if (!FillResControl(widget_app, application.res_controls))
503 bool StepParseManifest::FillServiceApplication(manifest_x* manifest) {
504 auto service_application_list =
505 std::static_pointer_cast<const tpk::parse::ServiceApplicationInfoList>(
506 parser_->GetManifestData(app_keys::kServiceApplicationKey));
507 if (!service_application_list)
510 for (const auto& application : service_application_list->items) {
511 int package_support_mode_val = atoi(manifest->support_mode);
512 int app_support_mode_val = package_support_mode_val |
513 GetSupportModeVal(application.app_info.support_mode());
515 application_x* service_app =
516 static_cast<application_x*>(calloc(1, sizeof(application_x)));
518 LOG(ERROR) << "Out of memory";
521 service_app->appid = strdup(application.app_info.appid().c_str());
522 service_app->multiple = strdup(application.app_info.multiple().c_str());
523 service_app->taskmanage = strdup(application.app_info.taskmanage().c_str());
524 service_app->support_mode =
525 strdup((std::to_string(app_support_mode_val)).c_str());
526 service_app->autorestart =
527 strdup(application.app_info.auto_restart().c_str());
528 service_app->onboot = strdup(application.app_info.on_boot().c_str());
529 if (!application.app_info.type().empty())
530 service_app->type = strdup(application.app_info.type().c_str());
532 service_app->type = strdup("capp");
533 service_app->component_type = strdup("svcapp");
534 service_app->mainapp = strdup(application.app_info.mainapp().c_str());
535 service_app->nodisplay = strdup("true");
536 service_app->hwacceleration = strdup("default");
537 service_app->screenreader = strdup("use-system-setting");
538 service_app->recentimage = strdup("false");
539 service_app->launchcondition = strdup("false");
540 service_app->indicatordisplay = strdup("true");
541 service_app->effectimage_type = strdup("image");
542 service_app->guestmode_visibility = strdup("true");
543 service_app->permission_type = strdup("normal");
544 service_app->submode = strdup("false");
545 service_app->process_pool = strdup("false");
546 service_app->support_ambient = strdup("false");
547 service_app->package = strdup(manifest->package);
548 service_app->support_disable = strdup(manifest->support_disable);
549 service_app->launch_mode = strdup("single");
550 if (!application.app_info.api_version().empty())
551 service_app->api_version =
552 strdup(application.app_info.api_version().c_str());
554 service_app->api_version = strdup(manifest->api_version);
555 manifest->application = g_list_append(manifest->application, service_app);
556 if (bf::path(application.app_info.exec().c_str()).is_absolute())
557 service_app->exec = strdup(application.app_info.exec().c_str());
559 service_app->exec = strdup((context_->root_application_path.get()
560 / manifest->package / "bin"
561 / application.app_info.exec()).c_str());
563 if (!FillAppControl(service_app, application.app_control))
565 if (!FillDataControl(service_app, application.data_control))
567 if (!FillApplicationIconPaths(service_app, application.app_icons))
569 if (!FillLabel(service_app, application.label))
571 if (!FillMetadata(service_app, application.meta_data))
573 if (!FillCategories(service_app, application.categories))
575 if (!FillBackgroundCategoryInfo(service_app,
576 application.background_category))
578 if (!FillResControl(service_app, application.res_controls))
584 bool StepParseManifest::FillUIApplication(manifest_x* manifest) {
585 std::shared_ptr<const tpk::parse::UIApplicationInfoList> ui_application_list =
586 std::static_pointer_cast<const tpk::parse::UIApplicationInfoList>(
587 parser_->GetManifestData(app_keys::kUIApplicationKey));
588 if (!ui_application_list)
591 for (const auto& application : ui_application_list->items) {
592 int package_support_mode_val = atoi(manifest->support_mode);
593 int app_support_mode_val = package_support_mode_val |
594 GetSupportModeVal(application.app_info.support_mode());
596 application_x* ui_app =
597 static_cast<application_x*>(calloc(1, sizeof(application_x)));
599 LOG(ERROR) << "Out of memory";
602 ui_app->appid = strdup(application.app_info.appid().c_str());
603 ui_app->launch_mode = strdup(application.app_info.launch_mode().c_str());
604 ui_app->multiple = strdup(application.app_info.multiple().c_str());
605 ui_app->nodisplay = strdup(application.app_info.nodisplay().c_str());
606 ui_app->support_mode =
607 strdup((std::to_string(app_support_mode_val)).c_str());
608 ui_app->taskmanage = strdup(application.app_info.taskmanage().c_str());
609 if (!application.app_info.type().empty())
610 ui_app->type = strdup(application.app_info.type().c_str());
612 ui_app->type = strdup("capp");
613 ui_app->ui_gadget = strdup(application.app_info.uigadget().c_str());
614 ui_app->process_pool = strdup(application.app_info.process_pool().c_str());
615 ui_app->submode = strdup(application.app_info.submode().c_str());
616 if (!application.app_info.indicator_display().empty())
617 ui_app->indicatordisplay =
618 strdup(application.app_info.indicator_display().c_str());
619 if (!application.app_info.effectimage_type().empty())
620 ui_app->effectimage_type =
621 strdup(application.app_info.effectimage_type().c_str());
622 if (!application.app_info.portrait_image().empty()) {
623 ui_app->portraitimg =
624 strdup(application.app_info.portrait_image().c_str());
625 AppendSplashScreen(ui_app, application.app_info.portrait_image(),
626 application.app_info.effectimage_type(), {}, kPortraitOrientation,
627 application.app_info.indicator_display(), {}, {});
629 if (!application.app_info.landscape_image().empty()) {
630 ui_app->landscapeimg =
631 strdup(application.app_info.landscape_image().c_str());
632 AppendSplashScreen(ui_app, application.app_info.landscape_image(),
633 application.app_info.effectimage_type(), {}, kLandscapeOrientation,
634 application.app_info.indicator_display(), {}, {});
636 ui_app->submode_mainid =
637 strdup(application.app_info.submode_mainid().c_str());
638 ui_app->hwacceleration =
639 strdup(application.app_info.hwacceleration().c_str());
640 ui_app->onboot = strdup("false");
641 ui_app->autorestart = strdup("false");
642 ui_app->component_type = strdup("uiapp");
643 ui_app->mainapp = strdup(application.app_info.mainapp().c_str());
644 ui_app->screenreader = strdup("use-system-setting");
645 ui_app->recentimage = strdup("false");
646 ui_app->launchcondition = strdup("false");
647 ui_app->guestmode_visibility = strdup("true");
648 ui_app->permission_type = strdup("normal");
649 ui_app->support_ambient = strdup("false");
650 ui_app->package = strdup(manifest->package);
651 ui_app->support_disable = strdup(manifest->support_disable);
652 ui_app->splash_screen_display =
653 strdup(application.app_info.splash_screen_display().c_str());
654 if (!application.app_info.api_version().empty())
655 ui_app->api_version = strdup(application.app_info.api_version().c_str());
657 ui_app->api_version = strdup(manifest->api_version);
658 manifest->application = g_list_append(manifest->application, ui_app);
659 if (bf::path(application.app_info.exec().c_str()).is_absolute())
660 ui_app->exec = strdup(application.app_info.exec().c_str());
662 ui_app->exec = strdup((context_->root_application_path.get()
663 / manifest->package / "bin"
664 / application.app_info.exec()).c_str());
667 if (!FillAppControl(ui_app, application.app_control))
669 if (!FillDataControl(ui_app, application.data_control))
671 if (!FillApplicationIconPaths(ui_app, application.app_icons))
673 if (!FillLabel(ui_app, application.label))
675 if (!FillImage(ui_app, application.app_images))
677 if (!FillMetadata(ui_app, application.meta_data))
679 if (!FillCategories(ui_app, application.categories))
681 if (!FillBackgroundCategoryInfo(ui_app, application.background_category))
683 if (!FillSplashScreen(ui_app, application.app_splashscreens))
685 if (!FillResControl(ui_app, application.res_controls))
691 bool StepParseManifest::FillWatchApplication(manifest_x* manifest) {
692 auto watch_application_list =
693 std::static_pointer_cast<const tpk::parse::WatchApplicationInfoList>(
694 parser_->GetManifestData(app_keys::kWatchApplicationKey));
695 if (!watch_application_list)
698 for (const auto& watch_application : watch_application_list->items) {
699 int package_support_mode_val = atoi(manifest->support_mode);
700 int app_support_mode_val = package_support_mode_val |
701 GetSupportModeVal(watch_application.app_info.support_mode());
703 application_x* watch_app =
704 static_cast<application_x*>(calloc(1, sizeof(application_x)));
706 LOG(ERROR) << "Out of memory";
709 watch_app->appid = strdup(watch_application.app_info.appid().c_str());
711 if (bf::path(watch_application.app_info.exec().c_str()).is_absolute())
712 watch_app->exec = strdup(watch_application.app_info.exec().c_str());
714 watch_app->exec = strdup(
715 (context_->root_application_path.get()
716 / manifest->package / "bin" /
717 watch_application.app_info.exec()).c_str());
718 watch_app->nodisplay = strdup("true");
719 watch_app->multiple = strdup("false");
720 if (!watch_application.app_info.type().empty())
721 watch_app->type = strdup(watch_application.app_info.type().c_str());
723 watch_app->type = strdup("capp");
724 watch_app->taskmanage = strdup("false");
725 watch_app->hwacceleration = strdup("default");
726 watch_app->screenreader = strdup("use-system-setting");
727 watch_app->mainapp = strdup(watch_application.app_info.mainapp().c_str());
728 watch_app->recentimage = strdup("false");
729 watch_app->launchcondition = strdup("false");
730 watch_app->indicatordisplay = strdup("true");
731 watch_app->effectimage_type = strdup("image");
732 watch_app->guestmode_visibility = strdup("true");
733 watch_app->permission_type = strdup("normal");
734 watch_app->component_type = strdup("watchapp");
735 watch_app->preload = strdup("false");
736 watch_app->submode = strdup("false");
737 watch_app->process_pool = strdup("false");
738 watch_app->autorestart = strdup("false");
739 watch_app->onboot = strdup("false");
740 watch_app->support_mode =
741 strdup((std::to_string(app_support_mode_val)).c_str());
742 watch_app->ui_gadget = strdup("false");
743 watch_app->launch_mode = strdup("single");
744 if (!watch_application.app_info.api_version().empty())
745 watch_app->api_version =
746 strdup(watch_application.app_info.api_version().c_str());
748 watch_app->api_version = strdup(manifest->api_version);
749 watch_app->support_ambient =
750 strdup(watch_application.app_info.ambient_support().c_str());
751 watch_app->package = strdup(manifest->package);
752 if (!watch_application.app_info.setup_appid().empty())
753 watch_app->setup_appid =
754 strdup(watch_application.app_info.setup_appid().c_str());
755 manifest->application = g_list_append(manifest->application, watch_app);
757 if (!FillLabel(watch_app, watch_application.label))
759 if (!FillApplicationIconPaths(watch_app, watch_application.app_icons))
761 if (!FillMetadata(watch_app, watch_application.meta_data))
763 if (!FillCategories(watch_app, watch_application.categories))
765 if (!FillBackgroundCategoryInfo(watch_app,
766 watch_application.background_category))
768 if (!FillResControl(watch_app, watch_application.res_controls))
774 bool StepParseManifest::FillTrustAnchorInfo(manifest_x* manifest) {
775 std::shared_ptr<const tpk::parse::TrustAnchorInfo> trust_anchor_info =
776 std::static_pointer_cast<const tpk::parse::TrustAnchorInfo>(
777 parser_->GetManifestData(app_keys::kTrustAnchorKey));
778 if (!trust_anchor_info)
781 if (trust_anchor_info->get_use_system_certs().empty()) {
782 LOG(ERROR) << "Invalid trust anchor data";
786 manifest->use_system_certs =
787 strdup(trust_anchor_info->get_use_system_certs().c_str());
792 bool StepParseManifest::FillDependencyInfo(manifest_x* manifest) {
793 std::shared_ptr<const tpk::parse::DependenciesInfo> dependencies_info =
794 std::static_pointer_cast<const tpk::parse::DependenciesInfo>(
795 parser_->GetManifestData(app_keys::kDependenciesKey));
796 if (!dependencies_info)
799 for (const auto& dependency : dependencies_info->dependencies()) {
801 static_cast<dependency_x*>(calloc(1, sizeof(dependency_x)));
803 LOG(ERROR) << "Out of memory";
806 dep->depends_on = strdup(dependency.pkgid().c_str());
807 dep->type = strdup(dependency.type().c_str());
808 if (!dependency.required_version().empty())
809 dep->required_version = strdup(dependency.required_version().c_str());
810 manifest->dependencies = g_list_append(manifest->dependencies, dep);
816 bool StepParseManifest::FillLightUserInfo(manifest_x* manifest) {
817 std::shared_ptr<const tpk::parse::LightUserInfo> light_user_info =
818 std::static_pointer_cast<const tpk::parse::LightUserInfo>(
819 parser_->GetManifestData(tpk::parse::LightUserInfo::Key()));
820 if (!light_user_info) {
821 manifest->light_user_switch_mode = strdup("default");
825 if (light_user_info->switch_mode().empty()) {
826 LOG(ERROR) << "Invalid switch mode";
830 manifest->light_user_switch_mode =
831 strdup(light_user_info->switch_mode().c_str());
836 bool StepParseManifest::CheckFeatures() {
838 std::static_pointer_cast<const tpk::parse::FeatureInfo>(
839 parser_->GetManifestData(tpk::parse::FeatureInfo::Key()));
844 FeatureValidator validator(feature_info->features());
845 if (!validator.Validate(&error)) {
846 LOG(ERROR) << "Feature validation error. " << error;
853 template <typename T>
854 bool StepParseManifest::FillAppControl(application_x* app,
855 const T& app_control_list) {
856 if (app_control_list.empty())
859 for (const auto& control : app_control_list) {
860 appcontrol_x* app_control =
861 static_cast<appcontrol_x*>(calloc(1, sizeof(appcontrol_x)));
863 LOG(ERROR) << "Out of memory";
866 app_control->operation = strdup(control.operation().c_str());
867 if (!control.mime().empty())
868 app_control->mime = strdup(control.mime().c_str());
869 if (!control.uri().empty())
870 app_control->uri = strdup(control.uri().c_str());
871 if (!control.visibility().empty())
872 app_control->visibility = strdup(control.visibility().c_str());
874 app_control->visibility = strdup("local-only");
875 if (!control.id().empty())
876 app_control->id = strdup(control.id().c_str());
878 app_control->id = strdup("no-name-app-control");
879 for (const auto& priv : control.privileges()) {
880 app_control->privileges = g_list_append(app_control->privileges,
881 strdup(priv.c_str()));
883 app->appcontrol = g_list_append(app->appcontrol, app_control);
888 template <typename T>
889 bool StepParseManifest::FillDataControl(application_x* app,
890 const T& data_control_list) {
891 if (data_control_list.empty())
894 for (const auto& control : data_control_list) {
895 datacontrol_x* data_control =
896 static_cast<datacontrol_x*>(calloc(1, sizeof(datacontrol_x)));
898 LOG(ERROR) << "Out of memory";
901 data_control->access = strdup(control.access().c_str());
902 data_control->providerid = strdup(control.providerid().c_str());
903 data_control->type = strdup(control.type().c_str());
904 if (!control.trusted().empty())
905 data_control->trusted = strdup(control.trusted().c_str());
907 data_control->trusted = strdup("false");
908 for (const auto& priv : control.privileges())
909 data_control->privileges = g_list_append(data_control->privileges,
910 strdup(priv.c_str()));
912 app->datacontrol = g_list_append(app->datacontrol, data_control);
917 template <typename T>
918 bool StepParseManifest::FillApplicationIconPaths(application_x* app,
919 const T& icons_info) {
920 for (auto& application_icon : icons_info.icons()) {
921 icon_x* icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
923 LOG(ERROR) << "Out of memory";
927 if (bf::path(application_icon.path()).is_absolute()) {
928 text = application_icon.path();
930 text = context_->root_application_path.get()
931 / context_->pkgid.get() / "shared" / "res" / application_icon.path();
933 // NOTE: name is an attribute, but the xml writer uses it as text.
934 // This must be fixed in whole app-installer modules, including wgt.
935 // Current implementation is just for compatibility.
936 icon->text = strdup(text.c_str());
937 if (application_icon.lang().empty())
938 icon->lang = strdup(DEFAULT_LOCALE);
940 icon->lang = strdup(application_icon.lang().c_str());
942 if (!application_icon.dpi().empty())
943 icon->dpi = strdup(application_icon.dpi().c_str());
944 app->icon = g_list_append(app->icon, icon);
949 template <typename T>
950 bool StepParseManifest::FillLabel(application_x* app, const T& label_list) {
951 if (label_list.empty())
954 for (const auto& control : label_list) {
956 static_cast<label_x*>(calloc(1, sizeof(label_x)));
958 LOG(ERROR) << "Out of memory";
961 // NOTE: name is an attribute, but the xml writer uses it as text.
962 // This must be fixed in whole app-installer modules, including wgt.
963 // Current implementation is just for compatibility.
964 label->text = strdup(control.text().c_str());
965 label->name = strdup(control.name().c_str());
966 label->lang = !control.xml_lang().empty() ?
967 strdup(control.xml_lang().c_str()) : strdup(DEFAULT_LOCALE);
968 app->label = g_list_append(app->label, label);
973 template <typename T>
974 bool StepParseManifest::FillMetadata(application_x* app,
975 const T& meta_data_list) {
976 if (meta_data_list.empty())
979 for (auto& meta : meta_data_list) {
980 metadata_x* metadata =
981 static_cast<metadata_x*>(calloc(1, sizeof(metadata_x)));
983 LOG(ERROR) << "Out of memory";
986 metadata->key = strdup(meta.key().c_str());
987 metadata->value = strdup(meta.val().c_str());
988 app->metadata = g_list_append(app->metadata, metadata);
990 GetLegacySplashScreenFromMetadata(app, meta.key(), meta.val());
995 template <typename T>
996 bool StepParseManifest::FillCategories(application_x* manifest,
997 const T& categories) {
998 for (auto& category : categories) {
999 manifest->category = g_list_append(manifest->category,
1000 strdup(category.c_str()));
1005 void StepParseManifest::AppendSplashScreen(application_x* app,
1006 const std::string& src, const std::string& type, const std::string& dpi,
1007 const std::string& orientation, const std::string& indicatordisplay,
1008 const std::string& operation, const std::string& color_depth) {
1009 splashscreen_x* splashscreen =
1010 static_cast<splashscreen_x*>(calloc(1, sizeof(splashscreen_x)));
1011 if (!splashscreen) {
1012 LOG(ERROR) << "Out of memory";
1015 if (bf::path(src).is_absolute()) {
1016 splashscreen->src = strdup(src.c_str());
1018 bf::path full_path = context_->GetPkgPath() / src;
1019 splashscreen->src = strdup(full_path.string().c_str());
1021 if (src.substr(src.find_last_of(".") + 1) == "edj")
1022 splashscreen->type = strdup("edj");
1023 else if (type == "edj")
1024 splashscreen->type = strdup("edj");
1026 splashscreen->type = strdup("img");
1028 splashscreen->dpi = strdup(dpi.c_str());
1029 splashscreen->orientation = strdup(orientation.c_str());
1030 if (!indicatordisplay.empty())
1031 splashscreen->indicatordisplay = strdup(indicatordisplay.c_str());
1033 splashscreen->indicatordisplay = strdup("true");
1034 if (operation == "launch_effect")
1035 splashscreen->operation = strdup("launch-effect");
1036 else if (!operation.empty())
1037 splashscreen->operation = strdup(operation.c_str());
1039 splashscreen->operation = strdup("launch-effect");
1040 if (!color_depth.empty())
1041 splashscreen->color_depth = strdup(color_depth.c_str());
1043 splashscreen->color_depth = strdup("24");
1044 app->splashscreens = g_list_append(app->splashscreens, splashscreen);
1047 template <typename T>
1048 bool StepParseManifest::FillSplashScreen(application_x* app,
1049 const T& splashscreens_info) {
1050 for (auto& splash_screen : splashscreens_info.splashscreens()) {
1052 if (context_->is_readonly_package.get())
1053 src = splash_screen.src();
1055 src = bf::path(context_->root_application_path.get()
1056 / app->package / "shared" / "res" / splash_screen.src()).string();
1058 AppendSplashScreen(app, src, splash_screen.type(), splash_screen.dpi(),
1059 splash_screen.orientation(), splash_screen.indicatordisplay(),
1060 splash_screen.operation(), splash_screen.colordepth());
1065 template <typename T>
1066 bool StepParseManifest::FillResControl(application_x* app,
1067 const T& res_control_list) {
1068 for (auto& res_control : res_control_list) {
1069 if (res_control.resource_type().empty())
1073 static_cast<res_control_x*>(calloc(1, sizeof(res_control_x)));
1075 LOG(ERROR) << "Out of memory";
1079 rc->res_type = strdup(res_control.resource_type().c_str());
1080 if (!res_control.min_res_version().empty())
1081 rc->min_res_version = strdup(res_control.min_res_version().c_str());
1082 if (!res_control.max_res_version().empty())
1083 rc->max_res_version = strdup(res_control.max_res_version().c_str());
1084 if (!res_control.auto_close().empty())
1085 rc->auto_close = strdup(res_control.auto_close().c_str());
1087 app->res_control = g_list_prepend(app->res_control, rc);
1092 void StepParseManifest::GetLegacySplashScreenFromMetadata(application_x* app,
1093 const std::string& key, const std::string& val) {
1094 std::string operation;
1095 if (key.find(kOperationEffectKey) != std::string::npos) {
1096 boost::char_separator<char> sep("=");
1097 boost::tokenizer<boost::char_separator<char>> tokens(key, sep);
1098 auto iter = tokens.begin();
1101 } else if (key.find(kLaunchEffectKey) != std::string::npos) {
1102 operation = std::string("launch-effect");
1104 // not a metadata splashscreen
1108 boost::char_separator<char> sep("=|");
1109 boost::tokenizer<boost::char_separator<char>> tokens(val, sep);
1110 auto iter = tokens.begin();
1111 std::string portrait_src;
1112 std::string landscape_src;
1113 std::string indicatordisplay;
1114 while (iter != tokens.end()) {
1115 if (!(*iter).compare(kPortraitEffectImageValue)) {
1117 portrait_src = *iter;
1118 } else if (!(*iter).compare(kLandscapeEffectImageValue)) {
1120 landscape_src = *iter;
1121 } else if (!(*iter).compare(kIndicatorDisplayValue)) {
1123 indicatordisplay = *iter;
1127 if (!portrait_src.empty())
1128 AppendSplashScreen(app, portrait_src, {}, {}, kPortraitOrientation,
1129 indicatordisplay, operation, {});
1130 if (!landscape_src.empty())
1131 AppendSplashScreen(app, landscape_src, {}, {}, kLandscapeOrientation,
1132 indicatordisplay, operation, {});
1135 bool StepParseManifest::FillImage(application_x* app,
1136 const tpk::parse::ApplicationImagesInfo& image_list) {
1137 for (auto& app_image : image_list.images) {
1139 static_cast<image_x*>(calloc(1, sizeof(image_x)));
1141 LOG(ERROR) << "Out of memory";
1144 const std::string& lang = app_image.lang();
1146 image->lang = strdup(lang.c_str());
1148 image->lang = strdup(DEFAULT_LOCALE);
1149 if (!app_image.section().empty())
1150 image->section = strdup(app_image.section().c_str());
1151 app->image = g_list_append(app->image, image);
1156 template <typename T>
1157 bool StepParseManifest::FillBackgroundCategoryInfo(application_x* app,
1158 const T& background_category_data_list) {
1159 for (const auto& background_category : background_category_data_list) {
1160 app->background_category = g_list_append(
1161 app->background_category, strdup(background_category.value().c_str()));
1167 bool StepParseManifest::FillExtraInfo(manifest_x* manifest) {
1168 if (manifest_location_ == ManifestLocation::INSTALLED) {
1169 // recovery of tep value for installed package
1170 PkgQueryInterface pkg_query(context_->pkgid.get(), context_->uid.get());
1171 std::string old_tep = pkg_query.TepPath();
1172 if (!old_tep.empty())
1173 manifest->tep_name = strdup(old_tep.c_str());
1175 // recovery of zip mount file for installed package
1176 std::string zip_mount_file = pkg_query.ZipMountFile();
1177 if (!zip_mount_file.empty())
1178 manifest->zip_mount_file = strdup(zip_mount_file.c_str());
1181 if (manifest->application == nullptr)
1184 // in case of hybrid package, main app is already set by wgt-backend
1185 application_x* mainapp = nullptr;
1186 if (!context_->cross_app_rules.get()) {
1188 for (const auto& app : GListRange<application_x*>(manifest->application)) {
1189 if (!strcmp(app->mainapp, "true")) {
1194 if (mainapp == nullptr)
1195 mainapp = reinterpret_cast<application_x*>(
1196 g_list_first(manifest->application)->data);
1197 free(mainapp->mainapp);
1198 mainapp->mainapp = strdup("true");
1199 manifest->mainapp_id = strdup(mainapp->appid);
1202 // mark mainapp=false at other apps
1203 for (auto& app : GListRange<application_x*>(manifest->application)) {
1207 app->mainapp = strdup("false");
1212 bool StepParseManifest::FillComponentBasedApplicationInfo(
1213 manifest_x* manifest) {
1214 std::shared_ptr<const tpk::parse::ComponentBasedApplicationInfoList>
1215 component_based_application_list = std::static_pointer_cast<
1216 const tpk::parse::ComponentBasedApplicationInfoList>(
1217 parser_->GetManifestData(
1218 app_keys::kComponentBasedApplicationKey));
1219 if (!component_based_application_list)
1222 for (const auto& application : component_based_application_list->items) {
1223 int package_support_mode_val = atoi(manifest->support_mode);
1224 int app_support_mode_val = package_support_mode_val |
1225 GetSupportModeVal(application.app_info.support_mode());
1227 application_x* app =
1228 static_cast<application_x*>(calloc(1, sizeof(application_x)));
1230 LOG(ERROR) << "Out of memory";
1234 app->appid = strdup(application.app_info.appid().c_str());
1235 app->launch_mode = strdup(application.app_info.launch_mode().c_str());
1236 app->multiple = strdup(application.app_info.multiple().c_str());
1237 app->nodisplay = strdup(application.app_info.nodisplay().c_str());
1238 app->support_mode = strdup((std::to_string(app_support_mode_val)).c_str());
1239 app->taskmanage = strdup(application.app_info.taskmanage().c_str());
1240 if (!application.app_info.type().empty())
1241 app->type = strdup(application.app_info.type().c_str());
1243 app->type = strdup("c++app");
1244 app->indicatordisplay =
1245 strdup(application.app_info.indicator_display().c_str());
1246 app->component_type = strdup("componentbasedapp");
1247 app->hwacceleration = strdup(application.app_info.hwacceleration().c_str());
1248 app->onboot = strdup("false");
1249 app->autorestart = strdup("false");
1250 app->mainapp = strdup(application.app_info.mainapp().c_str());
1251 app->screenreader = strdup("use-system-setting");
1252 app->recentimage = strdup("false");
1253 app->launchcondition = strdup("false");
1254 app->guestmode_visibility = strdup("true");
1255 app->permission_type = strdup("normal");
1256 app->support_ambient = strdup("false");
1257 app->effectimage_type = strdup("image");
1258 app->submode = strdup("false");
1259 app->process_pool = strdup("false");
1260 app->package = strdup(manifest->package);
1261 app->support_disable = strdup(manifest->support_disable);
1262 app->launch_mode = strdup("single");
1263 if (!application.app_info.api_version().empty())
1264 app->api_version = strdup(application.app_info.api_version().c_str());
1266 app->api_version = strdup(manifest->api_version);
1267 app->splash_screen_display =
1268 strdup(application.app_info.splash_screen_display().c_str());
1269 manifest->application = g_list_append(manifest->application, app);
1270 if (bf::path(application.app_info.exec().c_str()).is_absolute()) {
1271 app->exec = strdup(application.app_info.exec().c_str());
1273 app->exec = strdup((context_->root_application_path.get()
1274 / manifest->package / "bin"
1275 / application.app_info.exec()).c_str());
1277 if (!FillLabel(app, application.label))
1279 if (!FillImage(app, application.app_images))
1281 if (!FillBackgroundCategoryInfo(app, application.background_category))
1283 if (!FillAppControl(app, application.app_control))
1285 if (!FillDataControl(app, application.data_control))
1287 if (!FillMetadata(app, application.meta_data))
1289 if (!FillCategories(app, application.categories))
1291 if (!FillSplashScreen(app, application.app_splashscreens))
1293 if (!FillResControl(app, application.res_controls))
1300 bool StepParseManifest::FillManifestX(manifest_x* manifest) {
1301 if (!FillPackageInfo(manifest))
1303 if (!FillInstallationInfo(manifest))
1305 if (!FillUIApplication(manifest))
1307 if (!FillServiceApplication(manifest))
1309 if (!FillWidgetApplication(manifest))
1311 if (!FillWatchApplication(manifest))
1313 if (!FillComponentBasedApplicationInfo(manifest))
1315 if (!FillPrivileges(manifest))
1317 if (!FillProvidesAppDefinedPrivileges(manifest))
1319 if (!FillAuthorInfo(manifest))
1321 if (!FillDescriptionInfo(manifest))
1323 if (!FillExtraInfo(manifest))
1325 if (!FillTrustAnchorInfo(manifest))
1327 if (!FillDependencyInfo(manifest))
1329 if (!FillLightUserInfo(manifest))
1334 Step::Status StepParseManifest::process() {
1335 if (context_->force_clean_from_db.get())
1336 return Step::Status::OK;
1337 if (!LocateConfigFile()) {
1338 // continue if this is recovery, manifest file may never been created
1339 if (manifest_location_ == ManifestLocation::RECOVERY) {
1340 LOG(DEBUG) << "Manifest for recovery not found";
1341 return Step::Status::OK;
1343 LOG(ERROR) << "No manifest file exists";
1344 return Step::Status::MANIFEST_NOT_FOUND;
1346 parser_.reset(new tpk::parse::TPKConfigParser());
1347 if (!parser_->ParseManifest(path_)) {
1348 if (manifest_location_ == ManifestLocation::RECOVERY) {
1349 LOG(DEBUG) << "Manifest for recovery is invalid";
1351 return Step::Status::OK;
1353 LOG(ERROR) << "[Parse] Parse failed. " << parser_->GetErrorMessage();
1354 return Step::Status::PARSE_ERROR;
1357 // Copy data from ManifestData to InstallerContext
1358 std::shared_ptr<const tpk::parse::PackageInfo> info =
1359 std::static_pointer_cast<const tpk::parse::PackageInfo>(
1360 parser_->GetManifestData(app_keys::kManifestKey));
1362 context_->pkgid.set(info->package());
1364 manifest_x* manifest =
1365 static_cast<manifest_x*>(calloc(1, sizeof(manifest_x)));
1367 LOG(ERROR) << "Out of memory";
1368 return Step::Status::ERROR;
1371 if (!FillManifestX(const_cast<manifest_x*>(manifest))) {
1372 LOG(ERROR) << "[Parse] Storing manifest_x failed. "
1373 << parser_->GetErrorMessage();
1374 pkgmgr_parser_free_manifest_xml(manifest);
1375 return Step::Status::PARSE_ERROR;
1378 // write pkgid for recovery file
1379 if (context_->recovery_info.get().recovery_file) {
1380 context_->recovery_info.get().recovery_file->set_pkgid(manifest->package);
1381 context_->recovery_info.get().recovery_file->WriteAndCommitFileContent();
1384 LOG(INFO) << "Parsed package id: " << info->package();
1386 switch (store_location_) {
1387 case StoreLocation::NORMAL:
1388 context_->manifest_data.set(manifest);
1390 case StoreLocation::BACKUP:
1391 context_->old_manifest_data.set(manifest);
1394 LOG(ERROR) << "Unknown store location for parsed data";
1395 return Step::Status::ERROR;
1397 return Step::Status::OK;
1400 } // namespace configuration
1401 } // namespace common_installer