#include "common/step/configuration/step_parse_manifest.h"
-#include <boost/tokenizer.hpp>
-
#include <pkgmgr/pkgmgr_parser.h>
#include <pkgmgr-info.h>
#include <tpk_manifest_handlers/dependencies_handler.h>
#include <tpk_manifest_handlers/description_handler.h>
#include <tpk_manifest_handlers/feature_handler.h>
+#include <tpk_manifest_handlers/light_user_handler.h>
#include <tpk_manifest_handlers/package_handler.h>
#include <tpk_manifest_handlers/privileges_handler.h>
#include <tpk_manifest_handlers/profile_handler.h>
#include <tpk_manifest_handlers/provides_appdefined_privileges_handler.h>
+#include <tpk_manifest_handlers/robot_application_handler.h>
#include <tpk_manifest_handlers/service_application_handler.h>
#include <tpk_manifest_handlers/shortcut_handler.h>
#include <tpk_manifest_handlers/trust_anchor_handler.h>
#include <tpk_manifest_handlers/watch_application_handler.h>
#include <tpk_manifest_handlers/widget_application_handler.h>
-#include <chrono>
#include <cstdio>
#include <cstdlib>
#include <cstring>
+#include <filesystem>
#include <memory>
+#include <regex>
#include <set>
#include <type_traits>
#include <string>
#include "common/utils/pkgmgr_query.h"
#include "common/step/step.h"
#include "common/utils/glist_range.h"
+#include "common/utils/time_util.h"
namespace app_keys = tpk::application_keys;
-namespace bf = boost::filesystem;
+namespace fs = std::filesystem;
namespace {
}
bool StepParseManifest::LocateConfigFile() {
- boost::filesystem::path manifest;
+ std::filesystem::path manifest;
switch (manifest_location_) {
case ManifestLocation::RECOVERY: {
- bf::path backup_path = common_installer::GetBackupPathForPackagePath(
+ fs::path backup_path = common_installer::GetBackupPathForPackagePath(
context_->GetPkgPath()) / kManifestFileName;
- bf::path in_package_path = context_->GetPkgPath() / kManifestFileName;
- bf::path install_path =
- bf::path(getUserManifestPath(context_->uid.get(),
+ fs::path in_package_path = context_->GetPkgPath() / kManifestFileName;
+ fs::path install_path =
+ fs::path(getUserManifestPath(context_->uid.get(),
context_->is_readonly_package.get()))
- / bf::path(context_->pkgid.get());
+ / fs::path(context_->pkgid.get());
install_path += ".xml";
- bf::path backup_install_path =
+ fs::path backup_install_path =
common_installer::GetBackupPathForManifestFile(install_path);
- if (bf::exists(backup_install_path))
+ if (fs::exists(backup_install_path))
manifest = backup_install_path;
- else if (bf::exists(backup_path))
+ else if (fs::exists(backup_path))
manifest = backup_path;
- else if (bf::exists(install_path))
+ else if (fs::exists(install_path))
manifest = install_path;
- else if (bf::exists(in_package_path))
+ else if (fs::exists(in_package_path))
manifest = in_package_path;
break;
}
uid = tzplatform_getuid(TZ_SYS_GLOBALAPP_USER);
else
uid = context_->uid.get();
- bf::path xml_path =
- bf::path(getUserManifestPath(uid, is_readonly))
- / bf::path(context_->pkgid.get());
+ fs::path xml_path =
+ fs::path(getUserManifestPath(uid, is_readonly))
+ / fs::path(context_->pkgid.get());
xml_path += ".xml";
context_->xml_path.set(xml_path);
manifest = context_->xml_path.get();
- if (!boost::filesystem::exists(manifest)) {
+ if (!std::filesystem::exists(manifest)) {
/* This routine has added for platform update */
manifest = context_->unpacked_dir_path.get();
manifest /= kManifestFileName;
LOG(DEBUG) << "manifest path: " << manifest;
- if (!boost::filesystem::exists(manifest))
+ if (!std::filesystem::exists(manifest))
return false;
path_ = manifest;
bool StepParseManifest::FillInstallationInfo(manifest_x* manifest) {
manifest->root_path = strdup(
(context_->root_application_path.get() / manifest->package).c_str());
- manifest->installed_time =
- strdup(std::to_string(std::chrono::system_clock::to_time_t(
- std::chrono::system_clock::now())).c_str());
+ manifest->installed_time = strdup(GetCurrentTime().c_str());
return true;
}
}
// retrieve and set plugin execution info if exists
- if (manifest_location_ == ManifestLocation::INSTALLED ||
- manifest_location_ == ManifestLocation::RECOVERY) {
+ if (store_location_ == StoreLocation::BACKUP && (
+ manifest_location_ == ManifestLocation::INSTALLED ||
+ manifest_location_ == ManifestLocation::RECOVERY)) {
std::vector<PkgQueryInterface::PluginInfo> plugin_list;
pkg_query.PluginExecutionInfo(&plugin_list);
privilege->value = strdup(priv.privilege.c_str());
privilege->type = strdup(priv.type.c_str());
if (!priv.license.empty()) {
- if (bf::path(priv.license).is_absolute())
+ if (fs::path(priv.license).is_absolute())
privilege->license = strdup(priv.license.c_str());
else
privilege->license = strdup((context_->GetPkgPath()
privilege->value = strdup(priv.privilege.c_str());
privilege->type = strdup(priv.type.c_str());
if (!priv.license.empty()) {
- if (bf::path(priv.license).is_absolute())
+ if (fs::path(priv.license).is_absolute())
privilege->license = strdup(priv.license.c_str());
else
privilege->license = strdup((context_->GetPkgPath()
else
widget_app->api_version = strdup(manifest->api_version);
manifest->application = g_list_append(manifest->application, widget_app);
- if (bf::path(application.app_info.exec().c_str()).is_absolute())
+ if (fs::path(application.app_info.exec().c_str()).is_absolute())
widget_app->exec = strdup(application.app_info.exec().c_str());
else
widget_app->exec = strdup((context_->root_application_path.get()
else
service_app->api_version = strdup(manifest->api_version);
manifest->application = g_list_append(manifest->application, service_app);
- if (bf::path(application.app_info.exec().c_str()).is_absolute())
+ if (fs::path(application.app_info.exec().c_str()).is_absolute())
service_app->exec = strdup(application.app_info.exec().c_str());
else
service_app->exec = strdup((context_->root_application_path.get()
else
ui_app->api_version = strdup(manifest->api_version);
manifest->application = g_list_append(manifest->application, ui_app);
- if (bf::path(application.app_info.exec().c_str()).is_absolute())
+ if (fs::path(application.app_info.exec().c_str()).is_absolute())
ui_app->exec = strdup(application.app_info.exec().c_str());
else
ui_app->exec = strdup((context_->root_application_path.get()
}
watch_app->appid = strdup(watch_application.app_info.appid().c_str());
- if (bf::path(watch_application.app_info.exec().c_str()).is_absolute())
+ if (fs::path(watch_application.app_info.exec().c_str()).is_absolute())
watch_app->exec = strdup(watch_application.app_info.exec().c_str());
else
watch_app->exec = strdup(
if (!watch_application.app_info.setup_appid().empty())
watch_app->setup_appid =
strdup(watch_application.app_info.setup_appid().c_str());
+ manifest->application = g_list_append(manifest->application, watch_app);
if (!FillLabel(watch_app, watch_application.label))
return false;
return false;
if (!FillResControl(watch_app, watch_application.res_controls))
return false;
- manifest->application = g_list_append(manifest->application, watch_app);
}
return true;
}
return true;
}
+bool StepParseManifest::FillLightUserInfo(manifest_x* manifest) {
+ std::shared_ptr<const tpk::parse::LightUserInfo> light_user_info =
+ std::static_pointer_cast<const tpk::parse::LightUserInfo>(
+ parser_->GetManifestData(tpk::parse::LightUserInfo::Key()));
+ if (!light_user_info) {
+ manifest->light_user_switch_mode = strdup("default");
+ return true;
+ }
+
+ if (light_user_info->switch_mode().empty()) {
+ LOG(ERROR) << "Invalid switch mode";
+ return false;
+ }
+
+ manifest->light_user_switch_mode =
+ strdup(light_user_info->switch_mode().c_str());
+
+ return true;
+}
+
bool StepParseManifest::CheckFeatures() {
auto feature_info =
std::static_pointer_cast<const tpk::parse::FeatureInfo>(
LOG(ERROR) << "Out of memory";
return false;
}
- bf::path text;
- if (bf::path(application_icon.path()).is_absolute()) {
+ fs::path text;
+ if (fs::path(application_icon.path()).is_absolute()) {
text = application_icon.path();
} else {
text = context_->root_application_path.get()
LOG(ERROR) << "Out of memory";
return;
}
- if (bf::path(src).is_absolute()) {
+ if (fs::path(src).is_absolute()) {
splashscreen->src = strdup(src.c_str());
} else {
- bf::path full_path = context_->GetPkgPath() / src;
- splashscreen->src = strdup(full_path.string().c_str());
+ fs::path full_path = context_->GetPkgPath() / src;
+ splashscreen->src = strdup(full_path.c_str());
}
if (src.substr(src.find_last_of(".") + 1) == "edj")
splashscreen->type = strdup("edj");
if (context_->is_readonly_package.get())
src = splash_screen.src();
else
- src = bf::path(context_->root_application_path.get()
+ src = fs::path(context_->root_application_path.get()
/ app->package / "shared" / "res" / splash_screen.src()).string();
AppendSplashScreen(app, src, splash_screen.type(), splash_screen.dpi(),
void StepParseManifest::GetLegacySplashScreenFromMetadata(application_x* app,
const std::string& key, const std::string& val) {
std::string operation;
- if (key.find(kOperationEffectKey) != std::string::npos) {
- boost::char_separator<char> sep("=");
- boost::tokenizer<boost::char_separator<char>> tokens(key, sep);
- auto iter = tokens.begin();
- iter++;
- operation = *iter;
+ auto pos = key.find(kOperationEffectKey);
+ if (pos != std::string::npos) {
+ operation = key.substr(pos + 1, key.size());
} else if (key.find(kLaunchEffectKey) != std::string::npos) {
operation = std::string("launch-effect");
} else {
return;
}
- boost::char_separator<char> sep("=|");
- boost::tokenizer<boost::char_separator<char>> tokens(val, sep);
- auto iter = tokens.begin();
std::string portrait_src;
std::string landscape_src;
std::string indicatordisplay;
- while (iter != tokens.end()) {
- if (!(*iter).compare(kPortraitEffectImageValue)) {
- iter++;
- portrait_src = *iter;
- } else if (!(*iter).compare(kLandscapeEffectImageValue)) {
- iter++;
- landscape_src = *iter;
- } else if (!(*iter).compare(kIndicatorDisplayValue)) {
- iter++;
- indicatordisplay = *iter;
- }
- iter++;
+
+ std::regex re("[=|]");
+ std::sregex_token_iterator first(val.begin(), val.end(), re, -1);
+ std::sregex_token_iterator last;
+ std::vector<std::string> tokens(first, last);
+ for (const auto& t : tokens) {
+ if (t.compare(kPortraitEffectImageValue))
+ portrait_src = t;
+ else if (t.compare(kLandscapeEffectImageValue))
+ landscape_src = t;
+ else if (t.compare(kIndicatorDisplayValue))
+ indicatordisplay = t;
}
+
if (!portrait_src.empty())
AppendSplashScreen(app, portrait_src, {}, {}, kPortraitOrientation,
indicatordisplay, operation, {});
app->splash_screen_display =
strdup(application.app_info.splash_screen_display().c_str());
manifest->application = g_list_append(manifest->application, app);
- if (bf::path(application.app_info.exec().c_str()).is_absolute()) {
+ if (fs::path(application.app_info.exec().c_str()).is_absolute()) {
app->exec = strdup(application.app_info.exec().c_str());
} else {
app->exec = strdup((context_->root_application_path.get()
return true;
}
+bool StepParseManifest::FillRobotApplicationInfo(
+ manifest_x* manifest) {
+ std::shared_ptr<const tpk::parse::RobotApplicationInfoList>
+ robot_application_list = std::static_pointer_cast<
+ const tpk::parse::RobotApplicationInfoList>(
+ parser_->GetManifestData(
+ app_keys::kRobotApplicationKey));
+ if (!robot_application_list)
+ return true;
+
+ for (const auto& application : robot_application_list->items) {
+ int package_support_mode_val = atoi(manifest->support_mode);
+ int app_support_mode_val = package_support_mode_val |
+ GetSupportModeVal(application.app_info.support_mode());
+
+ application_x* app =
+ static_cast<application_x*>(calloc(1, sizeof(application_x)));
+ if (!app) {
+ LOG(ERROR) << "Out of memory";
+ return false;
+ }
+
+ app->appid = strdup(application.app_info.appid().c_str());
+ app->multiple = strdup("false");
+ app->nodisplay = strdup("false");
+ app->support_mode = strdup((std::to_string(app_support_mode_val)).c_str());
+ app->taskmanage = strdup("false");
+ if (!application.app_info.type().empty())
+ app->type = strdup(application.app_info.type().c_str());
+ else
+ app->type = strdup("robotapp");
+ app->indicatordisplay = strdup("false");
+ app->component_type = strdup("robotapp");
+ app->hwacceleration = strdup("default");
+ app->onboot = strdup("false");
+ app->autorestart = strdup("false");
+ app->mainapp = strdup(application.app_info.mainapp().c_str());
+ app->screenreader = strdup("use-system-setting");
+ app->recentimage = strdup("false");
+ app->launchcondition = strdup("false");
+ app->guestmode_visibility = strdup("true");
+ app->permission_type = strdup("normal");
+ app->support_ambient = strdup("false");
+ app->effectimage_type = strdup("image");
+ app->submode = strdup("false");
+ app->process_pool = strdup("false");
+ app->package = strdup(manifest->package);
+ app->support_disable = strdup(manifest->support_disable);
+ app->launch_mode = strdup("single");
+ if (!application.app_info.api_version().empty())
+ app->api_version = strdup(application.app_info.api_version().c_str());
+ else
+ app->api_version = strdup(manifest->api_version);
+ manifest->application = g_list_append(manifest->application, app);
+ if (fs::path(application.app_info.exec().c_str()).is_absolute()) {
+ app->exec = strdup(application.app_info.exec().c_str());
+ } else {
+ app->exec = strdup((context_->root_application_path.get()
+ / manifest->package / "bin"
+ / application.app_info.exec()).c_str());
+ }
+ if (!FillLabel(app, application.label))
+ return false;
+ if (!FillMetadata(app, application.meta_data))
+ return false;
+ if (!FillResControl(app, application.res_controls))
+ return false;
+ }
+
+ return true;
+}
+
bool StepParseManifest::FillManifestX(manifest_x* manifest) {
if (!FillPackageInfo(manifest))
return false;
return false;
if (!FillComponentBasedApplicationInfo(manifest))
return false;
+ if (!FillRobotApplicationInfo(manifest))
+ return false;
if (!FillPrivileges(manifest))
return false;
if (!FillProvidesAppDefinedPrivileges(manifest))
return false;
if (!FillDependencyInfo(manifest))
return false;
+ if (!FillLightUserInfo(manifest))
+ return false;
return true;
}
if (!parser_->ParseManifest(path_)) {
if (manifest_location_ == ManifestLocation::RECOVERY) {
LOG(DEBUG) << "Manifest for recovery is invalid";
- bf::remove(path_);
+ fs::remove(path_);
return Step::Status::OK;
}
LOG(ERROR) << "[Parse] Parse failed. " << parser_->GetErrorMessage();