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 (store_location_ == StoreLocation::BACKUP && (
276 manifest_location_ == ManifestLocation::INSTALLED ||
277 manifest_location_ == ManifestLocation::RECOVERY)) {
278 std::vector<PkgQueryInterface::PluginInfo> plugin_list;
279 pkg_query.PluginExecutionInfo(&plugin_list);
281 for (const auto& plugin_info : plugin_list) {
283 reinterpret_cast<plugin_x*>(calloc(1, sizeof(plugin_x)));
285 LOG(ERROR) << "Out of memory";
289 plugin->pkgid = strdup(manifest->package);
290 plugin->appid = strdup(std::get<1>(plugin_info).c_str());
291 plugin->plugin_type = strdup(std::get<2>(plugin_info).c_str());
292 plugin->plugin_name = strdup(std::get<3>(plugin_info).c_str());
293 manifest->plugin = g_list_append(manifest->plugin, plugin);
299 bool StepParseManifest::FillAuthorInfo(manifest_x* manifest) {
300 std::shared_ptr<const tpk::parse::AuthorInfo> author_info =
301 std::static_pointer_cast<const tpk::parse::AuthorInfo>(
302 parser_->GetManifestData(tpk::parse::AuthorInfo::Key()));
307 author_x* author = reinterpret_cast<author_x*>(calloc(1, sizeof(author_x)));
309 LOG(ERROR) << "Out of memory";
312 author->text = strdup(author_info->name().c_str());
313 author->email = strdup(author_info->email().c_str());
314 author->href = strdup(author_info->href().c_str());
315 author->lang = strdup(DEFAULT_LOCALE);
316 manifest->author = g_list_append(manifest->author, author);
320 bool StepParseManifest::FillDescriptionInfo(manifest_x* manifest) {
321 std::shared_ptr<const tpk::parse::DescriptionInfoList> description_info =
322 std::static_pointer_cast<const tpk::parse::DescriptionInfoList>(
323 parser_->GetManifestData(tpk::parse::DescriptionInfoList::Key()));
325 if (!description_info)
328 for (auto& desc : description_info->descriptions) {
329 description_x* description = reinterpret_cast<description_x*>
330 (calloc(1, sizeof(description_x)));
332 LOG(ERROR) << "Out of memory";
335 description->text = strdup(desc.description().c_str());
336 description->lang = !desc.xml_lang().empty() ?
337 strdup(desc.xml_lang().c_str()) : strdup(DEFAULT_LOCALE);
338 manifest->description = g_list_append(manifest->description, description);
343 bool StepParseManifest::FillPrivileges(manifest_x* manifest) {
344 std::shared_ptr<const tpk::parse::PrivilegesInfo> perm_info =
345 std::static_pointer_cast<const tpk::parse::PrivilegesInfo>(
346 parser_->GetManifestData(app_keys::kPrivilegesKey));
350 const auto& privileges = perm_info->GetPrivileges();
351 for (auto& priv : privileges) {
352 privilege_x* privilege =
353 reinterpret_cast<privilege_x*>(calloc(1, sizeof(privilege_x)));
355 LOG(ERROR) << "Out of memory";
358 privilege->value = strdup(priv.first.c_str());
359 privilege->type = strdup(priv.second.c_str());
360 manifest->privileges = g_list_append(manifest->privileges, privilege);
363 const auto& appdef_privileges_list =
364 perm_info->GetAppDefinedPrivilegeInfoList();
365 for (auto& appdef_info : appdef_privileges_list) {
366 appdefined_privilege_x* privilege =
367 reinterpret_cast<appdefined_privilege_x*>(calloc(1,
368 sizeof(appdefined_privilege_x)));
369 if (privilege == nullptr) {
370 LOG(ERROR) << "Memory alloc failure";
373 auto& priv = appdef_info.GetAppDefinedPrivilege();
374 privilege->value = strdup(priv.privilege.c_str());
375 privilege->type = strdup(priv.type.c_str());
376 if (!priv.license.empty()) {
377 if (bf::path(priv.license).is_absolute())
378 privilege->license = strdup(priv.license.c_str());
380 privilege->license = strdup((context_->GetPkgPath()
381 / priv.license).c_str());
383 manifest->appdefined_privileges =
384 g_list_append(manifest->appdefined_privileges, privilege);
390 bool StepParseManifest::FillProvidesAppDefinedPrivileges(
391 manifest_x* manifest) {
392 std::shared_ptr<const tpk::parse::ProvidesAppDefinedPrivilegesInfo>
393 priv_info = std::static_pointer_cast<
394 const tpk::parse::ProvidesAppDefinedPrivilegesInfo>(
395 parser_->GetManifestData(
396 app_keys::kProvidesAppDefinedPrivilegesKey));
400 const auto& privileges_list = priv_info->GetAppDefinedPrivilegeInfoList();
401 for (auto& appdef_info : privileges_list) {
402 appdefined_privilege_x* privilege =
403 reinterpret_cast<appdefined_privilege_x*>(calloc(1,
404 sizeof(appdefined_privilege_x)));
405 if (privilege == nullptr) {
406 LOG(ERROR) << "Memory alloc failure";
409 auto& priv = appdef_info.GetAppDefinedPrivilege();
410 privilege->value = strdup(priv.privilege.c_str());
411 privilege->type = strdup(priv.type.c_str());
412 if (!priv.license.empty()) {
413 if (bf::path(priv.license).is_absolute())
414 privilege->license = strdup(priv.license.c_str());
416 privilege->license = strdup((context_->GetPkgPath()
417 / priv.license).c_str());
419 manifest->provides_appdefined_privileges =
420 g_list_append(manifest->provides_appdefined_privileges, privilege);
426 bool StepParseManifest::FillWidgetApplication(manifest_x* manifest) {
427 auto widget_application_list =
428 std::static_pointer_cast<const tpk::parse::WidgetApplicationInfoList>(
429 parser_->GetManifestData(app_keys::kWidgetApplicationKey));
430 if (!widget_application_list)
433 for (const auto& application : widget_application_list->items) {
434 int package_support_mode_val = atoi(manifest->support_mode);
435 int app_support_mode_val = package_support_mode_val |
436 GetSupportModeVal(application.app_info.support_mode());
438 application_x* widget_app =
439 static_cast<application_x*>(calloc(1, sizeof(application_x)));
441 LOG(ERROR) << "Out of memory";
444 widget_app->appid = strdup(application.app_info.appid().c_str());
445 widget_app->launch_mode =
446 strdup(application.app_info.launch_mode().c_str());
447 widget_app->multiple = strdup("false");
448 widget_app->nodisplay = strdup(application.app_info.nodisplay().c_str());
449 widget_app->support_mode =
450 strdup((std::to_string(app_support_mode_val)).c_str());
451 widget_app->taskmanage = strdup("false");
452 widget_app->indicatordisplay = strdup("false");
453 if (!application.app_info.type().empty())
454 widget_app->type = strdup(application.app_info.type().c_str());
456 widget_app->type = strdup("capp");
457 widget_app->component_type = strdup("widgetapp");
458 widget_app->hwacceleration =
459 strdup(application.app_info.hwacceleration().c_str());
460 widget_app->onboot = strdup("false");
461 widget_app->autorestart = strdup("false");
462 widget_app->mainapp = strdup(application.app_info.mainapp().c_str());
463 widget_app->screenreader = strdup("use-system-setting");
464 widget_app->recentimage = strdup("false");
465 widget_app->launchcondition = strdup("false");
466 widget_app->guestmode_visibility = strdup("true");
467 widget_app->permission_type = strdup("normal");
468 widget_app->support_ambient = strdup("false");
469 widget_app->effectimage_type = strdup("image");
470 widget_app->submode = strdup("false");
471 widget_app->process_pool = strdup("false");
472 widget_app->package = strdup(manifest->package);
473 widget_app->support_disable = strdup(manifest->support_disable);
474 widget_app->launch_mode = strdup("single");
475 if (!application.app_info.api_version().empty())
476 widget_app->api_version =
477 strdup(application.app_info.api_version().c_str());
479 widget_app->api_version = strdup(manifest->api_version);
480 manifest->application = g_list_append(manifest->application, widget_app);
481 if (bf::path(application.app_info.exec().c_str()).is_absolute())
482 widget_app->exec = strdup(application.app_info.exec().c_str());
484 widget_app->exec = strdup((context_->root_application_path.get()
485 / manifest->package / "bin"
486 / application.app_info.exec()).c_str());
488 if (!FillApplicationIconPaths(widget_app, application.app_icons))
490 if (!FillLabel(widget_app, application.label))
492 if (!FillImage(widget_app, application.app_images))
494 if (!FillCategories(widget_app, application.categories))
496 if (!FillMetadata(widget_app, application.meta_data))
498 if (!FillResControl(widget_app, application.res_controls))
504 bool StepParseManifest::FillServiceApplication(manifest_x* manifest) {
505 auto service_application_list =
506 std::static_pointer_cast<const tpk::parse::ServiceApplicationInfoList>(
507 parser_->GetManifestData(app_keys::kServiceApplicationKey));
508 if (!service_application_list)
511 for (const auto& application : service_application_list->items) {
512 int package_support_mode_val = atoi(manifest->support_mode);
513 int app_support_mode_val = package_support_mode_val |
514 GetSupportModeVal(application.app_info.support_mode());
516 application_x* service_app =
517 static_cast<application_x*>(calloc(1, sizeof(application_x)));
519 LOG(ERROR) << "Out of memory";
522 service_app->appid = strdup(application.app_info.appid().c_str());
523 service_app->multiple = strdup(application.app_info.multiple().c_str());
524 service_app->taskmanage = strdup(application.app_info.taskmanage().c_str());
525 service_app->support_mode =
526 strdup((std::to_string(app_support_mode_val)).c_str());
527 service_app->autorestart =
528 strdup(application.app_info.auto_restart().c_str());
529 service_app->onboot = strdup(application.app_info.on_boot().c_str());
530 if (!application.app_info.type().empty())
531 service_app->type = strdup(application.app_info.type().c_str());
533 service_app->type = strdup("capp");
534 service_app->component_type = strdup("svcapp");
535 service_app->mainapp = strdup(application.app_info.mainapp().c_str());
536 service_app->nodisplay = strdup("true");
537 service_app->hwacceleration = strdup("default");
538 service_app->screenreader = strdup("use-system-setting");
539 service_app->recentimage = strdup("false");
540 service_app->launchcondition = strdup("false");
541 service_app->indicatordisplay = strdup("true");
542 service_app->effectimage_type = strdup("image");
543 service_app->guestmode_visibility = strdup("true");
544 service_app->permission_type = strdup("normal");
545 service_app->submode = strdup("false");
546 service_app->process_pool = strdup("false");
547 service_app->support_ambient = strdup("false");
548 service_app->package = strdup(manifest->package);
549 service_app->support_disable = strdup(manifest->support_disable);
550 service_app->launch_mode = strdup("single");
551 if (!application.app_info.api_version().empty())
552 service_app->api_version =
553 strdup(application.app_info.api_version().c_str());
555 service_app->api_version = strdup(manifest->api_version);
556 manifest->application = g_list_append(manifest->application, service_app);
557 if (bf::path(application.app_info.exec().c_str()).is_absolute())
558 service_app->exec = strdup(application.app_info.exec().c_str());
560 service_app->exec = strdup((context_->root_application_path.get()
561 / manifest->package / "bin"
562 / application.app_info.exec()).c_str());
564 if (!FillAppControl(service_app, application.app_control))
566 if (!FillDataControl(service_app, application.data_control))
568 if (!FillApplicationIconPaths(service_app, application.app_icons))
570 if (!FillLabel(service_app, application.label))
572 if (!FillMetadata(service_app, application.meta_data))
574 if (!FillCategories(service_app, application.categories))
576 if (!FillBackgroundCategoryInfo(service_app,
577 application.background_category))
579 if (!FillResControl(service_app, application.res_controls))
585 bool StepParseManifest::FillUIApplication(manifest_x* manifest) {
586 std::shared_ptr<const tpk::parse::UIApplicationInfoList> ui_application_list =
587 std::static_pointer_cast<const tpk::parse::UIApplicationInfoList>(
588 parser_->GetManifestData(app_keys::kUIApplicationKey));
589 if (!ui_application_list)
592 for (const auto& application : ui_application_list->items) {
593 int package_support_mode_val = atoi(manifest->support_mode);
594 int app_support_mode_val = package_support_mode_val |
595 GetSupportModeVal(application.app_info.support_mode());
597 application_x* ui_app =
598 static_cast<application_x*>(calloc(1, sizeof(application_x)));
600 LOG(ERROR) << "Out of memory";
603 ui_app->appid = strdup(application.app_info.appid().c_str());
604 ui_app->launch_mode = strdup(application.app_info.launch_mode().c_str());
605 ui_app->multiple = strdup(application.app_info.multiple().c_str());
606 ui_app->nodisplay = strdup(application.app_info.nodisplay().c_str());
607 ui_app->support_mode =
608 strdup((std::to_string(app_support_mode_val)).c_str());
609 ui_app->taskmanage = strdup(application.app_info.taskmanage().c_str());
610 if (!application.app_info.type().empty())
611 ui_app->type = strdup(application.app_info.type().c_str());
613 ui_app->type = strdup("capp");
614 ui_app->ui_gadget = strdup(application.app_info.uigadget().c_str());
615 ui_app->process_pool = strdup(application.app_info.process_pool().c_str());
616 ui_app->submode = strdup(application.app_info.submode().c_str());
617 if (!application.app_info.indicator_display().empty())
618 ui_app->indicatordisplay =
619 strdup(application.app_info.indicator_display().c_str());
620 if (!application.app_info.effectimage_type().empty())
621 ui_app->effectimage_type =
622 strdup(application.app_info.effectimage_type().c_str());
623 if (!application.app_info.portrait_image().empty()) {
624 ui_app->portraitimg =
625 strdup(application.app_info.portrait_image().c_str());
626 AppendSplashScreen(ui_app, application.app_info.portrait_image(),
627 application.app_info.effectimage_type(), {}, kPortraitOrientation,
628 application.app_info.indicator_display(), {}, {});
630 if (!application.app_info.landscape_image().empty()) {
631 ui_app->landscapeimg =
632 strdup(application.app_info.landscape_image().c_str());
633 AppendSplashScreen(ui_app, application.app_info.landscape_image(),
634 application.app_info.effectimage_type(), {}, kLandscapeOrientation,
635 application.app_info.indicator_display(), {}, {});
637 ui_app->submode_mainid =
638 strdup(application.app_info.submode_mainid().c_str());
639 ui_app->hwacceleration =
640 strdup(application.app_info.hwacceleration().c_str());
641 ui_app->onboot = strdup("false");
642 ui_app->autorestart = strdup("false");
643 ui_app->component_type = strdup("uiapp");
644 ui_app->mainapp = strdup(application.app_info.mainapp().c_str());
645 ui_app->screenreader = strdup("use-system-setting");
646 ui_app->recentimage = strdup("false");
647 ui_app->launchcondition = strdup("false");
648 ui_app->guestmode_visibility = strdup("true");
649 ui_app->permission_type = strdup("normal");
650 ui_app->support_ambient = strdup("false");
651 ui_app->package = strdup(manifest->package);
652 ui_app->support_disable = strdup(manifest->support_disable);
653 ui_app->splash_screen_display =
654 strdup(application.app_info.splash_screen_display().c_str());
655 if (!application.app_info.api_version().empty())
656 ui_app->api_version = strdup(application.app_info.api_version().c_str());
658 ui_app->api_version = strdup(manifest->api_version);
659 manifest->application = g_list_append(manifest->application, ui_app);
660 if (bf::path(application.app_info.exec().c_str()).is_absolute())
661 ui_app->exec = strdup(application.app_info.exec().c_str());
663 ui_app->exec = strdup((context_->root_application_path.get()
664 / manifest->package / "bin"
665 / application.app_info.exec()).c_str());
668 if (!FillAppControl(ui_app, application.app_control))
670 if (!FillDataControl(ui_app, application.data_control))
672 if (!FillApplicationIconPaths(ui_app, application.app_icons))
674 if (!FillLabel(ui_app, application.label))
676 if (!FillImage(ui_app, application.app_images))
678 if (!FillMetadata(ui_app, application.meta_data))
680 if (!FillCategories(ui_app, application.categories))
682 if (!FillBackgroundCategoryInfo(ui_app, application.background_category))
684 if (!FillSplashScreen(ui_app, application.app_splashscreens))
686 if (!FillResControl(ui_app, application.res_controls))
692 bool StepParseManifest::FillWatchApplication(manifest_x* manifest) {
693 auto watch_application_list =
694 std::static_pointer_cast<const tpk::parse::WatchApplicationInfoList>(
695 parser_->GetManifestData(app_keys::kWatchApplicationKey));
696 if (!watch_application_list)
699 for (const auto& watch_application : watch_application_list->items) {
700 int package_support_mode_val = atoi(manifest->support_mode);
701 int app_support_mode_val = package_support_mode_val |
702 GetSupportModeVal(watch_application.app_info.support_mode());
704 application_x* watch_app =
705 static_cast<application_x*>(calloc(1, sizeof(application_x)));
707 LOG(ERROR) << "Out of memory";
710 watch_app->appid = strdup(watch_application.app_info.appid().c_str());
712 if (bf::path(watch_application.app_info.exec().c_str()).is_absolute())
713 watch_app->exec = strdup(watch_application.app_info.exec().c_str());
715 watch_app->exec = strdup(
716 (context_->root_application_path.get()
717 / manifest->package / "bin" /
718 watch_application.app_info.exec()).c_str());
719 watch_app->nodisplay = strdup("true");
720 watch_app->multiple = strdup("false");
721 if (!watch_application.app_info.type().empty())
722 watch_app->type = strdup(watch_application.app_info.type().c_str());
724 watch_app->type = strdup("capp");
725 watch_app->taskmanage = strdup("false");
726 watch_app->hwacceleration = strdup("default");
727 watch_app->screenreader = strdup("use-system-setting");
728 watch_app->mainapp = strdup(watch_application.app_info.mainapp().c_str());
729 watch_app->recentimage = strdup("false");
730 watch_app->launchcondition = strdup("false");
731 watch_app->indicatordisplay = strdup("true");
732 watch_app->effectimage_type = strdup("image");
733 watch_app->guestmode_visibility = strdup("true");
734 watch_app->permission_type = strdup("normal");
735 watch_app->component_type = strdup("watchapp");
736 watch_app->preload = strdup("false");
737 watch_app->submode = strdup("false");
738 watch_app->process_pool = strdup("false");
739 watch_app->autorestart = strdup("false");
740 watch_app->onboot = strdup("false");
741 watch_app->support_mode =
742 strdup((std::to_string(app_support_mode_val)).c_str());
743 watch_app->ui_gadget = strdup("false");
744 watch_app->launch_mode = strdup("single");
745 if (!watch_application.app_info.api_version().empty())
746 watch_app->api_version =
747 strdup(watch_application.app_info.api_version().c_str());
749 watch_app->api_version = strdup(manifest->api_version);
750 watch_app->support_ambient =
751 strdup(watch_application.app_info.ambient_support().c_str());
752 watch_app->package = strdup(manifest->package);
753 if (!watch_application.app_info.setup_appid().empty())
754 watch_app->setup_appid =
755 strdup(watch_application.app_info.setup_appid().c_str());
756 manifest->application = g_list_append(manifest->application, watch_app);
758 if (!FillLabel(watch_app, watch_application.label))
760 if (!FillApplicationIconPaths(watch_app, watch_application.app_icons))
762 if (!FillMetadata(watch_app, watch_application.meta_data))
764 if (!FillCategories(watch_app, watch_application.categories))
766 if (!FillBackgroundCategoryInfo(watch_app,
767 watch_application.background_category))
769 if (!FillResControl(watch_app, watch_application.res_controls))
775 bool StepParseManifest::FillTrustAnchorInfo(manifest_x* manifest) {
776 std::shared_ptr<const tpk::parse::TrustAnchorInfo> trust_anchor_info =
777 std::static_pointer_cast<const tpk::parse::TrustAnchorInfo>(
778 parser_->GetManifestData(app_keys::kTrustAnchorKey));
779 if (!trust_anchor_info)
782 if (trust_anchor_info->get_use_system_certs().empty()) {
783 LOG(ERROR) << "Invalid trust anchor data";
787 manifest->use_system_certs =
788 strdup(trust_anchor_info->get_use_system_certs().c_str());
793 bool StepParseManifest::FillDependencyInfo(manifest_x* manifest) {
794 std::shared_ptr<const tpk::parse::DependenciesInfo> dependencies_info =
795 std::static_pointer_cast<const tpk::parse::DependenciesInfo>(
796 parser_->GetManifestData(app_keys::kDependenciesKey));
797 if (!dependencies_info)
800 for (const auto& dependency : dependencies_info->dependencies()) {
802 static_cast<dependency_x*>(calloc(1, sizeof(dependency_x)));
804 LOG(ERROR) << "Out of memory";
807 dep->depends_on = strdup(dependency.pkgid().c_str());
808 dep->type = strdup(dependency.type().c_str());
809 if (!dependency.required_version().empty())
810 dep->required_version = strdup(dependency.required_version().c_str());
811 manifest->dependencies = g_list_append(manifest->dependencies, dep);
817 bool StepParseManifest::FillLightUserInfo(manifest_x* manifest) {
818 std::shared_ptr<const tpk::parse::LightUserInfo> light_user_info =
819 std::static_pointer_cast<const tpk::parse::LightUserInfo>(
820 parser_->GetManifestData(tpk::parse::LightUserInfo::Key()));
821 if (!light_user_info) {
822 manifest->light_user_switch_mode = strdup("default");
826 if (light_user_info->switch_mode().empty()) {
827 LOG(ERROR) << "Invalid switch mode";
831 manifest->light_user_switch_mode =
832 strdup(light_user_info->switch_mode().c_str());
837 bool StepParseManifest::CheckFeatures() {
839 std::static_pointer_cast<const tpk::parse::FeatureInfo>(
840 parser_->GetManifestData(tpk::parse::FeatureInfo::Key()));
845 FeatureValidator validator(feature_info->features());
846 if (!validator.Validate(&error)) {
847 LOG(ERROR) << "Feature validation error. " << error;
854 template <typename T>
855 bool StepParseManifest::FillAppControl(application_x* app,
856 const T& app_control_list) {
857 if (app_control_list.empty())
860 for (const auto& control : app_control_list) {
861 appcontrol_x* app_control =
862 static_cast<appcontrol_x*>(calloc(1, sizeof(appcontrol_x)));
864 LOG(ERROR) << "Out of memory";
867 app_control->operation = strdup(control.operation().c_str());
868 if (!control.mime().empty())
869 app_control->mime = strdup(control.mime().c_str());
870 if (!control.uri().empty())
871 app_control->uri = strdup(control.uri().c_str());
872 if (!control.visibility().empty())
873 app_control->visibility = strdup(control.visibility().c_str());
875 app_control->visibility = strdup("local-only");
876 if (!control.id().empty())
877 app_control->id = strdup(control.id().c_str());
879 app_control->id = strdup("no-name-app-control");
880 for (const auto& priv : control.privileges()) {
881 app_control->privileges = g_list_append(app_control->privileges,
882 strdup(priv.c_str()));
884 app->appcontrol = g_list_append(app->appcontrol, app_control);
889 template <typename T>
890 bool StepParseManifest::FillDataControl(application_x* app,
891 const T& data_control_list) {
892 if (data_control_list.empty())
895 for (const auto& control : data_control_list) {
896 datacontrol_x* data_control =
897 static_cast<datacontrol_x*>(calloc(1, sizeof(datacontrol_x)));
899 LOG(ERROR) << "Out of memory";
902 data_control->access = strdup(control.access().c_str());
903 data_control->providerid = strdup(control.providerid().c_str());
904 data_control->type = strdup(control.type().c_str());
905 if (!control.trusted().empty())
906 data_control->trusted = strdup(control.trusted().c_str());
908 data_control->trusted = strdup("false");
909 for (const auto& priv : control.privileges())
910 data_control->privileges = g_list_append(data_control->privileges,
911 strdup(priv.c_str()));
913 app->datacontrol = g_list_append(app->datacontrol, data_control);
918 template <typename T>
919 bool StepParseManifest::FillApplicationIconPaths(application_x* app,
920 const T& icons_info) {
921 for (auto& application_icon : icons_info.icons()) {
922 icon_x* icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
924 LOG(ERROR) << "Out of memory";
928 if (bf::path(application_icon.path()).is_absolute()) {
929 text = application_icon.path();
931 text = context_->root_application_path.get()
932 / context_->pkgid.get() / "shared" / "res" / application_icon.path();
934 // NOTE: name is an attribute, but the xml writer uses it as text.
935 // This must be fixed in whole app-installer modules, including wgt.
936 // Current implementation is just for compatibility.
937 icon->text = strdup(text.c_str());
938 if (application_icon.lang().empty())
939 icon->lang = strdup(DEFAULT_LOCALE);
941 icon->lang = strdup(application_icon.lang().c_str());
943 if (!application_icon.dpi().empty())
944 icon->dpi = strdup(application_icon.dpi().c_str());
945 app->icon = g_list_append(app->icon, icon);
950 template <typename T>
951 bool StepParseManifest::FillLabel(application_x* app, const T& label_list) {
952 if (label_list.empty())
955 for (const auto& control : label_list) {
957 static_cast<label_x*>(calloc(1, sizeof(label_x)));
959 LOG(ERROR) << "Out of memory";
962 // NOTE: name is an attribute, but the xml writer uses it as text.
963 // This must be fixed in whole app-installer modules, including wgt.
964 // Current implementation is just for compatibility.
965 label->text = strdup(control.text().c_str());
966 label->name = strdup(control.name().c_str());
967 label->lang = !control.xml_lang().empty() ?
968 strdup(control.xml_lang().c_str()) : strdup(DEFAULT_LOCALE);
969 app->label = g_list_append(app->label, label);
974 template <typename T>
975 bool StepParseManifest::FillMetadata(application_x* app,
976 const T& meta_data_list) {
977 if (meta_data_list.empty())
980 for (auto& meta : meta_data_list) {
981 metadata_x* metadata =
982 static_cast<metadata_x*>(calloc(1, sizeof(metadata_x)));
984 LOG(ERROR) << "Out of memory";
987 metadata->key = strdup(meta.key().c_str());
988 metadata->value = strdup(meta.val().c_str());
989 app->metadata = g_list_append(app->metadata, metadata);
991 GetLegacySplashScreenFromMetadata(app, meta.key(), meta.val());
996 template <typename T>
997 bool StepParseManifest::FillCategories(application_x* manifest,
998 const T& categories) {
999 for (auto& category : categories) {
1000 manifest->category = g_list_append(manifest->category,
1001 strdup(category.c_str()));
1006 void StepParseManifest::AppendSplashScreen(application_x* app,
1007 const std::string& src, const std::string& type, const std::string& dpi,
1008 const std::string& orientation, const std::string& indicatordisplay,
1009 const std::string& operation, const std::string& color_depth) {
1010 splashscreen_x* splashscreen =
1011 static_cast<splashscreen_x*>(calloc(1, sizeof(splashscreen_x)));
1012 if (!splashscreen) {
1013 LOG(ERROR) << "Out of memory";
1016 if (bf::path(src).is_absolute()) {
1017 splashscreen->src = strdup(src.c_str());
1019 bf::path full_path = context_->GetPkgPath() / src;
1020 splashscreen->src = strdup(full_path.string().c_str());
1022 if (src.substr(src.find_last_of(".") + 1) == "edj")
1023 splashscreen->type = strdup("edj");
1024 else if (type == "edj")
1025 splashscreen->type = strdup("edj");
1027 splashscreen->type = strdup("img");
1029 splashscreen->dpi = strdup(dpi.c_str());
1030 splashscreen->orientation = strdup(orientation.c_str());
1031 if (!indicatordisplay.empty())
1032 splashscreen->indicatordisplay = strdup(indicatordisplay.c_str());
1034 splashscreen->indicatordisplay = strdup("true");
1035 if (operation == "launch_effect")
1036 splashscreen->operation = strdup("launch-effect");
1037 else if (!operation.empty())
1038 splashscreen->operation = strdup(operation.c_str());
1040 splashscreen->operation = strdup("launch-effect");
1041 if (!color_depth.empty())
1042 splashscreen->color_depth = strdup(color_depth.c_str());
1044 splashscreen->color_depth = strdup("24");
1045 app->splashscreens = g_list_append(app->splashscreens, splashscreen);
1048 template <typename T>
1049 bool StepParseManifest::FillSplashScreen(application_x* app,
1050 const T& splashscreens_info) {
1051 for (auto& splash_screen : splashscreens_info.splashscreens()) {
1053 if (context_->is_readonly_package.get())
1054 src = splash_screen.src();
1056 src = bf::path(context_->root_application_path.get()
1057 / app->package / "shared" / "res" / splash_screen.src()).string();
1059 AppendSplashScreen(app, src, splash_screen.type(), splash_screen.dpi(),
1060 splash_screen.orientation(), splash_screen.indicatordisplay(),
1061 splash_screen.operation(), splash_screen.colordepth());
1066 template <typename T>
1067 bool StepParseManifest::FillResControl(application_x* app,
1068 const T& res_control_list) {
1069 for (auto& res_control : res_control_list) {
1070 if (res_control.resource_type().empty())
1074 static_cast<res_control_x*>(calloc(1, sizeof(res_control_x)));
1076 LOG(ERROR) << "Out of memory";
1080 rc->res_type = strdup(res_control.resource_type().c_str());
1081 if (!res_control.min_res_version().empty())
1082 rc->min_res_version = strdup(res_control.min_res_version().c_str());
1083 if (!res_control.max_res_version().empty())
1084 rc->max_res_version = strdup(res_control.max_res_version().c_str());
1085 if (!res_control.auto_close().empty())
1086 rc->auto_close = strdup(res_control.auto_close().c_str());
1088 app->res_control = g_list_prepend(app->res_control, rc);
1093 void StepParseManifest::GetLegacySplashScreenFromMetadata(application_x* app,
1094 const std::string& key, const std::string& val) {
1095 std::string operation;
1096 if (key.find(kOperationEffectKey) != std::string::npos) {
1097 boost::char_separator<char> sep("=");
1098 boost::tokenizer<boost::char_separator<char>> tokens(key, sep);
1099 auto iter = tokens.begin();
1102 } else if (key.find(kLaunchEffectKey) != std::string::npos) {
1103 operation = std::string("launch-effect");
1105 // not a metadata splashscreen
1109 boost::char_separator<char> sep("=|");
1110 boost::tokenizer<boost::char_separator<char>> tokens(val, sep);
1111 auto iter = tokens.begin();
1112 std::string portrait_src;
1113 std::string landscape_src;
1114 std::string indicatordisplay;
1115 while (iter != tokens.end()) {
1116 if (!(*iter).compare(kPortraitEffectImageValue)) {
1118 portrait_src = *iter;
1119 } else if (!(*iter).compare(kLandscapeEffectImageValue)) {
1121 landscape_src = *iter;
1122 } else if (!(*iter).compare(kIndicatorDisplayValue)) {
1124 indicatordisplay = *iter;
1128 if (!portrait_src.empty())
1129 AppendSplashScreen(app, portrait_src, {}, {}, kPortraitOrientation,
1130 indicatordisplay, operation, {});
1131 if (!landscape_src.empty())
1132 AppendSplashScreen(app, landscape_src, {}, {}, kLandscapeOrientation,
1133 indicatordisplay, operation, {});
1136 bool StepParseManifest::FillImage(application_x* app,
1137 const tpk::parse::ApplicationImagesInfo& image_list) {
1138 for (auto& app_image : image_list.images) {
1140 static_cast<image_x*>(calloc(1, sizeof(image_x)));
1142 LOG(ERROR) << "Out of memory";
1145 const std::string& lang = app_image.lang();
1147 image->lang = strdup(lang.c_str());
1149 image->lang = strdup(DEFAULT_LOCALE);
1150 if (!app_image.section().empty())
1151 image->section = strdup(app_image.section().c_str());
1152 app->image = g_list_append(app->image, image);
1157 template <typename T>
1158 bool StepParseManifest::FillBackgroundCategoryInfo(application_x* app,
1159 const T& background_category_data_list) {
1160 for (const auto& background_category : background_category_data_list) {
1161 app->background_category = g_list_append(
1162 app->background_category, strdup(background_category.value().c_str()));
1168 bool StepParseManifest::FillExtraInfo(manifest_x* manifest) {
1169 if (manifest_location_ == ManifestLocation::INSTALLED) {
1170 // recovery of tep value for installed package
1171 PkgQueryInterface pkg_query(context_->pkgid.get(), context_->uid.get());
1172 std::string old_tep = pkg_query.TepPath();
1173 if (!old_tep.empty())
1174 manifest->tep_name = strdup(old_tep.c_str());
1176 // recovery of zip mount file for installed package
1177 std::string zip_mount_file = pkg_query.ZipMountFile();
1178 if (!zip_mount_file.empty())
1179 manifest->zip_mount_file = strdup(zip_mount_file.c_str());
1182 if (manifest->application == nullptr)
1185 // in case of hybrid package, main app is already set by wgt-backend
1186 application_x* mainapp = nullptr;
1187 if (!context_->cross_app_rules.get()) {
1189 for (const auto& app : GListRange<application_x*>(manifest->application)) {
1190 if (!strcmp(app->mainapp, "true")) {
1195 if (mainapp == nullptr)
1196 mainapp = reinterpret_cast<application_x*>(
1197 g_list_first(manifest->application)->data);
1198 free(mainapp->mainapp);
1199 mainapp->mainapp = strdup("true");
1200 manifest->mainapp_id = strdup(mainapp->appid);
1203 // mark mainapp=false at other apps
1204 for (auto& app : GListRange<application_x*>(manifest->application)) {
1208 app->mainapp = strdup("false");
1213 bool StepParseManifest::FillComponentBasedApplicationInfo(
1214 manifest_x* manifest) {
1215 std::shared_ptr<const tpk::parse::ComponentBasedApplicationInfoList>
1216 component_based_application_list = std::static_pointer_cast<
1217 const tpk::parse::ComponentBasedApplicationInfoList>(
1218 parser_->GetManifestData(
1219 app_keys::kComponentBasedApplicationKey));
1220 if (!component_based_application_list)
1223 for (const auto& application : component_based_application_list->items) {
1224 int package_support_mode_val = atoi(manifest->support_mode);
1225 int app_support_mode_val = package_support_mode_val |
1226 GetSupportModeVal(application.app_info.support_mode());
1228 application_x* app =
1229 static_cast<application_x*>(calloc(1, sizeof(application_x)));
1231 LOG(ERROR) << "Out of memory";
1235 app->appid = strdup(application.app_info.appid().c_str());
1236 app->launch_mode = strdup(application.app_info.launch_mode().c_str());
1237 app->multiple = strdup(application.app_info.multiple().c_str());
1238 app->nodisplay = strdup(application.app_info.nodisplay().c_str());
1239 app->support_mode = strdup((std::to_string(app_support_mode_val)).c_str());
1240 app->taskmanage = strdup(application.app_info.taskmanage().c_str());
1241 if (!application.app_info.type().empty())
1242 app->type = strdup(application.app_info.type().c_str());
1244 app->type = strdup("c++app");
1245 app->indicatordisplay =
1246 strdup(application.app_info.indicator_display().c_str());
1247 app->component_type = strdup("componentbasedapp");
1248 app->hwacceleration = strdup(application.app_info.hwacceleration().c_str());
1249 app->onboot = strdup("false");
1250 app->autorestart = strdup("false");
1251 app->mainapp = strdup(application.app_info.mainapp().c_str());
1252 app->screenreader = strdup("use-system-setting");
1253 app->recentimage = strdup("false");
1254 app->launchcondition = strdup("false");
1255 app->guestmode_visibility = strdup("true");
1256 app->permission_type = strdup("normal");
1257 app->support_ambient = strdup("false");
1258 app->effectimage_type = strdup("image");
1259 app->submode = strdup("false");
1260 app->process_pool = strdup("false");
1261 app->package = strdup(manifest->package);
1262 app->support_disable = strdup(manifest->support_disable);
1263 app->launch_mode = strdup("single");
1264 if (!application.app_info.api_version().empty())
1265 app->api_version = strdup(application.app_info.api_version().c_str());
1267 app->api_version = strdup(manifest->api_version);
1268 app->splash_screen_display =
1269 strdup(application.app_info.splash_screen_display().c_str());
1270 manifest->application = g_list_append(manifest->application, app);
1271 if (bf::path(application.app_info.exec().c_str()).is_absolute()) {
1272 app->exec = strdup(application.app_info.exec().c_str());
1274 app->exec = strdup((context_->root_application_path.get()
1275 / manifest->package / "bin"
1276 / application.app_info.exec()).c_str());
1278 if (!FillLabel(app, application.label))
1280 if (!FillImage(app, application.app_images))
1282 if (!FillBackgroundCategoryInfo(app, application.background_category))
1284 if (!FillAppControl(app, application.app_control))
1286 if (!FillDataControl(app, application.data_control))
1288 if (!FillMetadata(app, application.meta_data))
1290 if (!FillCategories(app, application.categories))
1292 if (!FillSplashScreen(app, application.app_splashscreens))
1294 if (!FillResControl(app, application.res_controls))
1301 bool StepParseManifest::FillManifestX(manifest_x* manifest) {
1302 if (!FillPackageInfo(manifest))
1304 if (!FillInstallationInfo(manifest))
1306 if (!FillUIApplication(manifest))
1308 if (!FillServiceApplication(manifest))
1310 if (!FillWidgetApplication(manifest))
1312 if (!FillWatchApplication(manifest))
1314 if (!FillComponentBasedApplicationInfo(manifest))
1316 if (!FillPrivileges(manifest))
1318 if (!FillProvidesAppDefinedPrivileges(manifest))
1320 if (!FillAuthorInfo(manifest))
1322 if (!FillDescriptionInfo(manifest))
1324 if (!FillExtraInfo(manifest))
1326 if (!FillTrustAnchorInfo(manifest))
1328 if (!FillDependencyInfo(manifest))
1330 if (!FillLightUserInfo(manifest))
1335 Step::Status StepParseManifest::process() {
1336 if (context_->force_clean_from_db.get())
1337 return Step::Status::OK;
1338 if (!LocateConfigFile()) {
1339 // continue if this is recovery, manifest file may never been created
1340 if (manifest_location_ == ManifestLocation::RECOVERY) {
1341 LOG(DEBUG) << "Manifest for recovery not found";
1342 return Step::Status::OK;
1344 LOG(ERROR) << "No manifest file exists";
1345 return Step::Status::MANIFEST_NOT_FOUND;
1347 parser_.reset(new tpk::parse::TPKConfigParser());
1348 if (!parser_->ParseManifest(path_)) {
1349 if (manifest_location_ == ManifestLocation::RECOVERY) {
1350 LOG(DEBUG) << "Manifest for recovery is invalid";
1352 return Step::Status::OK;
1354 LOG(ERROR) << "[Parse] Parse failed. " << parser_->GetErrorMessage();
1355 return Step::Status::PARSE_ERROR;
1358 // Copy data from ManifestData to InstallerContext
1359 std::shared_ptr<const tpk::parse::PackageInfo> info =
1360 std::static_pointer_cast<const tpk::parse::PackageInfo>(
1361 parser_->GetManifestData(app_keys::kManifestKey));
1363 context_->pkgid.set(info->package());
1365 manifest_x* manifest =
1366 static_cast<manifest_x*>(calloc(1, sizeof(manifest_x)));
1368 LOG(ERROR) << "Out of memory";
1369 return Step::Status::ERROR;
1372 if (!FillManifestX(const_cast<manifest_x*>(manifest))) {
1373 LOG(ERROR) << "[Parse] Storing manifest_x failed. "
1374 << parser_->GetErrorMessage();
1375 pkgmgr_parser_free_manifest_xml(manifest);
1376 return Step::Status::PARSE_ERROR;
1379 // write pkgid for recovery file
1380 if (context_->recovery_info.get().recovery_file) {
1381 context_->recovery_info.get().recovery_file->set_pkgid(manifest->package);
1382 context_->recovery_info.get().recovery_file->WriteAndCommitFileContent();
1385 LOG(INFO) << "Parsed package id: " << info->package();
1387 switch (store_location_) {
1388 case StoreLocation::NORMAL:
1389 context_->manifest_data.set(manifest);
1391 case StoreLocation::BACKUP:
1392 context_->old_manifest_data.set(manifest);
1395 LOG(ERROR) << "Unknown store location for parsed data";
1396 return Step::Status::ERROR;
1398 return Step::Status::OK;
1401 } // namespace configuration
1402 } // namespace common_installer