From c2fd87783a4f43f8e11f0bfb5f5144b737cb0e55 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Wed, 24 May 2017 14:38:17 +0900 Subject: [PATCH 01/16] Fix crash when parsing icon info from wgt archive Change-Id: Ifa4866a495af0764be72eb4e5d68d016642b931f Signed-off-by: Sangyoon Jang --- src/lib/wgt_archive_info.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/wgt_archive_info.cc b/src/lib/wgt_archive_info.cc index eb508e1..205ba5f 100644 --- a/src/lib/wgt_archive_info.cc +++ b/src/lib/wgt_archive_info.cc @@ -164,7 +164,7 @@ std::string GetIconInfo(const wgt::parse::WidgetConfigParser& parser) { auto icons_info = std::static_pointer_cast( parser.GetManifestData(wgt::parse::ApplicationIconsInfo::Key())); - if (!icons_info) + if (!icons_info || icons_info->icons().empty()) return {}; return std::string(icons_info->icons().front().path()); -- 2.7.4 From fef5e9e1ee8396fb3413d4cc2523c202dfe61f43 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Mon, 22 May 2017 10:43:28 +0900 Subject: [PATCH 02/16] Add update step of directories - shared/data directory of package should be created/removed when updating hybrid pkg Change-Id: Ib3f7bd0091f79d42472cc505c5bcf7ad96f69875 Signed-off-by: Junghyun Yeon --- src/hybrid/hybrid_installer.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/hybrid/hybrid_installer.cc b/src/hybrid/hybrid_installer.cc index ba50202..28ef97c 100644 --- a/src/hybrid/hybrid_installer.cc +++ b/src/hybrid/hybrid_installer.cc @@ -42,6 +42,8 @@ #include #include #include +#include +#include #include #include #include @@ -185,6 +187,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(true); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -201,6 +204,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep( ci::Plugin::ActionType::Upgrade); + AddStep(); AddStep(); AddStep(); break; @@ -268,6 +272,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(true); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -284,6 +289,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep( ci::Plugin::ActionType::Upgrade); + AddStep(); AddStep(); AddStep(); break; @@ -384,6 +390,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(); @@ -399,6 +406,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep( ci::Plugin::ActionType::Upgrade); + AddStep(); AddStep(true); AddStep(); break; @@ -463,6 +471,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep( ci::Plugin::ActionType::Upgrade); + AddStep(); AddStep(); AddStep(); break; @@ -507,6 +516,7 @@ HybridInstaller::HybridInstaller(common_installer::PkgMgrPtr pkgmgr) AddStep(); AddStep( ci::Plugin::ActionType::Upgrade); + AddStep(); AddStep(); break; } -- 2.7.4 From 88be41a3b7315837293bbf677f367000bade3cca Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Thu, 1 Jun 2017 09:47:27 +0900 Subject: [PATCH 03/16] Release version 0.4.3 Changes: - Fix crash when parsing icon info from wgt archive - Add update step of directories Change-Id: Id00bf427ae551510d7176b1c75f3ba8cf1f46019 Signed-off-by: Junghyun Yeon --- packaging/wgt-backend.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/wgt-backend.spec b/packaging/wgt-backend.spec index b80b728..c674ac2 100644 --- a/packaging/wgt-backend.spec +++ b/packaging/wgt-backend.spec @@ -1,6 +1,6 @@ Name: wgt-backend Summary: Application installer backend for WGT -Version: 0.4.2 +Version: 0.4.3 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From 128d8beb7b2ae2b32394d8ec62f7f8115c5bce6f Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Thu, 1 Jun 2017 15:18:01 +0900 Subject: [PATCH 04/16] Supress build warnings - Supress "unused parameter" build warnings Change-Id: Ic27d2298556ccbce75fc6a6fe4f06c1f3a544a8d Signed-off-by: Junghyun Yeon --- src/unit_tests/smoke_utils.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unit_tests/smoke_utils.cc b/src/unit_tests/smoke_utils.cc index ec50e82..3721b48 100644 --- a/src/unit_tests/smoke_utils.cc +++ b/src/unit_tests/smoke_utils.cc @@ -149,7 +149,7 @@ bool DeleteUser(const char *user_name, bool rem_home_dir) { bool AddTestUser(const char *user_name) { std::cout << "Adding test user: " << user_name << std::endl; - bool ret = AddUser(user_name); + AddUser(user_name); if (boost::optional uid = ci::GetUidByUserName(user_name)) { kTestUserId = *uid; kTestUserIdStr = std::to_string(kTestUserId); @@ -170,7 +170,7 @@ bool DeleteTestUser(const char *user_name) { uid_t test_uid; if (boost::optional uid = ci::GetUidByUserName(user_name)) test_uid = *uid; - bool ret = DeleteUser(user_name, true); + DeleteUser(user_name, true); if (!ci::GetUidByUserName(user_name)) { std::cout << "User deleted properly: user_name=" << user_name << " uid=" << test_uid << std::endl; -- 2.7.4 From 3a9647cc8e8e639dd2dc52ed3e8fd4b1e4979299 Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Wed, 24 May 2017 21:35:05 +0900 Subject: [PATCH 05/16] Fix logic of 'update' attribute Requires and Refer to: https://review.tizen.org/gerrit/#/c/130948/ Change-Id: I408ec32d9cabd161217e4a462188c27e6366d712 Signed-off-by: jongmyeongko --- src/wgt/step/configuration/step_parse.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc index 01ae9bc..6157663 100644 --- a/src/wgt/step/configuration/step_parse.cc +++ b/src/wgt/step/configuration/step_parse.cc @@ -275,12 +275,14 @@ bool StepParse::FillWidgetInfo(manifest_x* manifest) { // set update true if package is updated preload package ci::RequestType req_type = context_->request_type.get(); - if (req_type == ci::RequestType::ReadonlyUpdateInstall) + if (ci::QueryIsUpdatedPackage(context_->pkgid.get(), context_->uid.get())) manifest->update = strdup("true"); - else if (req_type == ci::RequestType::ReadonlyUpdateUninstall) - manifest->update = strdup("false"); - else if (ci::QueryIsUpdatedReadonlyPackage(context_->pkgid.get(), - context_->uid.get())) + else if (ci::QueryIsPreloadPackage(context_->pkgid.get(), + context_->uid.get()) && + (req_type == ci::RequestType::Update || + req_type == ci::RequestType::Delta || + req_type == ci::RequestType::MountUpdate || + req_type == ci::RequestType::ReadonlyUpdateInstall)) manifest->update = strdup("true"); else manifest->update = strdup("false"); -- 2.7.4 From ea510377447fc22afb1a7106ae566907ff7a1112 Mon Sep 17 00:00:00 2001 From: Piotr Ganicz Date: Fri, 2 Jun 2017 17:05:13 +0200 Subject: [PATCH 06/16] Fix for ManifestTests Both properties in config are mandatory, regarding the documentation. So it is intuitive that te parsing process will fail in case of lack of such properies. Change-Id: I2f89a3aaa2098f942fb53002fb64fab54cb8c936 --- src/unit_tests/manifest_test.cc | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/src/unit_tests/manifest_test.cc b/src/unit_tests/manifest_test.cc index 52f9a81..009cf44 100644 --- a/src/unit_tests/manifest_test.cc +++ b/src/unit_tests/manifest_test.cc @@ -528,18 +528,7 @@ TEST_F(ManifestTest, MetadataElement_MissingValue) { TEST_F(ManifestTest, MetadataElement_MissingKey) { StepParseRunner runner(GetMyName()); - ASSERT_TRUE(runner.Run()); - manifest_x* m = runner.GetManifest(); - ASSERT_NE(m, nullptr); - auto apps = GListRange(m->application); - application_x* app = *apps.begin(); - - std::map meta_data_map; - for (metadata_x* meta_data : GListRange(app->metadata)) { - if (meta_data->key && meta_data->value) - meta_data_map[meta_data->key] = meta_data->value; - } - ASSERT_EQ(meta_data_map.size(), 0); + ASSERT_FALSE(runner.Run()); } TEST_F(ManifestTest, CategoryElement_Valid) { @@ -561,17 +550,7 @@ TEST_F(ManifestTest, CategoryElement_Valid) { TEST_F(ManifestTest, CategoryElement_MissingName) { StepParseRunner runner(GetMyName()); - ASSERT_TRUE(runner.Run()); - manifest_x* m = runner.GetManifest(); - ASSERT_NE(m, nullptr); - auto apps = GListRange(m->application); - application_x* app = *apps.begin(); - - std::vector categories; - for (const char* category : GListRange(app->category)) { - categories.push_back(category); - } - ASSERT_TRUE(categories.empty()); + ASSERT_FALSE(runner.Run()); } TEST_F(ManifestTest, CategoryElement_MultipleElements) { -- 2.7.4 From decd7bcdce31132fa2cbad71f98e6da6fec876a9 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Fri, 9 Jun 2017 11:30:29 +0900 Subject: [PATCH 07/16] Release version 0.4.4 Changes: - Supress build warnings - Fix logic of 'update' attribute - Fix for ManifestTests Change-Id: Ief985c4e3f6e3320e88475697d2db506d55ffe86 Signed-off-by: Sangyoon Jang --- packaging/wgt-backend.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/wgt-backend.spec b/packaging/wgt-backend.spec index c674ac2..09189df 100644 --- a/packaging/wgt-backend.spec +++ b/packaging/wgt-backend.spec @@ -1,6 +1,6 @@ Name: wgt-backend Summary: Application installer backend for WGT -Version: 0.4.3 +Version: 0.4.4 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From e25408785ad84245a2e9d2eea53b445d900a0090 Mon Sep 17 00:00:00 2001 From: Bartlomiej Kunikowski Date: Wed, 24 May 2017 12:13:30 +0200 Subject: [PATCH 08/16] [SmokeTest] Fixes for smoke tests Add "System" exec label to extensive smoke test. Small fixes for RecoveryMode_ForDelta and MigrateLegacyExternalImageMode. Change-Id: I5e342a9e397e5c0ce72680037b1dcb667828c1e3 --- packaging/wgt-backend-tests.manifest | 1 + src/unit_tests/extensive_smoke_test.cc | 5 ++++- src/unit_tests/smoke_test.cc | 11 ++++++++--- src/unit_tests/smoke_utils.cc | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/packaging/wgt-backend-tests.manifest b/packaging/wgt-backend-tests.manifest index 17bba51..8ea34c3 100644 --- a/packaging/wgt-backend-tests.manifest +++ b/packaging/wgt-backend-tests.manifest @@ -5,5 +5,6 @@ + diff --git a/src/unit_tests/extensive_smoke_test.cc b/src/unit_tests/extensive_smoke_test.cc index 043c293..34104de 100644 --- a/src/unit_tests/extensive_smoke_test.cc +++ b/src/unit_tests/extensive_smoke_test.cc @@ -107,12 +107,14 @@ TEST_F(SmokeTest, RecoveryMode_ForDelta) { bf::path path_new = kSmokePackagesDirectory / "RecoveryMode_ForDelta.delta"; std::string pkgid = "smokewgt30"; std::string appid = "smokewgt30.RecoveryModeForDelta"; - bf::path recovery_file = FindRecoveryFile(); RemoveAllRecoveryFiles(); + ASSERT_EQ(Install(path_old, PackageType::WGT), ci::AppInstaller::Result::OK); + AddDataFiles(pkgid, kTestUserId); std::vector args = {"", "-i", path_new.string(), "-u", kTestUserIdStr.c_str()}; CrashAfterEachStep(args, [=](int step) -> bool { if (step >= 1) { + bf::path recovery_file = FindRecoveryFile(); EXTENDED_ASSERT_FALSE(recovery_file.empty()); EXTENDED_ASSERT_EQ(Recover(recovery_file, PackageType::WGT), ci::AppInstaller::Result::OK); @@ -120,6 +122,7 @@ TEST_F(SmokeTest, RecoveryMode_ForDelta) { EXTENDED_ASSERT_TRUE(ValidateFileContentInPackage(pkgid, "res/wgt/VERSION", "1\n")); + EXTENDED_ASSERT_TRUE(ValidateDataFiles(pkgid, kTestUserId)); } return true; }); diff --git a/src/unit_tests/smoke_test.cc b/src/unit_tests/smoke_test.cc index 35bdfbc..c3dad25 100644 --- a/src/unit_tests/smoke_test.cc +++ b/src/unit_tests/smoke_test.cc @@ -583,9 +583,14 @@ TEST_F(SmokeTest, MigrateLegacyExternalImageMode) { std::string pkgid = "smokewgt36"; std::string appid = "smokewgt36.web"; bf::path legacy_path = kSmokePackagesDirectory / kLegacyExtImageDir; - ASSERT_EQ(MigrateLegacyExternalImage(pkgid, path, legacy_path, - PackageType::WGT), ci::AppInstaller::Result::OK); - ValidateExternalPackage(pkgid, {appid}); + if (kTestUserIdStr == kDefaultUserIdStr || kTestUserId == kGlobalUserUid) { + ASSERT_EQ(MigrateLegacyExternalImage(pkgid, path, legacy_path, + PackageType::WGT), ci::AppInstaller::Result::OK); + ValidateExternalPackage(pkgid, {appid}); + } else { + ASSERT_EQ(MigrateLegacyExternalImage(pkgid, path, legacy_path, + PackageType::WGT), ci::AppInstaller::Result::ERROR); + } } TEST_F(PreloadSmokeTest, InstallationMode_Preload) { diff --git a/src/unit_tests/smoke_utils.cc b/src/unit_tests/smoke_utils.cc index 3721b48..08d617f 100644 --- a/src/unit_tests/smoke_utils.cc +++ b/src/unit_tests/smoke_utils.cc @@ -660,7 +660,7 @@ ci::AppInstaller::Result MigrateLegacyExternalImage(const std::string& pkgid, return ci::AppInstaller::Result::ERROR; } const char* argv[] = {"", "--migrate-extimg", pkgid.c_str(), - "-u", kDefaultUserIdStr.c_str()}; + "-u", kTestUserIdStr.c_str()}; return CallBackend(SIZEOFARRAY(argv), argv, type, mode); } -- 2.7.4 From 2a4847ba5155f13dd0572738b8c2cb4d07b1218f Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Wed, 5 Jul 2017 20:35:53 +0900 Subject: [PATCH 09/16] Release version 0.4.5 Changes: - [SmokeTest] Fixes for smoke tests Change-Id: Ic7c6e0fa3d64b9ffa0446c4b10f7e7e8355d8ce6 Signed-off-by: jongmyeongko --- packaging/wgt-backend.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/wgt-backend.spec b/packaging/wgt-backend.spec index 09189df..4710aad 100644 --- a/packaging/wgt-backend.spec +++ b/packaging/wgt-backend.spec @@ -1,6 +1,6 @@ Name: wgt-backend Summary: Application installer backend for WGT -Version: 0.4.4 +Version: 0.4.5 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From 24e215ea88f933ab341c871f355b3d9ae8ef3e67 Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Wed, 12 Jul 2017 15:42:29 +0900 Subject: [PATCH 10/16] Skip reading icon in case there is no icon file actually Change-Id: I653a8ac1d6fa1d496060adfd68ad8b1757814144 Signed-off-by: jongmyeongko --- src/lib/wgt_archive_info.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/wgt_archive_info.cc b/src/lib/wgt_archive_info.cc index 205ba5f..095b60d 100644 --- a/src/lib/wgt_archive_info.cc +++ b/src/lib/wgt_archive_info.cc @@ -140,6 +140,11 @@ bool ReadIcon(const bf::path& icon, const bf::path& tmp_dir, LOG(INFO) << "Icon file path: " << icon_path; + if (!bf::exists(icon_path)) { + LOG(WARNING) << "Icon file doesn't actually exist, skip reading icon"; + return true; + } + std::ifstream ifs(icon_path.c_str(), std::ifstream::in | std::ifstream::binary); ifs.seekg(0, ifs.end); -- 2.7.4 From 5ee35db0967c94419eddb7989311b55640f9ce62 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Tue, 11 Jul 2017 19:26:03 +0900 Subject: [PATCH 11/16] Invoke StepParsePreload when ReadonlyUpdateUninstall StepParsePreload should be invoked for setting system attributes properly. Change-Id: I9d40710a2a6a056031d77eeca52de7f7e91bba21 Signed-off-by: Sangyoon Jang --- src/wgt/wgt_installer.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index 475c05e..ef52922 100755 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -587,6 +587,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep( ci::configuration::StepParseManifest::ManifestLocation::INSTALLED, ci::configuration::StepParseManifest::StoreLocation::NORMAL); + AddStep(); AddStep(); AddStep(); AddStep(); -- 2.7.4 From 50b5482126136e6f1155d43e14150e3e1dca4e51 Mon Sep 17 00:00:00 2001 From: Sangyoon Jang Date: Mon, 17 Jul 2017 16:25:12 +0900 Subject: [PATCH 12/16] Fix ReadonlyUpdateUninstall The original package is preloaded(readonly) so we need to switch readonly mode before update security context. Change-Id: Iaad59be0850bf68ffb9bde4bbdfed34ba2327494 Signed-off-by: Sangyoon Jang --- src/wgt/wgt_installer.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wgt/wgt_installer.cc b/src/wgt/wgt_installer.cc index ef52922..20c741b 100755 --- a/src/wgt/wgt_installer.cc +++ b/src/wgt/wgt_installer.cc @@ -597,6 +597,7 @@ WgtInstaller::WgtInstaller(ci::PkgMgrPtr pkgrmgr) AddStep(); AddStep(); AddStep(); + AddStep(); AddStep(); AddStep(); AddStep(ci::Plugin::ActionType::Upgrade); -- 2.7.4 From d9a354f7837109f024ec32f655e10fba862e0663 Mon Sep 17 00:00:00 2001 From: Junghyun Yeon Date: Tue, 18 Jul 2017 11:30:15 +0900 Subject: [PATCH 13/16] Release version 0.4.6 Changes: - Skip reading icon in case there is no icon file actually - Invoke StepParsePreload when ReadonlyUpdateUninstall - Fix ReadonlyUpdateUninstall Change-Id: I869d1f74712431ad22d298d965e11888bb5b699e Signed-off-by: Junghyun Yeon --- packaging/wgt-backend.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/wgt-backend.spec b/packaging/wgt-backend.spec index 4710aad..ffcd730 100644 --- a/packaging/wgt-backend.spec +++ b/packaging/wgt-backend.spec @@ -1,6 +1,6 @@ Name: wgt-backend Summary: Application installer backend for WGT -Version: 0.4.5 +Version: 0.4.6 Release: 1 Group: Application Framework/Package Management License: Apache-2.0 -- 2.7.4 From 7860a9d80e1442fae7891580cdfeb404dd938b2a Mon Sep 17 00:00:00 2001 From: Damian Pietruchowski Date: Tue, 4 Apr 2017 11:55:59 +0200 Subject: [PATCH 14/16] Unnecessary queries if pkg_id is empty Change-Id: I825867e85142e704a50ecde510c4a8b72d97ae84 Signed-off-by: Damian Pietruchowski --- src/wgt/step/configuration/step_parse.cc | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc index 6157663..1844dec 100644 --- a/src/wgt/step/configuration/step_parse.cc +++ b/src/wgt/step/configuration/step_parse.cc @@ -273,19 +273,24 @@ bool StepParse::FillWidgetInfo(manifest_x* manifest) { manifest->installlocation = strdup("auto"); } - // set update true if package is updated preload package - ci::RequestType req_type = context_->request_type.get(); - if (ci::QueryIsUpdatedPackage(context_->pkgid.get(), context_->uid.get())) - manifest->update = strdup("true"); - else if (ci::QueryIsPreloadPackage(context_->pkgid.get(), - context_->uid.get()) && - (req_type == ci::RequestType::Update || - req_type == ci::RequestType::Delta || - req_type == ci::RequestType::MountUpdate || - req_type == ci::RequestType::ReadonlyUpdateInstall)) - manifest->update = strdup("true"); - else + if (!context_->pkgid.get().empty()) { + // set update true if package is updated preload package + ci::RequestType req_type = context_->request_type.get(); + if (ci::QueryIsUpdatedPackage(context_->pkgid.get(), context_->uid.get())) + manifest->update = strdup("true"); + else if (ci::QueryIsPreloadPackage(context_->pkgid.get(), + context_->uid.get()) && + (req_type == ci::RequestType::Update || + req_type == ci::RequestType::Delta || + req_type == ci::RequestType::MountUpdate || + req_type == ci::RequestType::ReadonlyUpdateInstall)) + manifest->update = strdup("true"); + else + manifest->update = strdup("false"); + } + else { manifest->update = strdup("false"); + } return true; } -- 2.7.4 From b5872bf1f65bb6f48d6f070e9b3e7389a03208ae Mon Sep 17 00:00:00 2001 From: jongmyeongko Date: Tue, 18 Jul 2017 23:23:43 +0900 Subject: [PATCH 15/16] Add appdefined privilege feature Requires: https://review.tizen.org/gerrit/#/c/136932/ https://review.tizen.org/gerrit/#/c/139373/ Change-Id: I185d5fe866b686152616cc20df79e80d8dbb7ea6 Signed-off-by: jongmyeongko --- .../configuration/step_merge_tpk_privileges.cc | 10 + src/hybrid/step/pkgmgr/step_generate_xml.cc | 1 + src/unit_tests/manifest_test.cc | 204 +++++++++++++++++++++ .../config.xml | 5 + .../config.xml | 5 + .../config.xml | 5 + .../config.xml | 5 + .../config.xml | 6 + .../config.xml | 5 + .../config.xml | 5 + .../config.xml | 6 + .../config.xml | 5 + .../config.xml | 7 + .../config.xml | 7 + .../config.xml | 7 + .../config.xml | 7 + .../config.xml | 8 + .../config.xml | 7 + .../config.xml | 7 + .../config.xml | 8 + .../config.xml | 7 + src/wgt/step/configuration/step_parse.cc | 67 +++++++ src/wgt/step/configuration/step_parse.h | 2 + src/wgt/step/pkgmgr/step_generate_xml.cc | 30 +++ src/wgt/step/pkgmgr/step_generate_xml.h | 1 + 25 files changed, 427 insertions(+) create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_InvalidName/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_Invalid_NoPKGID/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_Invalid_NoURI/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_Invalid_OverLength/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_ManyElements/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_MissingName/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_ValidName/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_WithLicenseManyElements/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_WithLicenseValidName/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_InvalidName/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_NoPKGID/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_NoURI/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_OverLength/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_ManyElements/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_MissingName/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_ValidName/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_WithLicenseManyElements/config.xml create mode 100644 src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_WithLicenseValidName/config.xml diff --git a/src/hybrid/step/configuration/step_merge_tpk_privileges.cc b/src/hybrid/step/configuration/step_merge_tpk_privileges.cc index 48f13f5..631189e 100644 --- a/src/hybrid/step/configuration/step_merge_tpk_privileges.cc +++ b/src/hybrid/step/configuration/step_merge_tpk_privileges.cc @@ -21,6 +21,16 @@ common_installer::Step::Status StepMergeTpkPrivileges::process() { g_list_concat(wgt_data->privileges, tpk_data->privileges); tpk_data->privileges = nullptr; + wgt_data->appdefined_privileges = + g_list_concat(wgt_data->appdefined_privileges, + tpk_data->appdefined_privileges); + tpk_data->appdefined_privileges = nullptr; + + wgt_data->provides_appdefined_privileges = + g_list_concat(wgt_data->provides_appdefined_privileges, + tpk_data->provides_appdefined_privileges); + tpk_data->provides_appdefined_privileges = nullptr; + return Status::OK; } diff --git a/src/hybrid/step/pkgmgr/step_generate_xml.cc b/src/hybrid/step/pkgmgr/step_generate_xml.cc index 2004179..00e4e5d 100644 --- a/src/hybrid/step/pkgmgr/step_generate_xml.cc +++ b/src/hybrid/step/pkgmgr/step_generate_xml.cc @@ -33,6 +33,7 @@ const std::vector kBlackListNodes = { {"description"}, {"profile"}, {"privileges"}, + {"provides-appdefined-privileges"}, }; const std::vector kNeedMergeNodes = { {"manifest"}, diff --git a/src/unit_tests/manifest_test.cc b/src/unit_tests/manifest_test.cc index 009cf44..90c9ed6 100644 --- a/src/unit_tests/manifest_test.cc +++ b/src/unit_tests/manifest_test.cc @@ -218,6 +218,210 @@ TEST_F(ManifestTest, PrivilegeElement_MissingName) { ASSERT_FALSE(runner.Run()); } +TEST_F(ManifestTest, AppDefinedPrivilegeElement_Invalid_NotURI) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, AppDefinedPrivilegeElement_Invalid_NoPKGID) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, AppDefinedPrivilegeElement_Invalid_OverLength) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, AppDefinedPrivilegeElement_ValidName) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + std::vector priv_vec; + for (appdefined_privilege_x* priv : + GListRange(m->appdefined_privileges)) { + priv_vec.push_back(priv->value); + } + ASSERT_FALSE(priv_vec.empty()); + const char* expected_name = "http://package0id/appdefined/test.read"; + ASSERT_CSTR_EQ(priv_vec[0].c_str(), expected_name); +} + +TEST_F(ManifestTest, AppDefinedPrivilegeElement_ManyElements) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + std::vector priv_vec; + for (appdefined_privilege_x* priv : + GListRange(m->appdefined_privileges)) { + priv_vec.push_back(priv->value); + } + ASSERT_EQ(priv_vec.size(), 2); + const char* first_priv = "http://package0id/appdefined/test.read"; + ASSERT_CSTR_EQ(priv_vec[0].c_str(), first_priv); + const char* second_priv = "http://package0id/appdefined/test.write"; + ASSERT_CSTR_EQ(priv_vec[1].c_str(), second_priv); +} + +TEST_F(ManifestTest, AppDefinedPrivilegeElement_WithLicenseValidName) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + std::vector priv_vec; + std::vector license_vec; + for (appdefined_privilege_x* priv : + GListRange(m->appdefined_privileges)) { + priv_vec.push_back(priv->value); + license_vec.push_back(priv->license); + } + ASSERT_FALSE(priv_vec.empty()); + const char* expected_name = "http://package0id/appdefined/test.read"; + ASSERT_CSTR_EQ(priv_vec[0].c_str(), expected_name); + ASSERT_FALSE(license_vec.empty()); + bf::path path(m->root_path); + path /= "res/cert"; + ASSERT_CSTR_EQ(license_vec[0].c_str(), path.c_str()); +} + +TEST_F(ManifestTest, AppDefinedPrivilegeElement_WithLicenseManyElements) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + std::vector priv_vec; + std::vector license_vec; + for (appdefined_privilege_x* priv : + GListRange(m->appdefined_privileges)) { + priv_vec.push_back(priv->value); + license_vec.push_back(priv->license); + } + ASSERT_EQ(priv_vec.size(), 2); + const char* first_priv = "http://package0id/appdefined/test.read"; + ASSERT_CSTR_EQ(priv_vec[0].c_str(), first_priv); + const char* second_priv = "http://package0id/appdefined/test.write"; + ASSERT_CSTR_EQ(priv_vec[1].c_str(), second_priv); + ASSERT_EQ(license_vec.size(), 2); + bf::path path(m->root_path); + path /= "res/cert"; + ASSERT_CSTR_EQ(license_vec[0].c_str(), path.c_str()); + ASSERT_CSTR_EQ(license_vec[1].c_str(), path.c_str()); +} + +TEST_F(ManifestTest, AppDefinedPrivilegeElement_InvalidName) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, AppDefinedPrivilegeElement_MissingName) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, ProvidesAppDefinedPrivilegeElement_Invalid_NotURI) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, ProvidesAppDefinedPrivilegeElement_Invalid_NoPKGID) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, ProvidesAppDefinedPrivilegeElement_Invalid_OverLength) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, ProvidesAppDefinedPrivilegeElement_ValidName) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + std::vector priv_vec; + for (appdefined_privilege_x* priv : GListRange( + m->provides_appdefined_privileges)) { + priv_vec.push_back(priv->value); + } + ASSERT_FALSE(priv_vec.empty()); + const char* expected_name = "http://package0id/appdefined/test.read"; + ASSERT_CSTR_EQ(priv_vec[0].c_str(), expected_name); +} + +TEST_F(ManifestTest, ProvidesAppDefinedPrivilegeElement_ManyElements) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + std::vector priv_vec; + for (appdefined_privilege_x* priv : GListRange( + m->provides_appdefined_privileges)) { + priv_vec.push_back(priv->value); + } + ASSERT_EQ(priv_vec.size(), 2); + const char* first_priv = "http://package0id/appdefined/test.read"; + ASSERT_CSTR_EQ(priv_vec[0].c_str(), first_priv); + const char* second_priv = "http://package0id/appdefined/test.write"; + ASSERT_CSTR_EQ(priv_vec[1].c_str(), second_priv); +} + +TEST_F(ManifestTest, ProvidesAppDefinedPrivilegeElement_WithLicenseValidName) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + std::vector priv_vec; + std::vector license_vec; + for (appdefined_privilege_x* priv : GListRange( + m->provides_appdefined_privileges)) { + priv_vec.push_back(priv->value); + license_vec.push_back(priv->license); + } + ASSERT_FALSE(priv_vec.empty()); + const char* expected_name = "http://package0id/appdefined/test.read"; + ASSERT_CSTR_EQ(priv_vec[0].c_str(), expected_name); + ASSERT_FALSE(license_vec.empty()); + bf::path path(m->root_path); + path /= "res/cert"; + ASSERT_CSTR_EQ(license_vec[0].c_str(), path.c_str()); +} + +TEST_F(ManifestTest, + ProvidesAppDefinedPrivilegeElement_WithLicenseManyElements) { + StepParseRunner runner(GetMyName()); + ASSERT_TRUE(runner.Run()); + manifest_x* m = runner.GetManifest(); + ASSERT_NE(m, nullptr); + std::vector priv_vec; + std::vector license_vec; + for (appdefined_privilege_x* priv : GListRange( + m->provides_appdefined_privileges)) { + priv_vec.push_back(priv->value); + license_vec.push_back(priv->license); + } + ASSERT_EQ(priv_vec.size(), 2); + const char* first_priv = "http://package0id/appdefined/test.read"; + ASSERT_CSTR_EQ(priv_vec[0].c_str(), first_priv); + const char* second_priv = "http://package0id/appdefined/test.write"; + ASSERT_CSTR_EQ(priv_vec[1].c_str(), second_priv); + ASSERT_EQ(license_vec.size(), 2); + bf::path path(m->root_path); + path /= "res/cert"; + ASSERT_CSTR_EQ(license_vec[0].c_str(), path.c_str()); + ASSERT_CSTR_EQ(license_vec[1].c_str(), path.c_str()); +} + +TEST_F(ManifestTest, ProvidesAppDefinedPrivilegeElement_InvalidName) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} + +TEST_F(ManifestTest, ProvidesAppDefinedPrivilegeElement_MissingName) { + StepParseRunner runner(GetMyName()); + ASSERT_FALSE(runner.Run()); +} TEST_F(ManifestTest, AppControlElement_Valid) { StepParseRunner runner(GetMyName()); diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_InvalidName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_InvalidName/config.xml new file mode 100644 index 0000000..d5aaa70 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_InvalidName/config.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_Invalid_NoPKGID/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_Invalid_NoPKGID/config.xml new file mode 100644 index 0000000..4cb239b --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_Invalid_NoPKGID/config.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_Invalid_NoURI/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_Invalid_NoURI/config.xml new file mode 100644 index 0000000..d824f8d --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_Invalid_NoURI/config.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_Invalid_OverLength/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_Invalid_OverLength/config.xml new file mode 100644 index 0000000..79a8bec --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_Invalid_OverLength/config.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_ManyElements/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_ManyElements/config.xml new file mode 100644 index 0000000..97cdcc1 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_ManyElements/config.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_MissingName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_MissingName/config.xml new file mode 100644 index 0000000..3dc4f44 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_MissingName/config.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_ValidName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_ValidName/config.xml new file mode 100644 index 0000000..00611d1 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_ValidName/config.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_WithLicenseManyElements/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_WithLicenseManyElements/config.xml new file mode 100644 index 0000000..270313a --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_WithLicenseManyElements/config.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_WithLicenseValidName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_WithLicenseValidName/config.xml new file mode 100644 index 0000000..536dca6 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.AppDefinedPrivilegeElement_WithLicenseValidName/config.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_InvalidName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_InvalidName/config.xml new file mode 100644 index 0000000..78ca65a --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_InvalidName/config.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_NoPKGID/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_NoPKGID/config.xml new file mode 100644 index 0000000..748f827 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_NoPKGID/config.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_NoURI/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_NoURI/config.xml new file mode 100644 index 0000000..68e32f7 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_NoURI/config.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_OverLength/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_OverLength/config.xml new file mode 100644 index 0000000..201ebd7 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_Invalid_OverLength/config.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_ManyElements/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_ManyElements/config.xml new file mode 100644 index 0000000..f01fb27 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_ManyElements/config.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_MissingName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_MissingName/config.xml new file mode 100644 index 0000000..bb84800 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_MissingName/config.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_ValidName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_ValidName/config.xml new file mode 100644 index 0000000..613eae7 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_ValidName/config.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_WithLicenseManyElements/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_WithLicenseManyElements/config.xml new file mode 100644 index 0000000..297cbdf --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_WithLicenseManyElements/config.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_WithLicenseValidName/config.xml b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_WithLicenseValidName/config.xml new file mode 100644 index 0000000..7d85238 --- /dev/null +++ b/src/unit_tests/test_samples/manifest/ManifestTest.ProvidesAppDefinedPrivilegeElement_WithLicenseValidName/config.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/wgt/step/configuration/step_parse.cc b/src/wgt/step/configuration/step_parse.cc index 1844dec..f1825e2 100644 --- a/src/wgt/step/configuration/step_parse.cc +++ b/src/wgt/step/configuration/step_parse.cc @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -545,6 +546,68 @@ bool StepParse::FillPrivileges(manifest_x* manifest) { return true; } +bool StepParse::FillAppDefinedPrivileges(manifest_x* manifest) { + auto priv_info = + GetManifestDataForKey( + app_keys::kTizenAppDefinedPrivilegeKey); + if (!priv_info) + return true; + + const auto& privileges = priv_info->GetAppDefinedPrivilegeList(); + for (auto& priv : privileges) { + appdefined_privilege_x* privilege = + reinterpret_cast(calloc(1, + sizeof(appdefined_privilege_x))); + if (privilege == nullptr) { + LOG(ERROR) << "Memory alloc failure"; + return false; + } + privilege->value = strdup(priv.privilege.c_str()); + privilege->type = strdup(common_installer::kWebPrivilegeType); + if (!priv.license.empty()) { + if (bf::path(priv.license).is_absolute()) + privilege->license = strdup(priv.license.c_str()); + else + privilege->license = strdup((context_->root_application_path.get() + / manifest->package / priv.license).c_str()); + } + manifest->appdefined_privileges = + g_list_append(manifest->appdefined_privileges, privilege); + } + return true; +} + +bool StepParse::FillProvidesAppDefinedPrivileges(manifest_x* manifest) { + auto priv_info = + GetManifestDataForKey( + app_keys::kTizenProvidesAppDefinedPrivilegesKey); + if (!priv_info) + return true; + + const auto& privileges = priv_info->GetAppDefinedPrivilegeList(); + for (auto& priv : privileges) { + appdefined_privilege_x* privilege = + reinterpret_cast(calloc(1, + sizeof(appdefined_privilege_x))); + if (privilege == nullptr) { + LOG(ERROR) << "Memory alloc failure"; + return false; + } + privilege->value = strdup(priv.privilege.c_str()); + privilege->type = strdup(common_installer::kWebPrivilegeType); + if (!priv.license.empty()) { + if (bf::path(priv.license).is_absolute()) + privilege->license = strdup(priv.license.c_str()); + else + privilege->license = strdup((context_->root_application_path.get() + / manifest->package / priv.license).c_str()); + } + manifest->provides_appdefined_privileges = + g_list_append(manifest->provides_appdefined_privileges, privilege); + } + return true; +} + bool StepParse::FillCategories(manifest_x* manifest) { auto category_info = GetManifestDataForKey( @@ -642,6 +705,10 @@ bool StepParse::FillManifestX(manifest_x* manifest) { return false; if (!FillPrivileges(manifest)) return false; + if (!FillAppDefinedPrivileges(manifest)) + return false; + if (!FillProvidesAppDefinedPrivileges(manifest)) + return false; if (!FillAppControl(manifest)) return false; if (!FillCategories(manifest)) diff --git a/src/wgt/step/configuration/step_parse.h b/src/wgt/step/configuration/step_parse.h index d2a42dc..10e5f9e 100644 --- a/src/wgt/step/configuration/step_parse.h +++ b/src/wgt/step/configuration/step_parse.h @@ -63,6 +63,8 @@ class StepParse : public common_installer::Step { bool FillWidgetApplicationInfo(manifest_x* manifest); bool FillAppControl(manifest_x* manifest); bool FillPrivileges(manifest_x* manifest); + bool FillAppDefinedPrivileges(manifest_x* manifest); + bool FillProvidesAppDefinedPrivileges(manifest_x* manifest); bool FillCategories(manifest_x* manifest); bool FillMetadata(manifest_x* manifest); bool FillExtraManifestInfo(manifest_x* manifest); diff --git a/src/wgt/step/pkgmgr/step_generate_xml.cc b/src/wgt/step/pkgmgr/step_generate_xml.cc index 370d403..ab05829 100644 --- a/src/wgt/step/pkgmgr/step_generate_xml.cc +++ b/src/wgt/step/pkgmgr/step_generate_xml.cc @@ -386,6 +386,7 @@ common_installer::Step::Status StepGenerateXml::GenerateManifestElement( return status; } GeneratePrivilege(writer); + GenerateProvidesAppDefinedPrivilege(writer); GenerateAccount(writer); GenerateIme(writer); GenerateProfiles(writer); @@ -505,7 +506,36 @@ void StepGenerateXml::GeneratePrivilege(xmlTextWriterPtr writer) { xmlTextWriterWriteString(writer, BAD_CAST priv->value); xmlTextWriterEndElement(writer); } + if (context_->manifest_data.get()->appdefined_privileges) { + for (appdefined_privilege_x* priv : GListRange( + context_->manifest_data.get()->appdefined_privileges)) { + xmlTextWriterStartElement(writer, BAD_CAST "appdefined-privilege"); + xmlTextWriterWriteAttribute(writer, BAD_CAST "license", + BAD_CAST priv->license); + xmlTextWriterWriteAttribute(writer, BAD_CAST "type", + BAD_CAST priv->type); + xmlTextWriterWriteString(writer, BAD_CAST priv->value); + xmlTextWriterEndElement(writer); + } + } + xmlTextWriterEndElement(writer); + } +} +void StepGenerateXml::GenerateProvidesAppDefinedPrivilege( + xmlTextWriterPtr writer) { + if (context_->manifest_data.get()->provides_appdefined_privileges) { + xmlTextWriterStartElement(writer, BAD_CAST "provides-appdefined-privileges"); + for (appdefined_privilege_x* priv : GListRange( + context_->manifest_data.get()->provides_appdefined_privileges)) { + xmlTextWriterStartElement(writer, BAD_CAST "appdefined-privilege"); + xmlTextWriterWriteAttribute(writer, BAD_CAST "license", + BAD_CAST priv->license); + xmlTextWriterWriteAttribute(writer, BAD_CAST "type", + BAD_CAST priv->type); + xmlTextWriterWriteString(writer, BAD_CAST priv->value); + xmlTextWriterEndElement(writer); + } xmlTextWriterEndElement(writer); } } diff --git a/src/wgt/step/pkgmgr/step_generate_xml.h b/src/wgt/step/pkgmgr/step_generate_xml.h index 5dbb706..5bb7f89 100644 --- a/src/wgt/step/pkgmgr/step_generate_xml.h +++ b/src/wgt/step/pkgmgr/step_generate_xml.h @@ -44,6 +44,7 @@ class StepGenerateXml : public common_installer::Step { void GenerateDescription(xmlTextWriterPtr writer); Step::Status GenerateApplications(xmlTextWriterPtr writer); void GeneratePrivilege(xmlTextWriterPtr writer); + void GenerateProvidesAppDefinedPrivilege(xmlTextWriterPtr writer); void GenerateAccount(xmlTextWriterPtr writer); void GenerateIme(xmlTextWriterPtr writer); void GenerateProfiles(xmlTextWriterPtr writer); -- 2.7.4 From a042e9936314b49ec38eadb88020714cf45f07cc Mon Sep 17 00:00:00 2001 From: Semun Lee Date: Tue, 1 Aug 2017 11:46:02 +0900 Subject: [PATCH 16/16] Fix wrong condition for checking shortcut info Change-Id: I06467d12a59e8f2bdd452744f8a72575fb656d36 Signed-off-by: Semun Lee --- src/wgt/step/pkgmgr/step_generate_xml.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wgt/step/pkgmgr/step_generate_xml.cc b/src/wgt/step/pkgmgr/step_generate_xml.cc index ab05829..e7e8235 100644 --- a/src/wgt/step/pkgmgr/step_generate_xml.cc +++ b/src/wgt/step/pkgmgr/step_generate_xml.cc @@ -650,10 +650,10 @@ void StepGenerateXml::GenerateShortcuts(xmlTextWriterPtr writer) { if (!shortcut.app_id.empty()) xmlTextWriterWriteAttribute(writer, BAD_CAST "appid", BAD_CAST shortcut.app_id.c_str()); - if (!shortcut.app_id.empty()) + if (!shortcut.extra_data.empty()) xmlTextWriterWriteAttribute(writer, BAD_CAST "extra_data", BAD_CAST shortcut.extra_data.c_str()); - if (!shortcut.app_id.empty()) + if (!shortcut.extra_key.empty()) xmlTextWriterWriteAttribute(writer, BAD_CAST "extra_key", BAD_CAST shortcut.extra_key.c_str()); if (!shortcut.icon.empty()) { -- 2.7.4