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>
37 #include <type_traits>
41 #include "common/feature_validator.h"
42 #include "common/installer_context.h"
43 #include "common/utils/paths.h"
44 #include "common/privileges.h"
45 #include "common/pkgmgr_registration.h"
46 #include "common/utils/pkgmgr_query.h"
47 #include "common/step/step.h"
48 #include "common/utils/glist_range.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 =
192 strdup(std::to_string(std::chrono::system_clock::to_time_t(
193 std::chrono::system_clock::now())).c_str());
197 bool StepParseManifest::FillPackageInfo(manifest_x* manifest) {
198 std::shared_ptr<const tpk::parse::PackageInfo> pkg_info =
199 std::static_pointer_cast<const tpk::parse::PackageInfo>(
200 parser_->GetManifestData(app_keys::kManifestKey));
202 LOG(ERROR) << "Package info manifest data has not been found.";
206 int support_mode_val = GetSupportModeVal(pkg_info->support_mode());
208 manifest->ns = strdup(pkg_info->xmlns().c_str());
209 manifest->package = strdup(pkg_info->package().c_str());
210 manifest->nodisplay_setting = strdup(pkg_info->nodisplay_setting().c_str());
211 manifest->support_mode = strdup((std::to_string(support_mode_val)).c_str());
212 manifest->appsetting = strdup("false");
213 manifest->support_disable = strdup(pkg_info->support_disable().c_str());
214 manifest->version = strdup(pkg_info->version().c_str());
215 manifest->installlocation = strdup(pkg_info->install_location().c_str());
216 manifest->api_version = strdup(pkg_info->api_version().c_str());
217 manifest->readonly = strdup(pkg_info->readonly().c_str());
218 manifest->preload = strdup(pkg_info->preload().c_str());
219 manifest->removable = strdup(pkg_info->removable().c_str());
221 common_installer::RequestType req_type = context_->request_type.get();
222 if (pkg_info->type().empty()) {
223 if ((req_type == RequestType::ManifestDirectInstall ||
224 req_type == RequestType::ManifestDirectUpdate) &&
225 context_->is_readonly_package.get())
226 manifest->type = strdup("rpm");
228 manifest->type = strdup("tpk");
230 manifest->type = strdup(pkg_info->type().c_str());
233 for (auto& pair : pkg_info->labels()) {
234 label_x* label = reinterpret_cast<label_x*>(calloc(1, sizeof(label_x)));
236 LOG(ERROR) << "Out of memory";
239 if (!pair.first.empty())
240 label->lang = strdup(pair.first.c_str());
242 label->lang = strdup(DEFAULT_LOCALE);
243 label->text = strdup(pair.second.c_str());
244 manifest->label = g_list_append(manifest->label, label);
247 std::shared_ptr<const tpk::parse::ProfileInfo> profile_info =
248 std::static_pointer_cast<const tpk::parse::ProfileInfo>(
249 parser_->GetManifestData(tpk::parse::ProfileInfo::Key()));
251 for (auto& profile : profile_info->profiles()) {
252 manifest->deviceprofile = g_list_append(manifest->deviceprofile,
253 strdup(profile.c_str()));
257 // set installed_storage if package is installed
258 // this is internal field in package manager but after reading configuration
260 PkgQueryInterface pkg_query(manifest->package, context_->uid.get());
261 if (!manifest->installed_storage) {
262 if (manifest_location_ == ManifestLocation::INSTALLED ||
263 manifest_location_ == ManifestLocation::RECOVERY) {
264 std::string storage = pkg_query.StorageForPkgId();
265 if (storage.empty()) {
266 // Failed to query installation storage, assign internal
267 manifest->installed_storage = strdup(kInstalledInternally);
269 manifest->installed_storage = strdup(storage.c_str());
272 manifest->installed_storage = strdup(kInstalledInternally);
276 // retrieve and set plugin execution info if exists
277 if (manifest_location_ == ManifestLocation::INSTALLED ||
278 manifest_location_ == ManifestLocation::RECOVERY) {
279 std::vector<PkgQueryInterface::PluginInfo> plugin_list;
280 pkg_query.PluginExecutionInfo(&plugin_list);
282 for (const auto& plugin_info : plugin_list) {
284 reinterpret_cast<plugin_x*>(calloc(1, sizeof(plugin_x)));
286 LOG(ERROR) << "Out of memory";
290 plugin->pkgid = strdup(manifest->package);
291 plugin->appid = strdup(std::get<1>(plugin_info).c_str());
292 plugin->plugin_type = strdup(std::get<2>(plugin_info).c_str());
293 plugin->plugin_name = strdup(std::get<3>(plugin_info).c_str());
294 manifest->plugin = g_list_append(manifest->plugin, plugin);
300 bool StepParseManifest::FillAuthorInfo(manifest_x* manifest) {
301 std::shared_ptr<const tpk::parse::AuthorInfo> author_info =
302 std::static_pointer_cast<const tpk::parse::AuthorInfo>(
303 parser_->GetManifestData(tpk::parse::AuthorInfo::Key()));
308 author_x* author = reinterpret_cast<author_x*>(calloc(1, sizeof(author_x)));
310 LOG(ERROR) << "Out of memory";
313 author->text = strdup(author_info->name().c_str());
314 author->email = strdup(author_info->email().c_str());
315 author->href = strdup(author_info->href().c_str());
316 author->lang = strdup(DEFAULT_LOCALE);
317 manifest->author = g_list_append(manifest->author, author);
321 bool StepParseManifest::FillDescriptionInfo(manifest_x* manifest) {
322 std::shared_ptr<const tpk::parse::DescriptionInfoList> description_info =
323 std::static_pointer_cast<const tpk::parse::DescriptionInfoList>(
324 parser_->GetManifestData(tpk::parse::DescriptionInfoList::Key()));
326 if (!description_info)
329 for (auto& desc : description_info->descriptions) {
330 description_x* description = reinterpret_cast<description_x*>
331 (calloc(1, sizeof(description_x)));
333 LOG(ERROR) << "Out of memory";
336 description->text = strdup(desc.description().c_str());
337 description->lang = !desc.xml_lang().empty() ?
338 strdup(desc.xml_lang().c_str()) : strdup(DEFAULT_LOCALE);
339 manifest->description = g_list_append(manifest->description, description);
344 bool StepParseManifest::FillPrivileges(manifest_x* manifest) {
345 std::shared_ptr<const tpk::parse::PrivilegesInfo> perm_info =
346 std::static_pointer_cast<const tpk::parse::PrivilegesInfo>(
347 parser_->GetManifestData(app_keys::kPrivilegesKey));
351 const auto& privileges = perm_info->GetPrivileges();
352 for (auto& priv : privileges) {
353 privilege_x* privilege =
354 reinterpret_cast<privilege_x*>(calloc(1, sizeof(privilege_x)));
356 LOG(ERROR) << "Out of memory";
359 privilege->value = strdup(priv.first.c_str());
360 privilege->type = strdup(priv.second.c_str());
361 manifest->privileges = g_list_append(manifest->privileges, privilege);
364 const auto& appdef_privileges_list =
365 perm_info->GetAppDefinedPrivilegeInfoList();
366 for (auto& appdef_info : appdef_privileges_list) {
367 appdefined_privilege_x* privilege =
368 reinterpret_cast<appdefined_privilege_x*>(calloc(1,
369 sizeof(appdefined_privilege_x)));
370 if (privilege == nullptr) {
371 LOG(ERROR) << "Memory alloc failure";
374 auto& priv = appdef_info.GetAppDefinedPrivilege();
375 privilege->value = strdup(priv.privilege.c_str());
376 privilege->type = strdup(priv.type.c_str());
377 if (!priv.license.empty()) {
378 if (bf::path(priv.license).is_absolute())
379 privilege->license = strdup(priv.license.c_str());
381 privilege->license = strdup((context_->GetPkgPath()
382 / priv.license).c_str());
384 manifest->appdefined_privileges =
385 g_list_append(manifest->appdefined_privileges, privilege);
391 bool StepParseManifest::FillProvidesAppDefinedPrivileges(
392 manifest_x* manifest) {
393 std::shared_ptr<const tpk::parse::ProvidesAppDefinedPrivilegesInfo>
394 priv_info = std::static_pointer_cast<
395 const tpk::parse::ProvidesAppDefinedPrivilegesInfo>(
396 parser_->GetManifestData(
397 app_keys::kProvidesAppDefinedPrivilegesKey));
401 const auto& privileges_list = priv_info->GetAppDefinedPrivilegeInfoList();
402 for (auto& appdef_info : privileges_list) {
403 appdefined_privilege_x* privilege =
404 reinterpret_cast<appdefined_privilege_x*>(calloc(1,
405 sizeof(appdefined_privilege_x)));
406 if (privilege == nullptr) {
407 LOG(ERROR) << "Memory alloc failure";
410 auto& priv = appdef_info.GetAppDefinedPrivilege();
411 privilege->value = strdup(priv.privilege.c_str());
412 privilege->type = strdup(priv.type.c_str());
413 if (!priv.license.empty()) {
414 if (bf::path(priv.license).is_absolute())
415 privilege->license = strdup(priv.license.c_str());
417 privilege->license = strdup((context_->GetPkgPath()
418 / priv.license).c_str());
420 manifest->provides_appdefined_privileges =
421 g_list_append(manifest->provides_appdefined_privileges, privilege);
427 bool StepParseManifest::FillWidgetApplication(manifest_x* manifest) {
428 auto widget_application_list =
429 std::static_pointer_cast<const tpk::parse::WidgetApplicationInfoList>(
430 parser_->GetManifestData(app_keys::kWidgetApplicationKey));
431 if (!widget_application_list)
434 for (const auto& application : widget_application_list->items) {
435 int package_support_mode_val = atoi(manifest->support_mode);
436 int app_support_mode_val = package_support_mode_val |
437 GetSupportModeVal(application.app_info.support_mode());
439 application_x* widget_app =
440 static_cast<application_x*>(calloc(1, sizeof(application_x)));
442 LOG(ERROR) << "Out of memory";
445 widget_app->appid = strdup(application.app_info.appid().c_str());
446 widget_app->launch_mode =
447 strdup(application.app_info.launch_mode().c_str());
448 widget_app->multiple = strdup("false");
449 widget_app->nodisplay = strdup(application.app_info.nodisplay().c_str());
450 widget_app->support_mode =
451 strdup((std::to_string(app_support_mode_val)).c_str());
452 widget_app->taskmanage = strdup("false");
453 widget_app->indicatordisplay = strdup("false");
454 if (!application.app_info.type().empty())
455 widget_app->type = strdup(application.app_info.type().c_str());
457 widget_app->type = strdup("capp");
458 widget_app->component_type = strdup("widgetapp");
459 widget_app->hwacceleration =
460 strdup(application.app_info.hwacceleration().c_str());
461 widget_app->onboot = strdup("false");
462 widget_app->autorestart = strdup("false");
463 widget_app->mainapp = strdup(application.app_info.mainapp().c_str());
464 widget_app->screenreader = strdup("use-system-setting");
465 widget_app->recentimage = strdup("false");
466 widget_app->launchcondition = strdup("false");
467 widget_app->guestmode_visibility = strdup("true");
468 widget_app->permission_type = strdup("normal");
469 widget_app->support_ambient = strdup("false");
470 widget_app->effectimage_type = strdup("image");
471 widget_app->submode = strdup("false");
472 widget_app->process_pool = strdup("false");
473 widget_app->package = strdup(manifest->package);
474 widget_app->support_disable = strdup(manifest->support_disable);
475 widget_app->launch_mode = strdup("single");
476 if (!application.app_info.api_version().empty())
477 widget_app->api_version =
478 strdup(application.app_info.api_version().c_str());
480 widget_app->api_version = strdup(manifest->api_version);
481 manifest->application = g_list_append(manifest->application, widget_app);
482 if (bf::path(application.app_info.exec().c_str()).is_absolute())
483 widget_app->exec = strdup(application.app_info.exec().c_str());
485 widget_app->exec = strdup((context_->root_application_path.get()
486 / manifest->package / "bin"
487 / application.app_info.exec()).c_str());
489 if (!FillApplicationIconPaths(widget_app, application.app_icons))
491 if (!FillLabel(widget_app, application.label))
493 if (!FillImage(widget_app, application.app_images))
495 if (!FillCategories(widget_app, application.categories))
497 if (!FillMetadata(widget_app, application.meta_data))
499 if (!FillResControl(widget_app, application.res_controls))
505 bool StepParseManifest::FillServiceApplication(manifest_x* manifest) {
506 auto service_application_list =
507 std::static_pointer_cast<const tpk::parse::ServiceApplicationInfoList>(
508 parser_->GetManifestData(app_keys::kServiceApplicationKey));
509 if (!service_application_list)
512 for (const auto& application : service_application_list->items) {
513 int package_support_mode_val = atoi(manifest->support_mode);
514 int app_support_mode_val = package_support_mode_val |
515 GetSupportModeVal(application.app_info.support_mode());
517 application_x* service_app =
518 static_cast<application_x*>(calloc(1, sizeof(application_x)));
520 LOG(ERROR) << "Out of memory";
523 service_app->appid = strdup(application.app_info.appid().c_str());
524 service_app->multiple = strdup(application.app_info.multiple().c_str());
525 service_app->taskmanage = strdup(application.app_info.taskmanage().c_str());
526 service_app->support_mode =
527 strdup((std::to_string(app_support_mode_val)).c_str());
528 service_app->autorestart =
529 strdup(application.app_info.auto_restart().c_str());
530 service_app->onboot = strdup(application.app_info.on_boot().c_str());
531 if (!application.app_info.type().empty())
532 service_app->type = strdup(application.app_info.type().c_str());
534 service_app->type = strdup("capp");
535 service_app->component_type = strdup("svcapp");
536 service_app->mainapp = strdup(application.app_info.mainapp().c_str());
537 service_app->nodisplay = strdup("true");
538 service_app->hwacceleration = strdup("default");
539 service_app->screenreader = strdup("use-system-setting");
540 service_app->recentimage = strdup("false");
541 service_app->launchcondition = strdup("false");
542 service_app->indicatordisplay = strdup("true");
543 service_app->effectimage_type = strdup("image");
544 service_app->guestmode_visibility = strdup("true");
545 service_app->permission_type = strdup("normal");
546 service_app->submode = strdup("false");
547 service_app->process_pool = strdup("false");
548 service_app->support_ambient = strdup("false");
549 service_app->package = strdup(manifest->package);
550 service_app->support_disable = strdup(manifest->support_disable);
551 service_app->launch_mode = strdup("single");
552 if (!application.app_info.api_version().empty())
553 service_app->api_version =
554 strdup(application.app_info.api_version().c_str());
556 service_app->api_version = strdup(manifest->api_version);
557 manifest->application = g_list_append(manifest->application, service_app);
558 if (bf::path(application.app_info.exec().c_str()).is_absolute())
559 service_app->exec = strdup(application.app_info.exec().c_str());
561 service_app->exec = strdup((context_->root_application_path.get()
562 / manifest->package / "bin"
563 / application.app_info.exec()).c_str());
565 if (!FillAppControl(service_app, application.app_control))
567 if (!FillDataControl(service_app, application.data_control))
569 if (!FillApplicationIconPaths(service_app, application.app_icons))
571 if (!FillLabel(service_app, application.label))
573 if (!FillMetadata(service_app, application.meta_data))
575 if (!FillCategories(service_app, application.categories))
577 if (!FillBackgroundCategoryInfo(service_app,
578 application.background_category))
580 if (!FillResControl(service_app, application.res_controls))
586 bool StepParseManifest::FillUIApplication(manifest_x* manifest) {
587 std::shared_ptr<const tpk::parse::UIApplicationInfoList> ui_application_list =
588 std::static_pointer_cast<const tpk::parse::UIApplicationInfoList>(
589 parser_->GetManifestData(app_keys::kUIApplicationKey));
590 if (!ui_application_list)
593 for (const auto& application : ui_application_list->items) {
594 int package_support_mode_val = atoi(manifest->support_mode);
595 int app_support_mode_val = package_support_mode_val |
596 GetSupportModeVal(application.app_info.support_mode());
598 application_x* ui_app =
599 static_cast<application_x*>(calloc(1, sizeof(application_x)));
601 LOG(ERROR) << "Out of memory";
604 ui_app->appid = strdup(application.app_info.appid().c_str());
605 ui_app->launch_mode = strdup(application.app_info.launch_mode().c_str());
606 ui_app->multiple = strdup(application.app_info.multiple().c_str());
607 ui_app->nodisplay = strdup(application.app_info.nodisplay().c_str());
608 ui_app->support_mode =
609 strdup((std::to_string(app_support_mode_val)).c_str());
610 ui_app->taskmanage = strdup(application.app_info.taskmanage().c_str());
611 if (!application.app_info.type().empty())
612 ui_app->type = strdup(application.app_info.type().c_str());
614 ui_app->type = strdup("capp");
615 ui_app->ui_gadget = strdup(application.app_info.uigadget().c_str());
616 ui_app->process_pool = strdup(application.app_info.process_pool().c_str());
617 ui_app->submode = strdup(application.app_info.submode().c_str());
618 if (!application.app_info.indicator_display().empty())
619 ui_app->indicatordisplay =
620 strdup(application.app_info.indicator_display().c_str());
621 if (!application.app_info.effectimage_type().empty())
622 ui_app->effectimage_type =
623 strdup(application.app_info.effectimage_type().c_str());
624 if (!application.app_info.portrait_image().empty()) {
625 ui_app->portraitimg =
626 strdup(application.app_info.portrait_image().c_str());
627 AppendSplashScreen(ui_app, application.app_info.portrait_image(),
628 application.app_info.effectimage_type(), {}, kPortraitOrientation,
629 application.app_info.indicator_display(), {}, {});
631 if (!application.app_info.landscape_image().empty()) {
632 ui_app->landscapeimg =
633 strdup(application.app_info.landscape_image().c_str());
634 AppendSplashScreen(ui_app, application.app_info.landscape_image(),
635 application.app_info.effectimage_type(), {}, kLandscapeOrientation,
636 application.app_info.indicator_display(), {}, {});
638 ui_app->submode_mainid =
639 strdup(application.app_info.submode_mainid().c_str());
640 ui_app->hwacceleration =
641 strdup(application.app_info.hwacceleration().c_str());
642 ui_app->onboot = strdup("false");
643 ui_app->autorestart = strdup("false");
644 ui_app->component_type = strdup("uiapp");
645 ui_app->mainapp = strdup(application.app_info.mainapp().c_str());
646 ui_app->screenreader = strdup("use-system-setting");
647 ui_app->recentimage = strdup("false");
648 ui_app->launchcondition = strdup("false");
649 ui_app->guestmode_visibility = strdup("true");
650 ui_app->permission_type = strdup("normal");
651 ui_app->support_ambient = strdup("false");
652 ui_app->package = strdup(manifest->package);
653 ui_app->support_disable = strdup(manifest->support_disable);
654 ui_app->splash_screen_display =
655 strdup(application.app_info.splash_screen_display().c_str());
656 if (!application.app_info.api_version().empty())
657 ui_app->api_version = strdup(application.app_info.api_version().c_str());
659 ui_app->api_version = strdup(manifest->api_version);
660 manifest->application = g_list_append(manifest->application, ui_app);
661 if (bf::path(application.app_info.exec().c_str()).is_absolute())
662 ui_app->exec = strdup(application.app_info.exec().c_str());
664 ui_app->exec = strdup((context_->root_application_path.get()
665 / manifest->package / "bin"
666 / application.app_info.exec()).c_str());
669 if (!FillAppControl(ui_app, application.app_control))
671 if (!FillDataControl(ui_app, application.data_control))
673 if (!FillApplicationIconPaths(ui_app, application.app_icons))
675 if (!FillLabel(ui_app, application.label))
677 if (!FillImage(ui_app, application.app_images))
679 if (!FillMetadata(ui_app, application.meta_data))
681 if (!FillCategories(ui_app, application.categories))
683 if (!FillBackgroundCategoryInfo(ui_app, application.background_category))
685 if (!FillSplashScreen(ui_app, application.app_splashscreens))
687 if (!FillResControl(ui_app, application.res_controls))
693 bool StepParseManifest::FillWatchApplication(manifest_x* manifest) {
694 auto watch_application_list =
695 std::static_pointer_cast<const tpk::parse::WatchApplicationInfoList>(
696 parser_->GetManifestData(app_keys::kWatchApplicationKey));
697 if (!watch_application_list)
700 for (const auto& watch_application : watch_application_list->items) {
701 int package_support_mode_val = atoi(manifest->support_mode);
702 int app_support_mode_val = package_support_mode_val |
703 GetSupportModeVal(watch_application.app_info.support_mode());
705 application_x* watch_app =
706 static_cast<application_x*>(calloc(1, sizeof(application_x)));
708 LOG(ERROR) << "Out of memory";
711 watch_app->appid = strdup(watch_application.app_info.appid().c_str());
713 if (bf::path(watch_application.app_info.exec().c_str()).is_absolute())
714 watch_app->exec = strdup(watch_application.app_info.exec().c_str());
716 watch_app->exec = strdup(
717 (context_->root_application_path.get()
718 / manifest->package / "bin" /
719 watch_application.app_info.exec()).c_str());
720 watch_app->nodisplay = strdup("true");
721 watch_app->multiple = strdup("false");
722 if (!watch_application.app_info.type().empty())
723 watch_app->type = strdup(watch_application.app_info.type().c_str());
725 watch_app->type = strdup("capp");
726 watch_app->taskmanage = strdup("false");
727 watch_app->hwacceleration = strdup("default");
728 watch_app->screenreader = strdup("use-system-setting");
729 watch_app->mainapp = strdup(watch_application.app_info.mainapp().c_str());
730 watch_app->recentimage = strdup("false");
731 watch_app->launchcondition = strdup("false");
732 watch_app->indicatordisplay = strdup("true");
733 watch_app->effectimage_type = strdup("image");
734 watch_app->guestmode_visibility = strdup("true");
735 watch_app->permission_type = strdup("normal");
736 watch_app->component_type = strdup("watchapp");
737 watch_app->preload = strdup("false");
738 watch_app->submode = strdup("false");
739 watch_app->process_pool = strdup("false");
740 watch_app->autorestart = strdup("false");
741 watch_app->onboot = strdup("false");
742 watch_app->support_mode =
743 strdup((std::to_string(app_support_mode_val)).c_str());
744 watch_app->ui_gadget = strdup("false");
745 watch_app->launch_mode = strdup("single");
746 if (!watch_application.app_info.api_version().empty())
747 watch_app->api_version =
748 strdup(watch_application.app_info.api_version().c_str());
750 watch_app->api_version = strdup(manifest->api_version);
751 watch_app->support_ambient =
752 strdup(watch_application.app_info.ambient_support().c_str());
753 watch_app->package = strdup(manifest->package);
754 if (!watch_application.app_info.setup_appid().empty())
755 watch_app->setup_appid =
756 strdup(watch_application.app_info.setup_appid().c_str());
757 manifest->application = g_list_append(manifest->application, watch_app);
759 if (!FillLabel(watch_app, watch_application.label))
761 if (!FillApplicationIconPaths(watch_app, watch_application.app_icons))
763 if (!FillMetadata(watch_app, watch_application.meta_data))
765 if (!FillCategories(watch_app, watch_application.categories))
767 if (!FillBackgroundCategoryInfo(watch_app,
768 watch_application.background_category))
770 if (!FillResControl(watch_app, watch_application.res_controls))
776 bool StepParseManifest::FillTrustAnchorInfo(manifest_x* manifest) {
777 std::shared_ptr<const tpk::parse::TrustAnchorInfo> trust_anchor_info =
778 std::static_pointer_cast<const tpk::parse::TrustAnchorInfo>(
779 parser_->GetManifestData(app_keys::kTrustAnchorKey));
780 if (!trust_anchor_info)
783 if (trust_anchor_info->get_use_system_certs().empty()) {
784 LOG(ERROR) << "Invalid trust anchor data";
788 manifest->use_system_certs =
789 strdup(trust_anchor_info->get_use_system_certs().c_str());
794 bool StepParseManifest::FillDependencyInfo(manifest_x* manifest) {
795 std::shared_ptr<const tpk::parse::DependenciesInfo> dependencies_info =
796 std::static_pointer_cast<const tpk::parse::DependenciesInfo>(
797 parser_->GetManifestData(app_keys::kDependenciesKey));
798 if (!dependencies_info)
801 for (const auto& dependency : dependencies_info->dependencies()) {
803 static_cast<dependency_x*>(calloc(1, sizeof(dependency_x)));
805 LOG(ERROR) << "Out of memory";
808 dep->depends_on = strdup(dependency.pkgid().c_str());
809 dep->type = strdup(dependency.type().c_str());
810 if (!dependency.required_version().empty())
811 dep->required_version = strdup(dependency.required_version().c_str());
812 manifest->dependencies = g_list_append(manifest->dependencies, dep);
818 bool StepParseManifest::FillLightUserInfo(manifest_x* manifest) {
819 std::shared_ptr<const tpk::parse::LightUserInfo> light_user_info =
820 std::static_pointer_cast<const tpk::parse::LightUserInfo>(
821 parser_->GetManifestData(tpk::parse::LightUserInfo::Key()));
822 if (!light_user_info) {
823 manifest->light_user_switch_mode = strdup("default");
827 if (light_user_info->switch_mode().empty()) {
828 LOG(ERROR) << "Invalid switch mode";
832 manifest->light_user_switch_mode =
833 strdup(light_user_info->switch_mode().c_str());
838 bool StepParseManifest::CheckFeatures() {
840 std::static_pointer_cast<const tpk::parse::FeatureInfo>(
841 parser_->GetManifestData(tpk::parse::FeatureInfo::Key()));
846 FeatureValidator validator(feature_info->features());
847 if (!validator.Validate(&error)) {
848 LOG(ERROR) << "Feature validation error. " << error;
855 template <typename T>
856 bool StepParseManifest::FillAppControl(application_x* app,
857 const T& app_control_list) {
858 if (app_control_list.empty())
861 for (const auto& control : app_control_list) {
862 appcontrol_x* app_control =
863 static_cast<appcontrol_x*>(calloc(1, sizeof(appcontrol_x)));
865 LOG(ERROR) << "Out of memory";
868 app_control->operation = strdup(control.operation().c_str());
869 if (!control.mime().empty())
870 app_control->mime = strdup(control.mime().c_str());
871 if (!control.uri().empty())
872 app_control->uri = strdup(control.uri().c_str());
873 if (!control.visibility().empty())
874 app_control->visibility = strdup(control.visibility().c_str());
876 app_control->visibility = strdup("local-only");
877 if (!control.id().empty())
878 app_control->id = strdup(control.id().c_str());
880 app_control->id = strdup("no-name-app-control");
881 for (const auto& priv : control.privileges()) {
882 app_control->privileges = g_list_append(app_control->privileges,
883 strdup(priv.c_str()));
885 app->appcontrol = g_list_append(app->appcontrol, app_control);
890 template <typename T>
891 bool StepParseManifest::FillDataControl(application_x* app,
892 const T& data_control_list) {
893 if (data_control_list.empty())
896 for (const auto& control : data_control_list) {
897 datacontrol_x* data_control =
898 static_cast<datacontrol_x*>(calloc(1, sizeof(datacontrol_x)));
900 LOG(ERROR) << "Out of memory";
903 data_control->access = strdup(control.access().c_str());
904 data_control->providerid = strdup(control.providerid().c_str());
905 data_control->type = strdup(control.type().c_str());
906 if (!control.trusted().empty())
907 data_control->trusted = strdup(control.trusted().c_str());
909 data_control->trusted = strdup("false");
910 for (const auto& priv : control.privileges())
911 data_control->privileges = g_list_append(data_control->privileges,
912 strdup(priv.c_str()));
914 app->datacontrol = g_list_append(app->datacontrol, data_control);
919 template <typename T>
920 bool StepParseManifest::FillApplicationIconPaths(application_x* app,
921 const T& icons_info) {
922 for (auto& application_icon : icons_info.icons()) {
923 icon_x* icon = reinterpret_cast<icon_x*>(calloc(1, sizeof(icon_x)));
925 LOG(ERROR) << "Out of memory";
929 if (bf::path(application_icon.path()).is_absolute()) {
930 text = application_icon.path();
932 text = context_->root_application_path.get()
933 / context_->pkgid.get() / "shared" / "res" / application_icon.path();
935 // NOTE: name is an attribute, but the xml writer uses it as text.
936 // This must be fixed in whole app-installer modules, including wgt.
937 // Current implementation is just for compatibility.
938 icon->text = strdup(text.c_str());
939 if (application_icon.lang().empty())
940 icon->lang = strdup(DEFAULT_LOCALE);
942 icon->lang = strdup(application_icon.lang().c_str());
944 if (!application_icon.dpi().empty())
945 icon->dpi = strdup(application_icon.dpi().c_str());
946 app->icon = g_list_append(app->icon, icon);
951 template <typename T>
952 bool StepParseManifest::FillLabel(application_x* app, const T& label_list) {
953 if (label_list.empty())
956 for (const auto& control : label_list) {
958 static_cast<label_x*>(calloc(1, sizeof(label_x)));
960 LOG(ERROR) << "Out of memory";
963 // NOTE: name is an attribute, but the xml writer uses it as text.
964 // This must be fixed in whole app-installer modules, including wgt.
965 // Current implementation is just for compatibility.
966 label->text = strdup(control.text().c_str());
967 label->name = strdup(control.name().c_str());
968 label->lang = !control.xml_lang().empty() ?
969 strdup(control.xml_lang().c_str()) : strdup(DEFAULT_LOCALE);
970 app->label = g_list_append(app->label, label);
975 template <typename T>
976 bool StepParseManifest::FillMetadata(application_x* app,
977 const T& meta_data_list) {
978 if (meta_data_list.empty())
981 for (auto& meta : meta_data_list) {
982 metadata_x* metadata =
983 static_cast<metadata_x*>(calloc(1, sizeof(metadata_x)));
985 LOG(ERROR) << "Out of memory";
988 metadata->key = strdup(meta.key().c_str());
989 metadata->value = strdup(meta.val().c_str());
990 app->metadata = g_list_append(app->metadata, metadata);
992 GetLegacySplashScreenFromMetadata(app, meta.key(), meta.val());
997 template <typename T>
998 bool StepParseManifest::FillCategories(application_x* manifest,
999 const T& categories) {
1000 for (auto& category : categories) {
1001 manifest->category = g_list_append(manifest->category,
1002 strdup(category.c_str()));
1007 void StepParseManifest::AppendSplashScreen(application_x* app,
1008 const std::string& src, const std::string& type, const std::string& dpi,
1009 const std::string& orientation, const std::string& indicatordisplay,
1010 const std::string& operation, const std::string& color_depth) {
1011 splashscreen_x* splashscreen =
1012 static_cast<splashscreen_x*>(calloc(1, sizeof(splashscreen_x)));
1013 if (!splashscreen) {
1014 LOG(ERROR) << "Out of memory";
1017 if (bf::path(src).is_absolute()) {
1018 splashscreen->src = strdup(src.c_str());
1020 bf::path full_path = context_->GetPkgPath() / src;
1021 splashscreen->src = strdup(full_path.string().c_str());
1023 if (src.substr(src.find_last_of(".") + 1) == "edj")
1024 splashscreen->type = strdup("edj");
1025 else if (type == "edj")
1026 splashscreen->type = strdup("edj");
1028 splashscreen->type = strdup("img");
1030 splashscreen->dpi = strdup(dpi.c_str());
1031 splashscreen->orientation = strdup(orientation.c_str());
1032 if (!indicatordisplay.empty())
1033 splashscreen->indicatordisplay = strdup(indicatordisplay.c_str());
1035 splashscreen->indicatordisplay = strdup("true");
1036 if (operation == "launch_effect")
1037 splashscreen->operation = strdup("launch-effect");
1038 else if (!operation.empty())
1039 splashscreen->operation = strdup(operation.c_str());
1041 splashscreen->operation = strdup("launch-effect");
1042 if (!color_depth.empty())
1043 splashscreen->color_depth = strdup(color_depth.c_str());
1045 splashscreen->color_depth = strdup("24");
1046 app->splashscreens = g_list_append(app->splashscreens, splashscreen);
1049 template <typename T>
1050 bool StepParseManifest::FillSplashScreen(application_x* app,
1051 const T& splashscreens_info) {
1052 for (auto& splash_screen : splashscreens_info.splashscreens()) {
1054 if (context_->is_readonly_package.get())
1055 src = splash_screen.src();
1057 src = bf::path(context_->root_application_path.get()
1058 / app->package / "shared" / "res" / splash_screen.src()).string();
1060 AppendSplashScreen(app, src, splash_screen.type(), splash_screen.dpi(),
1061 splash_screen.orientation(), splash_screen.indicatordisplay(),
1062 splash_screen.operation(), splash_screen.colordepth());
1067 template <typename T>
1068 bool StepParseManifest::FillResControl(application_x* app,
1069 const T& res_control_list) {
1070 for (auto& res_control : res_control_list) {
1071 if (res_control.resource_type().empty())
1075 static_cast<res_control_x*>(calloc(1, sizeof(res_control_x)));
1077 LOG(ERROR) << "Out of memory";
1081 rc->res_type = strdup(res_control.resource_type().c_str());
1082 if (!res_control.min_res_version().empty())
1083 rc->min_res_version = strdup(res_control.min_res_version().c_str());
1084 if (!res_control.max_res_version().empty())
1085 rc->max_res_version = strdup(res_control.max_res_version().c_str());
1086 if (!res_control.auto_close().empty())
1087 rc->auto_close = strdup(res_control.auto_close().c_str());
1089 app->res_control = g_list_prepend(app->res_control, rc);
1094 void StepParseManifest::GetLegacySplashScreenFromMetadata(application_x* app,
1095 const std::string& key, const std::string& val) {
1096 std::string operation;
1097 if (key.find(kOperationEffectKey) != std::string::npos) {
1098 boost::char_separator<char> sep("=");
1099 boost::tokenizer<boost::char_separator<char>> tokens(key, sep);
1100 auto iter = tokens.begin();
1103 } else if (key.find(kLaunchEffectKey) != std::string::npos) {
1104 operation = std::string("launch-effect");
1106 // not a metadata splashscreen
1110 boost::char_separator<char> sep("=|");
1111 boost::tokenizer<boost::char_separator<char>> tokens(val, sep);
1112 auto iter = tokens.begin();
1113 std::string portrait_src;
1114 std::string landscape_src;
1115 std::string indicatordisplay;
1116 while (iter != tokens.end()) {
1117 if (!(*iter).compare(kPortraitEffectImageValue)) {
1119 portrait_src = *iter;
1120 } else if (!(*iter).compare(kLandscapeEffectImageValue)) {
1122 landscape_src = *iter;
1123 } else if (!(*iter).compare(kIndicatorDisplayValue)) {
1125 indicatordisplay = *iter;
1129 if (!portrait_src.empty())
1130 AppendSplashScreen(app, portrait_src, {}, {}, kPortraitOrientation,
1131 indicatordisplay, operation, {});
1132 if (!landscape_src.empty())
1133 AppendSplashScreen(app, landscape_src, {}, {}, kLandscapeOrientation,
1134 indicatordisplay, operation, {});
1137 bool StepParseManifest::FillImage(application_x* app,
1138 const tpk::parse::ApplicationImagesInfo& image_list) {
1139 for (auto& app_image : image_list.images) {
1141 static_cast<image_x*>(calloc(1, sizeof(image_x)));
1143 LOG(ERROR) << "Out of memory";
1146 const std::string& lang = app_image.lang();
1148 image->lang = strdup(lang.c_str());
1150 image->lang = strdup(DEFAULT_LOCALE);
1151 if (!app_image.section().empty())
1152 image->section = strdup(app_image.section().c_str());
1153 app->image = g_list_append(app->image, image);
1158 template <typename T>
1159 bool StepParseManifest::FillBackgroundCategoryInfo(application_x* app,
1160 const T& background_category_data_list) {
1161 for (const auto& background_category : background_category_data_list) {
1162 app->background_category = g_list_append(
1163 app->background_category, strdup(background_category.value().c_str()));
1169 bool StepParseManifest::FillExtraInfo(manifest_x* manifest) {
1170 if (manifest_location_ == ManifestLocation::INSTALLED) {
1171 // recovery of tep value for installed package
1172 PkgQueryInterface pkg_query(context_->pkgid.get(), context_->uid.get());
1173 std::string old_tep = pkg_query.TepPath();
1174 if (!old_tep.empty())
1175 manifest->tep_name = strdup(old_tep.c_str());
1177 // recovery of zip mount file for installed package
1178 std::string zip_mount_file = pkg_query.ZipMountFile();
1179 if (!zip_mount_file.empty())
1180 manifest->zip_mount_file = strdup(zip_mount_file.c_str());
1183 if (manifest->application == nullptr)
1186 // in case of hybrid package, main app is already set by wgt-backend
1187 application_x* mainapp = nullptr;
1188 if (!context_->cross_app_rules.get()) {
1190 for (const auto& app : GListRange<application_x*>(manifest->application)) {
1191 if (!strcmp(app->mainapp, "true")) {
1196 if (mainapp == nullptr)
1197 mainapp = reinterpret_cast<application_x*>(
1198 g_list_first(manifest->application)->data);
1199 free(mainapp->mainapp);
1200 mainapp->mainapp = strdup("true");
1201 manifest->mainapp_id = strdup(mainapp->appid);
1204 // mark mainapp=false at other apps
1205 for (auto& app : GListRange<application_x*>(manifest->application)) {
1209 app->mainapp = strdup("false");
1214 bool StepParseManifest::FillComponentBasedApplicationInfo(
1215 manifest_x* manifest) {
1216 std::shared_ptr<const tpk::parse::ComponentBasedApplicationInfoList>
1217 component_based_application_list = std::static_pointer_cast<
1218 const tpk::parse::ComponentBasedApplicationInfoList>(
1219 parser_->GetManifestData(
1220 app_keys::kComponentBasedApplicationKey));
1221 if (!component_based_application_list)
1224 for (const auto& application : component_based_application_list->items) {
1225 int package_support_mode_val = atoi(manifest->support_mode);
1226 int app_support_mode_val = package_support_mode_val |
1227 GetSupportModeVal(application.app_info.support_mode());
1229 application_x* app =
1230 static_cast<application_x*>(calloc(1, sizeof(application_x)));
1232 LOG(ERROR) << "Out of memory";
1236 app->appid = strdup(application.app_info.appid().c_str());
1237 app->launch_mode = strdup(application.app_info.launch_mode().c_str());
1238 app->multiple = strdup(application.app_info.multiple().c_str());
1239 app->nodisplay = strdup(application.app_info.nodisplay().c_str());
1240 app->support_mode = strdup((std::to_string(app_support_mode_val)).c_str());
1241 app->taskmanage = strdup(application.app_info.taskmanage().c_str());
1242 if (!application.app_info.type().empty())
1243 app->type = strdup(application.app_info.type().c_str());
1245 app->type = strdup("c++app");
1246 app->indicatordisplay =
1247 strdup(application.app_info.indicator_display().c_str());
1248 app->component_type = strdup("componentbasedapp");
1249 app->hwacceleration = strdup(application.app_info.hwacceleration().c_str());
1250 app->onboot = strdup("false");
1251 app->autorestart = strdup("false");
1252 app->mainapp = strdup(application.app_info.mainapp().c_str());
1253 app->screenreader = strdup("use-system-setting");
1254 app->recentimage = strdup("false");
1255 app->launchcondition = strdup("false");
1256 app->guestmode_visibility = strdup("true");
1257 app->permission_type = strdup("normal");
1258 app->support_ambient = strdup("false");
1259 app->effectimage_type = strdup("image");
1260 app->submode = strdup("false");
1261 app->process_pool = strdup("false");
1262 app->package = strdup(manifest->package);
1263 app->support_disable = strdup(manifest->support_disable);
1264 app->launch_mode = strdup("single");
1265 if (!application.app_info.api_version().empty())
1266 app->api_version = strdup(application.app_info.api_version().c_str());
1268 app->api_version = strdup(manifest->api_version);
1269 app->splash_screen_display =
1270 strdup(application.app_info.splash_screen_display().c_str());
1271 manifest->application = g_list_append(manifest->application, app);
1272 if (bf::path(application.app_info.exec().c_str()).is_absolute()) {
1273 app->exec = strdup(application.app_info.exec().c_str());
1275 app->exec = strdup((context_->root_application_path.get()
1276 / manifest->package / "bin"
1277 / application.app_info.exec()).c_str());
1279 if (!FillLabel(app, application.label))
1281 if (!FillImage(app, application.app_images))
1283 if (!FillBackgroundCategoryInfo(app, application.background_category))
1285 if (!FillAppControl(app, application.app_control))
1287 if (!FillDataControl(app, application.data_control))
1289 if (!FillMetadata(app, application.meta_data))
1291 if (!FillCategories(app, application.categories))
1293 if (!FillSplashScreen(app, application.app_splashscreens))
1295 if (!FillResControl(app, application.res_controls))
1302 bool StepParseManifest::FillManifestX(manifest_x* manifest) {
1303 if (!FillPackageInfo(manifest))
1305 if (!FillInstallationInfo(manifest))
1307 if (!FillUIApplication(manifest))
1309 if (!FillServiceApplication(manifest))
1311 if (!FillWidgetApplication(manifest))
1313 if (!FillWatchApplication(manifest))
1315 if (!FillComponentBasedApplicationInfo(manifest))
1317 if (!FillPrivileges(manifest))
1319 if (!FillProvidesAppDefinedPrivileges(manifest))
1321 if (!FillAuthorInfo(manifest))
1323 if (!FillDescriptionInfo(manifest))
1325 if (!FillExtraInfo(manifest))
1327 if (!FillTrustAnchorInfo(manifest))
1329 if (!FillDependencyInfo(manifest))
1331 if (!FillLightUserInfo(manifest))
1336 Step::Status StepParseManifest::process() {
1337 if (context_->force_clean_from_db.get())
1338 return Step::Status::OK;
1339 if (!LocateConfigFile()) {
1340 // continue if this is recovery, manifest file may never been created
1341 if (manifest_location_ == ManifestLocation::RECOVERY) {
1342 LOG(DEBUG) << "Manifest for recovery not found";
1343 return Step::Status::OK;
1345 LOG(ERROR) << "No manifest file exists";
1346 return Step::Status::MANIFEST_NOT_FOUND;
1348 parser_.reset(new tpk::parse::TPKConfigParser());
1349 if (!parser_->ParseManifest(path_)) {
1350 if (manifest_location_ == ManifestLocation::RECOVERY) {
1351 LOG(DEBUG) << "Manifest for recovery is invalid";
1353 return Step::Status::OK;
1355 LOG(ERROR) << "[Parse] Parse failed. " << parser_->GetErrorMessage();
1356 return Step::Status::PARSE_ERROR;
1359 // Copy data from ManifestData to InstallerContext
1360 std::shared_ptr<const tpk::parse::PackageInfo> info =
1361 std::static_pointer_cast<const tpk::parse::PackageInfo>(
1362 parser_->GetManifestData(app_keys::kManifestKey));
1364 context_->pkgid.set(info->package());
1366 manifest_x* manifest =
1367 static_cast<manifest_x*>(calloc(1, sizeof(manifest_x)));
1369 LOG(ERROR) << "Out of memory";
1370 return Step::Status::ERROR;
1373 if (!FillManifestX(const_cast<manifest_x*>(manifest))) {
1374 LOG(ERROR) << "[Parse] Storing manifest_x failed. "
1375 << parser_->GetErrorMessage();
1376 pkgmgr_parser_free_manifest_xml(manifest);
1377 return Step::Status::PARSE_ERROR;
1380 // write pkgid for recovery file
1381 if (context_->recovery_info.get().recovery_file) {
1382 context_->recovery_info.get().recovery_file->set_pkgid(manifest->package);
1383 context_->recovery_info.get().recovery_file->WriteAndCommitFileContent();
1386 LOG(INFO) << "Parsed package id: " << info->package();
1388 switch (store_location_) {
1389 case StoreLocation::NORMAL:
1390 context_->manifest_data.set(manifest);
1392 case StoreLocation::BACKUP:
1393 context_->old_manifest_data.set(manifest);
1396 LOG(ERROR) << "Unknown store location for parsed data";
1397 return Step::Status::ERROR;
1399 return Step::Status::OK;
1402 } // namespace configuration
1403 } // namespace common_installer