From 761553033e4fc1e335a63c7fdc15ac2b57ed13c4 Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Tue, 4 Jun 2024 09:15:07 +0000 Subject: [PATCH 01/23] =?UTF-8?q?quick=5Ffix=5Ftest=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=BF=90=E8=A1=8Ccrash=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei --- .../bms_bundle_quick_fix_test.cpp | 21 +++---------------- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/bms_bundle_quick_fix_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/bms_bundle_quick_fix_test.cpp index 5d015b95f..454cea9d2 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/bms_bundle_quick_fix_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/bms_bundle_quick_fix_test.cpp @@ -370,22 +370,7 @@ AppQuickFix BmsBundleQuickFixTest::CreateAppQuickFix() sptr BmsBundleQuickFixTest::GetQuickFixManagerProxy() { - auto systemAbilityManager = OHOS::SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (systemAbilityManager == nullptr) { - APP_LOGE("GetSystemAbilityManager failed."); - return nullptr; - } - auto bundleMgrSa = systemAbilityManager->GetSystemAbility(OHOS::BUNDLE_MGR_SERVICE_SYS_ABILITY_ID); - if (bundleMgrSa == nullptr) { - APP_LOGE("GetSystemAbility failed."); - return nullptr; - } - auto bundleMgr = OHOS::iface_cast(bundleMgrSa); - if (bundleMgr == nullptr) { - APP_LOGE("iface_cast failed."); - return nullptr; - } - return bundleMgr->GetQuickFixManagerProxy(); + return bundleMgrService_->GetQuickFixManagerProxy(); } void BmsBundleQuickFixTest::CreateFiles(const std::vector& sourceFiles) @@ -1043,7 +1028,7 @@ HWTEST_F(BmsBundleQuickFixTest, BmsBundleQuickFixTest_0026, Function | SmallTest */ HWTEST_F(BmsBundleQuickFixTest, BmsBundleQuickFixTest_0027, Function | SmallTest | Level0) { - auto quickFixProxy= GetQuickFixManagerProxy(); + auto quickFixProxy = GetQuickFixManagerProxy(); EXPECT_NE(quickFixProxy, nullptr) << "the quickFixProxy is nullptr"; sptr callback = new (std::nothrow) MockQuickFixCallback(); EXPECT_NE(callback, nullptr) << "the callback is nullptr"; @@ -3606,7 +3591,7 @@ HWTEST_F(BmsBundleQuickFixTest, BmsBundleCopyFiles_0003, Function | SmallTest | CreateFiles(sourceFiles); std::vector destFiles = {"hello.hqf"}; ErrCode ret = quickFixProxy->CopyFiles(sourceFiles, destFiles); - EXPECT_EQ(ret, ERR_BUNDLEMANAGER_QUICK_FIX_PARAM_ERROR); + EXPECT_EQ(ret, ERR_BUNDLEMANAGER_QUICK_FIX_INTERNAL_ERROR); DeleteFiles(sourceFiles); DeleteFiles(destFiles); } From 6cfb720c3158d7f8b00412cafb4b2f2c8c5c9f68 Mon Sep 17 00:00:00 2001 From: zhaogan Date: Tue, 4 Jun 2024 17:22:11 +0800 Subject: [PATCH 02/23] add appIndex to ability Signed-off-by: zhaogan --- .../bundlemgr/include/inner_bundle_info.h | 6 +++--- services/bundlemgr/src/inner_bundle_info.cpp | 21 +++++++++++++------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/services/bundlemgr/include/inner_bundle_info.h b/services/bundlemgr/include/inner_bundle_info.h index 0279f662e..66b907a0e 100644 --- a/services/bundlemgr/include/inner_bundle_info.h +++ b/services/bundlemgr/include/inner_bundle_info.h @@ -1008,9 +1008,9 @@ public: private: bool IsExistLauncherAbility() const; void GetBundleWithAbilities( - int32_t flags, BundleInfo &bundleInfo, int32_t userId = Constants::UNSPECIFIED_USERID) const; + int32_t flags, BundleInfo &bundleInfo, int32_t appIndex, int32_t userId = Constants::UNSPECIFIED_USERID) const; void GetBundleWithExtension( - int32_t flags, BundleInfo &bundleInfo, int32_t userId = Constants::UNSPECIFIED_USERID) const; + int32_t flags, BundleInfo &bundleInfo, int32_t appIndex, int32_t userId = Constants::UNSPECIFIED_USERID) const; void RemoveDuplicateName(std::vector &name) const; void GetBundleWithReqPermissionsV9( int32_t flags, int32_t userId, BundleInfo &bundleInfo, int32_t appIndex = 0) const; @@ -1020,7 +1020,7 @@ private: int32_t flags, BundleInfo &bundleInfo, int32_t userId, int32_t appIndex = 0) const; void GetBundleWithAbilitiesV9( int32_t flags, HapModuleInfo &hapModuleInfo, int32_t userId, int32_t appIndex = 0) const; - void GetBundleWithExtensionAbilitiesV9(int32_t flags, HapModuleInfo &hapModuleInfo) const; + void GetBundleWithExtensionAbilitiesV9(int32_t flags, HapModuleInfo &hapModuleInfo, int32_t appIndex = 0) const; IsolationMode GetIsolationMode(const std::string &isolationMode) const; void UpdateIsCompressNativeLibs(); void InnerProcessShortcut(const Shortcut &oldShortcut, ShortcutInfo &shortcutInfo) const; diff --git a/services/bundlemgr/src/inner_bundle_info.cpp b/services/bundlemgr/src/inner_bundle_info.cpp index 14c08b799..5a539a53d 100644 --- a/services/bundlemgr/src/inner_bundle_info.cpp +++ b/services/bundlemgr/src/inner_bundle_info.cpp @@ -1351,6 +1351,7 @@ void InnerBundleInfo::GetApplicationInfo(int32_t flags, int32_t userId, Applicat if (!appInfo.permissions.empty()) { RemoveDuplicateName(appInfo.permissions); } + appInfo.appIndex = appIndex; } ErrCode InnerBundleInfo::GetApplicationInfoV9(int32_t flags, int32_t userId, ApplicationInfo &appInfo, @@ -1464,8 +1465,8 @@ bool InnerBundleInfo::GetBundleInfo(int32_t flags, BundleInfo &bundleInfo, int32 } bundleInfo.reqPermissionDetails = GetAllRequestPermissions(); } - GetBundleWithAbilities(flags, bundleInfo, userId); - GetBundleWithExtension(flags, bundleInfo, userId); + GetBundleWithAbilities(flags, bundleInfo, appIndex, userId); + GetBundleWithExtension(flags, bundleInfo, appIndex, userId); return true; } @@ -1524,6 +1525,7 @@ void InnerBundleInfo::ProcessBundleFlags( bundleInfo.applicationInfo, appIndex); } } + bundleInfo.applicationInfo.appIndex = appIndex; GetBundleWithReqPermissionsV9(flags, userId, bundleInfo, appIndex); ProcessBundleWithHapModuleInfoFlag(flags, bundleInfo, userId, appIndex); if ((static_cast(flags) & static_cast(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_SIGNATURE_INFO)) @@ -1623,7 +1625,7 @@ void InnerBundleInfo::ProcessBundleWithHapModuleInfoFlag( } GetBundleWithAbilitiesV9(flags, hapModuleInfo, userId, appIndex); - GetBundleWithExtensionAbilitiesV9(flags, hapModuleInfo); + GetBundleWithExtensionAbilitiesV9(flags, hapModuleInfo, appIndex); bundleInfo.hapModuleInfos.emplace_back(hapModuleInfo); } } @@ -1651,6 +1653,7 @@ void InnerBundleInfo::GetBundleWithAbilitiesV9( } AbilityInfo abilityInfo = ability.second; abilityInfo.enabled = isEnabled; + abilityInfo.appIndex = appIndex; if ((static_cast(flags) & static_cast(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_METADATA)) != static_cast(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_METADATA)) { @@ -1666,7 +1669,8 @@ void InnerBundleInfo::GetBundleWithAbilitiesV9( } } -void InnerBundleInfo::GetBundleWithExtensionAbilitiesV9(int32_t flags, HapModuleInfo &hapModuleInfo) const +void InnerBundleInfo::GetBundleWithExtensionAbilitiesV9( + int32_t flags, HapModuleInfo &hapModuleInfo, int32_t appIndex) const { hapModuleInfo.extensionInfos.clear(); if ((static_cast(flags) & @@ -1680,6 +1684,7 @@ void InnerBundleInfo::GetBundleWithExtensionAbilitiesV9(int32_t flags, HapModule continue; } ExtensionAbilityInfo info = extensionInfo.second; + info.appIndex = appIndex; if ((static_cast(flags) & static_cast(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_METADATA)) != static_cast(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_METADATA)) { @@ -1693,7 +1698,8 @@ void InnerBundleInfo::GetBundleWithExtensionAbilitiesV9(int32_t flags, HapModule } } -void InnerBundleInfo::GetBundleWithAbilities(int32_t flags, BundleInfo &bundleInfo, int32_t userId) const +void InnerBundleInfo::GetBundleWithAbilities( + int32_t flags, BundleInfo &bundleInfo, int32_t appIndex, int32_t userId) const { APP_LOGD("bundleName:%{public}s userid:%{public}d", bundleInfo.name.c_str(), userId); if (static_cast(flags) & GET_BUNDLE_WITH_ABILITIES) { @@ -1712,12 +1718,14 @@ void InnerBundleInfo::GetBundleWithAbilities(int32_t flags, BundleInfo &bundleIn if ((static_cast(flags) & GET_BUNDLE_WITH_SKILL) != GET_BUNDLE_WITH_SKILL) { abilityInfo.skills.clear(); } + abilityInfo.appIndex = appIndex; bundleInfo.abilityInfos.emplace_back(abilityInfo); } } } -void InnerBundleInfo::GetBundleWithExtension(int32_t flags, BundleInfo &bundleInfo, int32_t userId) const +void InnerBundleInfo::GetBundleWithExtension( + int32_t flags, BundleInfo &bundleInfo, int32_t appIndex, int32_t userId) const { APP_LOGD("get bundleInfo with extensionInfo begin"); if ((static_cast(flags) & GET_BUNDLE_WITH_EXTENSION_INFO) == GET_BUNDLE_WITH_EXTENSION_INFO) { @@ -1729,6 +1737,7 @@ void InnerBundleInfo::GetBundleWithExtension(int32_t flags, BundleInfo &bundleIn if ((static_cast(flags) & GET_BUNDLE_WITH_SKILL) != GET_BUNDLE_WITH_SKILL) { info.skills.clear(); } + info.appIndex = appIndex; bundleInfo.extensionInfos.emplace_back(info); } } From 285bd59addcd23f641ae91f6e90e0ad023e9205c Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Tue, 4 Jun 2024 09:15:07 +0000 Subject: [PATCH 03/23] =?UTF-8?q?quick=5Ffix=5Ftest=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E8=BF=90=E8=A1=8Ccrash=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei --- .../bms_bundle_quick_fix_test.cpp | 63 +++++++++++++------ 1 file changed, 45 insertions(+), 18 deletions(-) diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/bms_bundle_quick_fix_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/bms_bundle_quick_fix_test.cpp index 5d015b95f..ca6cd8d6f 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/bms_bundle_quick_fix_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/bms_bundle_quick_fix_test.cpp @@ -370,22 +370,7 @@ AppQuickFix BmsBundleQuickFixTest::CreateAppQuickFix() sptr BmsBundleQuickFixTest::GetQuickFixManagerProxy() { - auto systemAbilityManager = OHOS::SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); - if (systemAbilityManager == nullptr) { - APP_LOGE("GetSystemAbilityManager failed."); - return nullptr; - } - auto bundleMgrSa = systemAbilityManager->GetSystemAbility(OHOS::BUNDLE_MGR_SERVICE_SYS_ABILITY_ID); - if (bundleMgrSa == nullptr) { - APP_LOGE("GetSystemAbility failed."); - return nullptr; - } - auto bundleMgr = OHOS::iface_cast(bundleMgrSa); - if (bundleMgr == nullptr) { - APP_LOGE("iface_cast failed."); - return nullptr; - } - return bundleMgr->GetQuickFixManagerProxy(); + return bundleMgrService_->GetQuickFixManagerProxy(); } void BmsBundleQuickFixTest::CreateFiles(const std::vector& sourceFiles) @@ -1043,7 +1028,7 @@ HWTEST_F(BmsBundleQuickFixTest, BmsBundleQuickFixTest_0026, Function | SmallTest */ HWTEST_F(BmsBundleQuickFixTest, BmsBundleQuickFixTest_0027, Function | SmallTest | Level0) { - auto quickFixProxy= GetQuickFixManagerProxy(); + auto quickFixProxy = GetQuickFixManagerProxy(); EXPECT_NE(quickFixProxy, nullptr) << "the quickFixProxy is nullptr"; sptr callback = new (std::nothrow) MockQuickFixCallback(); EXPECT_NE(callback, nullptr) << "the callback is nullptr"; @@ -3606,7 +3591,7 @@ HWTEST_F(BmsBundleQuickFixTest, BmsBundleCopyFiles_0003, Function | SmallTest | CreateFiles(sourceFiles); std::vector destFiles = {"hello.hqf"}; ErrCode ret = quickFixProxy->CopyFiles(sourceFiles, destFiles); - EXPECT_EQ(ret, ERR_BUNDLEMANAGER_QUICK_FIX_PARAM_ERROR); + EXPECT_EQ(ret, ERR_BUNDLEMANAGER_QUICK_FIX_INTERNAL_ERROR); DeleteFiles(sourceFiles); DeleteFiles(destFiles); } @@ -3883,6 +3868,48 @@ HWTEST_F(BmsBundleQuickFixTest, QuickFixer_0100, Function | SmallTest | Level0) EXPECT_EQ(fixer.statusCallback_, nullptr); } +/** + * @tc.number: QuickFixMgr_0100 + * @tc.name: Test QuickFixMgr + * @tc.desc: 1.Test QuickFixMgr + */ +HWTEST_F(BmsBundleQuickFixTest, QuickFixMgr_0100, Function | SmallTest | Level0) +{ + sptr statusCallback; + QuickFixMgr quickFixMgr; + const std::vector bundleFilePaths; + auto ret = quickFixMgr.DeployQuickFix(bundleFilePaths, statusCallback); + EXPECT_EQ(ret, ERR_OK); + ret = quickFixMgr.SwitchQuickFix("", false, statusCallback); + EXPECT_EQ(ret, ERR_OK); + ret = quickFixMgr.DeleteQuickFix("", statusCallback); + EXPECT_EQ(ret, ERR_OK); +} + +/** + * @tc.number: QuickFixManagerHostImpl_0100 + * @tc.name: Test QuickFixManagerHostImpl + * @tc.desc: 1.Test the failed scene of QuickFixManagerHostImpl + */ +HWTEST_F(BmsBundleQuickFixTest, QuickFixManagerHostImpl_0100, Function | SmallTest | Level0) +{ + sptr statusCallback; + QuickFixManagerHostImpl quickFixMgrHostImpl; + const std::vector bundleFilePaths; + auto ret = quickFixMgrHostImpl.DeployQuickFix(bundleFilePaths, statusCallback); + EXPECT_EQ(ret, ERR_BUNDLEMANAGER_QUICK_FIX_PARAM_ERROR); + ret = quickFixMgrHostImpl.SwitchQuickFix("", false, statusCallback); + EXPECT_EQ(ret, ERR_BUNDLEMANAGER_QUICK_FIX_PARAM_ERROR); + ret = quickFixMgrHostImpl.DeleteQuickFix("", statusCallback); + EXPECT_EQ(ret, ERR_BUNDLEMANAGER_QUICK_FIX_PARAM_ERROR); + + std::string fileName = ""; + int32_t fd = 0; + std::string path; + auto res = quickFixMgrHostImpl.CreateFd(fileName, fd, path); + EXPECT_EQ(ret, ERR_BUNDLEMANAGER_QUICK_FIX_PARAM_ERROR); +} + /** * @tc.number: QuickFixDataMgr_0100 * @tc.name: Test QuickFixDataMgr From 37ffc2bc3b684a1fd3e40f523b6296d2b0072432 Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Wed, 5 Jun 2024 03:16:17 +0000 Subject: [PATCH 04/23] =?UTF-8?q?=E5=A2=9E=E5=8A=A0quick=5Ffix=20TDD?= =?UTF-8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bms_bundle_quick_fix_test.cpp | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/bms_bundle_quick_fix_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/bms_bundle_quick_fix_test.cpp index ca6cd8d6f..3012e23ce 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/bms_bundle_quick_fix_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/bms_bundle_quick_fix_test.cpp @@ -3910,6 +3910,38 @@ HWTEST_F(BmsBundleQuickFixTest, QuickFixManagerHostImpl_0100, Function | SmallTe EXPECT_EQ(ret, ERR_BUNDLEMANAGER_QUICK_FIX_PARAM_ERROR); } +/** + * @tc.number: QuickFixManagerHostImpl_0200 + * @tc.name: Test QuickFixManagerHostImpl.IsFileNameValid + * @tc.desc: 1.Test QuickFixManagerHostImpl.IsFileNameValid + */ +HWTEST_F(BmsBundleQuickFixTest, QuickFixManagerHostImpl_0200, Function | SmallTest | Level0) +{ + QuickFixManagerHostImpl quickFixMgrHostImpl; + + auto ret = quickFixMgrHostImpl.IsFileNameValid(INVALID_FILE_NAME); + EXPECT_FALSE(ret); + ret = quickFixMgrHostImpl.IsFileNameValid(VALID_FILE_NAME); + EXPECT_EQ(ret, true); +} + +/** + * @tc.number: QuickFixManagerHostImpl_0300 + * @tc.name: Test QuickFixManagerHostImpl.IsFileNameValid + * @tc.desc: 1.Test QuickFixManagerHostImpl.IsFileNameValid + */ +HWTEST_F(BmsBundleQuickFixTest, QuickFixManagerHostImpl_0300, Function | SmallTest | Level0) +{ + QuickFixManagerHostImpl quickFixMgrHostImpl; + std::vector bundleFilePaths; + bundleFilePaths.push_back(VALID_FILE_PATH_3); + + std::vector securityFilePaths; + + auto ret = quickFixMgrHostImpl.CopyHqfToSecurityDir(bundleFilePaths, securityFilePaths); + EXPECT_EQ(ret, ERR_BUNDLEMANAGER_QUICK_FIX_MOVE_PATCH_FILE_FAILED); +} + /** * @tc.number: QuickFixDataMgr_0100 * @tc.name: Test QuickFixDataMgr From f9a8d3ce5b15895778223b734a8aebe67cdb2358 Mon Sep 17 00:00:00 2001 From: jiangminsen Date: Wed, 5 Jun 2024 11:23:10 +0800 Subject: [PATCH 05/23] getBundleInfoforSelf add env crean_hook Signed-off-by: jiangminsen --- interfaces/kits/js/bundle_manager/bundle_manager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/interfaces/kits/js/bundle_manager/bundle_manager.cpp b/interfaces/kits/js/bundle_manager/bundle_manager.cpp index 714194fe8..1b0869034 100644 --- a/interfaces/kits/js/bundle_manager/bundle_manager.cpp +++ b/interfaces/kits/js/bundle_manager/bundle_manager.cpp @@ -4549,6 +4549,7 @@ napi_value GetBundleInfoForSelfSync(napi_env env, napi_callback_info info) { APP_LOGD("GetBundleInfoForSelfSync called"); NapiArg args(env, info); + napi_add_env_cleanup_hook(env, HandleCleanEnv, env); if (!args.Init(ARGS_SIZE_ONE, ARGS_SIZE_ONE)) { APP_LOGE("param count invalid"); BusinessError::ThrowTooFewParametersError(env, ERROR_PARAM_CHECK_ERROR); From 4207d63824f6aa93add16fe9d409d40adc241a68 Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Wed, 5 Jun 2024 03:16:17 +0000 Subject: [PATCH 06/23] =?UTF-8?q?=E5=A2=9E=E5=8A=A0quick=5Ffix=20TDD?= =?UTF-8?q?=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bms_bundle_quick_fix_test.cpp | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/bms_bundle_quick_fix_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/bms_bundle_quick_fix_test.cpp index ca6cd8d6f..4beb8b053 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/bms_bundle_quick_fix_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/bms_bundle_quick_fix_test.cpp @@ -81,6 +81,8 @@ const std::string INVALID_FILE_SUFFIX_PATH = "/data/test/invalidSuffix.txt"; const std::string INVALID_FILE_PATH_1 = "/data/service/el1/public/bms/bundle_manager_service/hello.hqf"; const std::string INVALID_FILE_PATH_2 = "/data/service/el1/public/bms/bundle_manager_service/quick_fix/../hello.hqf"; const std::string VALID_FILE_PATH_3 = "/data/service/el1/public/bms/bundle_manager_service/quick_fix/hello.hqf"; +const std::string INVALID_FILE_NAME = "..hello.hqf"; +const std::string VALID_FILE_NAME = "hello.hqf"; } // namespace class BmsBundleQuickFixTest : public testing::Test { @@ -3910,6 +3912,38 @@ HWTEST_F(BmsBundleQuickFixTest, QuickFixManagerHostImpl_0100, Function | SmallTe EXPECT_EQ(ret, ERR_BUNDLEMANAGER_QUICK_FIX_PARAM_ERROR); } +/** + * @tc.number: QuickFixManagerHostImpl_0200 + * @tc.name: Test QuickFixManagerHostImpl.IsFileNameValid + * @tc.desc: 1.Test QuickFixManagerHostImpl.IsFileNameValid + */ +HWTEST_F(BmsBundleQuickFixTest, QuickFixManagerHostImpl_0200, Function | SmallTest | Level0) +{ + QuickFixManagerHostImpl quickFixMgrHostImpl; + + auto ret = quickFixMgrHostImpl.IsFileNameValid(INVALID_FILE_NAME); + EXPECT_FALSE(ret); + ret = quickFixMgrHostImpl.IsFileNameValid(VALID_FILE_NAME); + EXPECT_EQ(ret, true); +} + +/** + * @tc.number: QuickFixManagerHostImpl_0300 + * @tc.name: Test QuickFixManagerHostImpl.IsFileNameValid + * @tc.desc: 1.Test QuickFixManagerHostImpl.IsFileNameValid + */ +HWTEST_F(BmsBundleQuickFixTest, QuickFixManagerHostImpl_0300, Function | SmallTest | Level0) +{ + QuickFixManagerHostImpl quickFixMgrHostImpl; + std::vector bundleFilePaths; + bundleFilePaths.push_back(VALID_FILE_PATH_3); + + std::vector securityFilePaths; + + auto ret = quickFixMgrHostImpl.CopyHqfToSecurityDir(bundleFilePaths, securityFilePaths); + EXPECT_EQ(ret, ERR_BUNDLEMANAGER_QUICK_FIX_MOVE_PATCH_FILE_FAILED); +} + /** * @tc.number: QuickFixDataMgr_0100 * @tc.name: Test QuickFixDataMgr From 7caa82e47b136122a6bb89b07efa2cb36acc563f Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Wed, 5 Jun 2024 08:42:54 +0800 Subject: [PATCH 07/23] =?UTF-8?q?bms=5Fbundle=5Fquick=5Ffix=5Ftest=20TDD?= =?UTF-8?q?=20=E5=A2=9E=E5=BC=BA=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei --- .../bms_bundle_quick_fix_test.cpp | 118 +++++++++++++++++- 1 file changed, 117 insertions(+), 1 deletion(-) diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/bms_bundle_quick_fix_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/bms_bundle_quick_fix_test.cpp index 557d500e4..897c80be3 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/bms_bundle_quick_fix_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/bms_bundle_quick_fix_test.cpp @@ -2736,6 +2736,94 @@ HWTEST_F(BmsBundleQuickFixTest, BmsBundleQuickFixTest_0104, Function | SmallTest UninstallBundleInfo(BUNDLE_NAME); } +/** + * @tc.number: BmsBundleQuickFixTest_0105 + * Function: ExtractQuickFixSoFile + * @tc.name: test ExtractQuickFixSoFile + * @tc.require: issueI5N7AD + * @tc.desc: ExtractQuickFixSoFile + */ +HWTEST_F(BmsBundleQuickFixTest, BmsBundleQuickFixTest_0105, Function | SmallTest | Level0) +{ + AddInnerBundleInfo(BUNDLE_NAME); + auto deployer = GetQuickFixDeployer(); + EXPECT_FALSE(deployer == nullptr); + if (deployer != nullptr) { + AppQuickFix appQuickFix; + std::string patchPath = "data/test"; + BundleInfo bundleInfo; + auto ret = deployer->ExtractSoAndApplyDiff(appQuickFix, bundleInfo, patchPath); + EXPECT_EQ(ret, ERR_OK); + + appQuickFix = CreateAppQuickFix(); + ret = deployer->ExtractSoAndApplyDiff(appQuickFix, bundleInfo, patchPath); + EXPECT_EQ(ret, ERR_OK); + + HapModuleInfo info; + info.moduleName = "entry"; + bundleInfo.hapModuleInfos.emplace_back(info); + + ret = deployer->ExtractSoAndApplyDiff(appQuickFix, bundleInfo, patchPath); + EXPECT_EQ(ret, ERR_OK); + // so exist + appQuickFix.deployingAppqfInfo.nativeLibraryPath = QUICK_FIX_SO_PATH; + ret = deployer->ExtractSoAndApplyDiff(appQuickFix, bundleInfo, patchPath); + EXPECT_EQ(ret, ERR_OK); + } + UninstallBundleInfo(BUNDLE_NAME); +} + +/** + * @tc.number: BmsBundleQuickFixTest_0106 + * Function: ExtractQuickFixSoFile + * @tc.name: test ExtractQuickFixSoFile + * @tc.require: issueI5N7AD + * @tc.desc: ExtractQuickFixSoFile + */ +HWTEST_F(BmsBundleQuickFixTest, BmsBundleQuickFixTest_0106, Function | SmallTest | Level0) +{ + AddInnerBundleInfo(BUNDLE_NAME); + auto deployer = GetQuickFixDeployer(); + EXPECT_FALSE(deployer == nullptr); + if (deployer != nullptr) { + AppQuickFix appQuickFix; + std::string patchPath = "data/test"; + BundleInfo bundleInfo; + appQuickFix = CreateAppQuickFix(); + appQuickFix.bundleName = "error"; + auto ret = deployer->ExtractSoAndApplyDiff(appQuickFix, bundleInfo, patchPath); + EXPECT_EQ(ret, ERR_BUNDLEMANAGER_QUICK_FIX_BUNDLE_NAME_NOT_EXIST); + } + UninstallBundleInfo(BUNDLE_NAME); +} + +/** + * @tc.number: BmsBundleQuickFixTest_0107 + * Function: ExtractQuickFixSoFile + * @tc.name: test ExtractQuickFixSoFile + * @tc.require: issueI5N7AD + * @tc.desc: ExtractQuickFixSoFile + */ +HWTEST_F(BmsBundleQuickFixTest, BmsBundleQuickFixTest_0107, Function | SmallTest | Level0) +{ + AddInnerBundleInfo(BUNDLE_NAME); + auto deployer = GetQuickFixDeployer(); + EXPECT_FALSE(deployer == nullptr); + if (deployer != nullptr) { + AppQuickFix appQuickFix; + std::string patchPath = "data/test"; + BundleInfo bundleInfo; + appQuickFix = CreateAppQuickFix(); + auto &appQfInfo = appQuickFix.deployingAppqfInfo; + for (auto &hqf : appQfInfo.hqfInfos) { + hqf.moduleName = "name"; + } + auto ret = deployer->ExtractSoAndApplyDiff(appQuickFix, bundleInfo, patchPath); + EXPECT_EQ(ret, ERR_OK); + } + UninstallBundleInfo(BUNDLE_NAME); +} + /** * @tc.number: BmsBundleQuickFixTest_0110 * Function: DefaultNativeSo @@ -3839,7 +3927,6 @@ HWTEST_F(BmsBundleQuickFixTest, QuickFixDeployer_0200, Function | SmallTest | Le UninstallBundleInfo(BUNDLE_NAME); } - /** * @tc.number: QuickFixDeployer_0400 * @tc.name: Test ProcessHotReloadDeployEnd with Execute @@ -4626,6 +4713,35 @@ HWTEST_F(BmsBundleQuickFixTest, BmsBundleQuickFixTest_0490, Function | SmallTest DelayedSingleton::GetInstance()->dataMgr_ = dataMgr; } +/** + * @tc.number: BmsBundleQuickFixTest_0610 + * Function: PrepareCodeSignatureParam + * @tc.name: test PrepareCodeSignatureParam + * @tc.require: issueI5N7AD + * @tc.desc: PrepareCodeSignatureParam + */ +HWTEST_F(BmsBundleQuickFixTest, BmsBundleQuickFixTest_0610, Function | SmallTest | Level0) +{ + AddInnerBundleInfo(BUNDLE_NAME_DEMO); + + auto deployer = GetQuickFixDeployer(); + EXPECT_FALSE(deployer == nullptr); + if (deployer != nullptr) { + AppQuickFix appQuickFix = CreateAppQuickFix(); + appQuickFix.bundleName = BUNDLE_NAME_DEMO; + appQuickFix.deployingAppqfInfo.nativeLibraryPath = QUICK_FIX_SO_PATH; + + HqfInfo hqf; + BundleInfo bundleInfo; + bundleInfo.applicationInfo.compileSdkType = ""; + std::string hqfSoPath = "/data/test/"; + CodeSignatureParam codeSignatureParam; + deployer->PrepareCodeSignatureParam(appQuickFix, hqf, bundleInfo, hqfSoPath, codeSignatureParam); + EXPECT_EQ(codeSignatureParam.isCompileSdkOpenHarmony, false); + } + UninstallBundleInfo(BUNDLE_NAME_DEMO); +} + /** * @tc.number: DeployQuickFix_0001 * Function: DeployQuickFix From 4221bf3dfd54b538249c975b5ca4e0e748806358 Mon Sep 17 00:00:00 2001 From: zhubingwei Date: Wed, 5 Jun 2024 11:27:10 +0800 Subject: [PATCH 08/23] =?UTF-8?q?=E8=A1=A5=E5=85=85bms=5Fbundle=5Fquick=5F?= =?UTF-8?q?fix=20TDD=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhubingwei --- .../bms_bundle_quick_fix_deleter_test.cpp | 104 ++++++++++++++++++ .../bms_bundle_quick_fix_switcher_test.cpp | 53 +++++++++ 2 files changed, 157 insertions(+) diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_deleter_test/bms_bundle_quick_fix_deleter_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_deleter_test/bms_bundle_quick_fix_deleter_test.cpp index 4b2e05d05..17a9935ca 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_deleter_test/bms_bundle_quick_fix_deleter_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_deleter_test/bms_bundle_quick_fix_deleter_test.cpp @@ -24,6 +24,7 @@ #include "mock_quick_fix_callback.h" #include "nlohmann/json.hpp" #include "system_bundle_installer.h" +#include "quick_fix_deleter.h" using namespace testing::ext; using namespace std::chrono_literals; @@ -220,4 +221,107 @@ HWTEST_F(BmsBundleQuickFixDeleterTest, BmsBundleQuickFixDeleterTest_0500, Functi EXPECT_EQ(result, ERR_OK); CheckResult(callback, BUNDLE_NAME, ERR_OK); } + +/** + * @tc.number: BmsBundleQuickFixDeleterTest_0600 + * Function: Execute + * @tc.desc: 1. system running normally + * 2. test QuickFixDeleter + */ +HWTEST_F(BmsBundleQuickFixDeleterTest, BmsBundleQuickFixDeleterTest_0600, Function | SmallTest | Level0) +{ + std::shared_ptr quickFixDeleter = std::make_shared(""); + ErrCode result = quickFixDeleter->Execute(); + EXPECT_EQ(result, ERR_BUNDLEMANAGER_QUICK_FIX_PARAM_ERROR); +} + +/** + * @tc.number: BmsBundleQuickFixDeleterTest_0700 + * Function: Execute + * @tc.desc: 1. system running normally + * 2. test QuickFixDeleter + */ +HWTEST_F(BmsBundleQuickFixDeleterTest, BmsBundleQuickFixDeleterTest_0700, Function | SmallTest | Level0) +{ + std::shared_ptr quickFixDeleter = std::make_shared(BUNDLE_NAME); + ErrCode result = quickFixDeleter->Execute(); + EXPECT_EQ(result, ERR_OK); +} + +/** + * @tc.number: BmsBundleQuickFixDeleterTest_0800 + * Function: AddHqfInfo + * @tc.desc: 1. system running normally + * 2. test InnerAppQuickFix + */ +HWTEST_F(BmsBundleQuickFixDeleterTest, BmsBundleQuickFixDeleterTest_0800, Function | SmallTest | Level0) +{ + AppQuickFix appQuickFix; + QuickFixMark mark; + std::shared_ptr innerAppQuickFix = std::make_shared(appQuickFix, mark); + ErrCode result = innerAppQuickFix->AddHqfInfo(appQuickFix); + EXPECT_EQ(result, false); +} + +/** + * @tc.number: BmsBundleQuickFixDeleterTest_0900 + * Function: AddHqfInfo + * @tc.desc: 1. system running normally + * 2. test InnerAppQuickFix + */ +HWTEST_F(BmsBundleQuickFixDeleterTest, BmsBundleQuickFixDeleterTest_0900, Function | SmallTest | Level0) +{ + AppQuickFix appQuickFix; + HqfInfo hqfInfo; + hqfInfo.moduleName = "moduleName"; + hqfInfo.hapSha256 = "hapSha256"; + hqfInfo.hqfFilePath = "/data/test/"; + appQuickFix.deployingAppqfInfo.hqfInfos.emplace_back(hqfInfo); + QuickFixMark mark; + std::shared_ptr innerAppQuickFix = std::make_shared(appQuickFix, mark); + ErrCode result = innerAppQuickFix->AddHqfInfo(appQuickFix); + EXPECT_EQ(result, true); +} + +/** + * @tc.number: BmsBundleQuickFixDeleterTest_1000 + * Function: RemoveHqfInfo + * @tc.desc: 1. system running normally + * 2. test InnerAppQuickFix + */ +HWTEST_F(BmsBundleQuickFixDeleterTest, BmsBundleQuickFixDeleterTest_1000, Function | SmallTest | Level0) +{ + AppQuickFix appQuickFix; + HqfInfo hqfInfo; + hqfInfo.moduleName = "moduleName"; + hqfInfo.hapSha256 = "hapSha256"; + hqfInfo.hqfFilePath = "/data/test/"; + appQuickFix.deployingAppqfInfo.hqfInfos.emplace_back(hqfInfo); + QuickFixMark mark; + std::shared_ptr innerAppQuickFix = std::make_shared(appQuickFix, mark); + innerAppQuickFix->SetAppQuickFix(appQuickFix); + ErrCode result = innerAppQuickFix->RemoveHqfInfo("moduleNameNo"); + EXPECT_EQ(result, false); +} + +/** + * @tc.number: BmsBundleQuickFixDeleterTest_1100 + * Function: RemoveHqfInfo + * @tc.desc: 1. system running normally + * 2. test InnerAppQuickFix + */ +HWTEST_F(BmsBundleQuickFixDeleterTest, BmsBundleQuickFixDeleterTest_1100, Function | SmallTest | Level0) +{ + AppQuickFix appQuickFix; + HqfInfo hqfInfo; + hqfInfo.moduleName = "moduleName"; + hqfInfo.hapSha256 = "hapSha256"; + hqfInfo.hqfFilePath = "/data/test/"; + appQuickFix.deployingAppqfInfo.hqfInfos.emplace_back(hqfInfo); + QuickFixMark mark; + std::shared_ptr innerAppQuickFix = std::make_shared(appQuickFix, mark); + innerAppQuickFix->SetAppQuickFix(appQuickFix); + ErrCode result = innerAppQuickFix->RemoveHqfInfo("moduleName"); + EXPECT_EQ(result, true); +} } // OHOS \ No newline at end of file diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_switcher_test/bms_bundle_quick_fix_switcher_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_switcher_test/bms_bundle_quick_fix_switcher_test.cpp index 5431a1faf..afba6542b 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_switcher_test/bms_bundle_quick_fix_switcher_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_switcher_test/bms_bundle_quick_fix_switcher_test.cpp @@ -28,6 +28,7 @@ #include "mock_status_receiver.h" #include "nlohmann/json.hpp" #include "system_bundle_installer.h" +#include "quick_fix_switcher.h" using namespace testing::ext; using namespace std::chrono_literals; @@ -596,4 +597,56 @@ HWTEST_F(BmsBundleQuickFixSwitcherTest, BmsBundleQuickFixSwitcherTest_1500, Func ret = UninstallBundle(BUNDLE_NAME); EXPECT_EQ(ret, ERR_OK) << "Uninstall bundle com.example.l3jsdemo failed"; } + +/** + * @tc.number: BmsBundleQuickFixSwitcherTest_1600 + * Function: Execute + * @tc.desc: 1. system running normally + * 2. test QuickFixSwitcher + */ +HWTEST_F(BmsBundleQuickFixSwitcherTest, BmsBundleQuickFixSwitcherTest_1600, Function | SmallTest | Level0) +{ + std::shared_ptr quickFixSwitcher = std::make_shared("", false); + ErrCode result = quickFixSwitcher->Execute(); + EXPECT_EQ(result, ERR_BUNDLEMANAGER_QUICK_FIX_PARAM_ERROR); +} + +/** + * @tc.number: BmsBundleQuickFixSwitcherTest_1700 + * Function: Execute + * @tc.desc: 1. system running normally + * 2. test QuickFixSwitcher + */ +HWTEST_F(BmsBundleQuickFixSwitcherTest, BmsBundleQuickFixSwitcherTest_1700, Function | SmallTest | Level0) +{ + std::shared_ptr quickFixSwitcher = std::make_shared("", true); + ErrCode result = quickFixSwitcher->Execute(); + EXPECT_EQ(result, ERR_BUNDLEMANAGER_QUICK_FIX_PARAM_ERROR); +} + +/** + * @tc.number: BmsBundleQuickFixSwitcherTest_1800 + * Function: Execute + * @tc.desc: 1. system running normally + * 2. test QuickFixSwitcher + */ +HWTEST_F(BmsBundleQuickFixSwitcherTest, BmsBundleQuickFixSwitcherTest_1800, Function | SmallTest | Level0) +{ + std::shared_ptr quickFixSwitcher = std::make_shared(BUNDLE_NAME, false); + ErrCode result = quickFixSwitcher->Execute(); + EXPECT_EQ(result, ERR_BUNDLEMANAGER_QUICK_FIX_NOT_EXISTED_BUNDLE_INFO); +} + +/** + * @tc.number: BmsBundleQuickFixSwitcherTest_1900 + * Function: Execute + * @tc.desc: 1. system running normally + * 2. test QuickFixSwitcher + */ +HWTEST_F(BmsBundleQuickFixSwitcherTest, BmsBundleQuickFixSwitcherTest_1900, Function | SmallTest | Level0) +{ + std::shared_ptr quickFixSwitcher = std::make_shared(BUNDLE_NAME, true); + ErrCode result = quickFixSwitcher->Execute(); + EXPECT_EQ(result, ERR_BUNDLEMANAGER_QUICK_FIX_NO_PATCH_IN_DATABASE); +} } // OHOS \ No newline at end of file From 32808100883fb105707a1eba46f410878593e35d Mon Sep 17 00:00:00 2001 From: zhaogan Date: Tue, 4 Jun 2024 12:14:29 +0800 Subject: [PATCH 09/23] create extension dir for preinstall Signed-off-by: zhaogan --- .../bundlemgr/include/base_bundle_installer.h | 1 + .../bundlemgr/src/base_bundle_installer.cpp | 38 ++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/services/bundlemgr/include/base_bundle_installer.h b/services/bundlemgr/include/base_bundle_installer.h index f5dabfb83..e6c164f88 100644 --- a/services/bundlemgr/include/base_bundle_installer.h +++ b/services/bundlemgr/include/base_bundle_installer.h @@ -636,6 +636,7 @@ private: ErrCode GetRemoveDataGroupDirs(const InnerBundleInfo &oldInfo, const InnerBundleInfo &newInfo); ErrCode RemoveOldGroupDirs() const; ErrCode CreateGroupDirs() const; + void CreateDataGroupDir(InnerBundleInfo &info) const; ErrCode GetDataGroupCreateInfos(const InnerBundleInfo &newInfo); ErrCode RemoveDataGroupDirs(const std::string &bundleName, int32_t userId) const; void DeleteGroupDirsForException() const; diff --git a/services/bundlemgr/src/base_bundle_installer.cpp b/services/bundlemgr/src/base_bundle_installer.cpp index 41452772c..b5d213025 100644 --- a/services/bundlemgr/src/base_bundle_installer.cpp +++ b/services/bundlemgr/src/base_bundle_installer.cpp @@ -1712,7 +1712,10 @@ ErrCode BaseBundleInstaller::InnerProcessInstallByPreInstallInfo( if (result != ERR_OK) { return result; } - + std::vector extensionDirs = oldInfo.GetAllExtensionDirs(); + createExtensionDirs_.assign(extensionDirs.begin(), extensionDirs.end()); + CreateExtensionDataDir(oldInfo); + CreateDataGroupDir(oldInfo); // extract ap file result = ExtractAllArkProfileFile(oldInfo); if (result != ERR_OK) { @@ -3478,6 +3481,39 @@ void BaseBundleInstaller::CreateExtensionDataDir(InnerBundleInfo &info) const } } +void BaseBundleInstaller::CreateDataGroupDir(InnerBundleInfo &info) const +{ + if (dataMgr_ == nullptr) { + APP_LOGE("dataMgr_ is nullptr"); + return; + } + std::vector dataGroupInfos; + if (!dataMgr_->QueryDataGroupInfos(info.GetBundleName(), userId_, dataGroupInfos)) { + APP_LOGW("query group info for bundle %{public}s userId %{public}d failed", + info.GetBundleName().c_str(), userId_); + return; + } + if (dataGroupInfos.empty()) { + return; + } + + for (const DataGroupInfo &dataGroupInfo : dataGroupInfos) { + std::string dir = ServiceConstants::REAL_DATA_PATH + ServiceConstants::PATH_SEPARATOR + + std::to_string(userId_) + ServiceConstants::DATA_GROUP_PATH + dataGroupInfo.uuid; + bool dirExist = false; + auto result = InstalldClient::GetInstance()->IsExistDir(dir, dirExist); + if (result == ERR_OK && dirExist) { + continue; + } + APP_LOGD("create group dir: %{public}s", dir.c_str()); + result = InstalldClient::GetInstance()->Mkdir(dir, + DATA_GROUP_DIR_MODE, dataGroupInfo.uid, dataGroupInfo.gid); + if (result != ERR_OK) { + APP_LOGW("create data group dir %{public}s userId %{public}d failed", dataGroupInfo.uuid.c_str(), userId_); + } + } +} + void BaseBundleInstaller::GetCreateExtensionDirs(std::unordered_map &newInfos) { for (auto &item : newInfos) { From 09f3773b0a28cb4af97595f573859362581028a6 Mon Sep 17 00:00:00 2001 From: wangtiantian Date: Sun, 26 May 2024 20:34:31 +0800 Subject: [PATCH 10/23] IssueNo:#I9S5K7 Description:add badge resource Sig:SIG_ApplicaitonFramework Feature or Bugfix:Bugfix Binary Source:No Signed-off-by: wangtiantian --- .../bundle_resource_drawable.h | 11 +++ .../bundle_resource/bundle_resource_parser.h | 3 + .../bundle_resource_drawable.cpp | 28 ++++++ .../bundle_resource_manager.cpp | 6 ++ .../bundle_resource_parser.cpp | 85 +++++++++++++++++++ 5 files changed, 133 insertions(+) diff --git a/services/bundlemgr/include/bundle_resource/bundle_resource_drawable.h b/services/bundlemgr/include/bundle_resource/bundle_resource_drawable.h index e5923e12f..e8888c3e5 100644 --- a/services/bundlemgr/include/bundle_resource/bundle_resource_drawable.h +++ b/services/bundlemgr/include/bundle_resource/bundle_resource_drawable.h @@ -21,6 +21,10 @@ #include "resource_manager.h" #include "resource_info.h" +#ifdef BUNDLE_FRAMEWORK_GRAPHICS +#include "pixel_map.h" +#endif + namespace OHOS { namespace AppExecFwk { class BundleResourceDrawable { @@ -30,6 +34,13 @@ public: const int32_t density, std::shared_ptr resourceManager, ResourceInfo &resourceInfo); + +#ifdef BUNDLE_FRAMEWORK_GRAPHICS + bool GetBadgedIconResource( + const std::shared_ptr layeredPixelMap, + const std::shared_ptr badgedPixelMap, + ResourceInfo &resourceInfo); +#endif }; } // AppExecFwk } // OHOS diff --git a/services/bundlemgr/include/bundle_resource/bundle_resource_parser.h b/services/bundlemgr/include/bundle_resource/bundle_resource_parser.h index a288e5875..c77142b46 100644 --- a/services/bundlemgr/include/bundle_resource/bundle_resource_parser.h +++ b/services/bundlemgr/include/bundle_resource/bundle_resource_parser.h @@ -38,6 +38,9 @@ public: // parse icon resource by hapPath bool ParseIconResourceByPath(const std::string &hapPath, const int32_t iconId, ResourceInfo &resourceInfo); + // parse clone bundle resource info + bool ParserCloneResourceInfo(const int32_t appIndex, std::vector &resourceInfos); + private: // for defaultIconPath is empty, icon and label exist in same hap. bool ParseResourceInfoWithSameHap(const int32_t userId, ResourceInfo &resourceInfo); diff --git a/services/bundlemgr/src/bundle_resource/bundle_resource_drawable.cpp b/services/bundlemgr/src/bundle_resource/bundle_resource_drawable.cpp index 9c0c11ab6..34045949b 100644 --- a/services/bundlemgr/src/bundle_resource/bundle_resource_drawable.cpp +++ b/services/bundlemgr/src/bundle_resource/bundle_resource_drawable.cpp @@ -73,5 +73,33 @@ bool BundleResourceDrawable::GetIconResourceByDrawable( return false; #endif } + +#ifdef BUNDLE_FRAMEWORK_GRAPHICS +bool BundleResourceDrawable::GetBadgedIconResource( + const std::shared_ptr layeredPixelMap, + const std::shared_ptr badgedPixelMap, + ResourceInfo &resourceInfo) +{ + if ((layeredPixelMap == nullptr) || (badgedPixelMap == nullptr)) { + LOG_E(BMS_TAG_DEFAULT, "wtt bundleName:%{public}s layered or badge pixelMap are nullptr", + resourceInfo.bundleName_.c_str()); + return false; + } + Ace::Napi::LayeredDrawableDescriptor layeredDrawableDescriptor; + std::shared_ptr compositePixelMap; + if (!layeredDrawableDescriptor.GetCompositePixelMapWithBadge(layeredPixelMap, badgedPixelMap, compositePixelMap)) { + LOG_E(BMS_TAG_DEFAULT, "wtt bundleName:%{public}s GetCompositePixelMapWithBadge failed", + resourceInfo.bundleName_.c_str()); + return false; + } + if (compositePixelMap == nullptr) { + LOG_E(BMS_TAG_DEFAULT, "wtt bundleName:%{public}s compositePixelMap is nullptr", + resourceInfo.bundleName_.c_str()); + return false; + } + BundleResourceImageInfo info; + return info.ConvertToString(compositePixelMap, resourceInfo.icon_); +} +#endif } // AppExecFwk } // OHOS diff --git a/services/bundlemgr/src/bundle_resource/bundle_resource_manager.cpp b/services/bundlemgr/src/bundle_resource/bundle_resource_manager.cpp index bc5b2ff24..6e81946da 100644 --- a/services/bundlemgr/src/bundle_resource/bundle_resource_manager.cpp +++ b/services/bundlemgr/src/bundle_resource/bundle_resource_manager.cpp @@ -522,6 +522,12 @@ bool BundleResourceManager::AddCloneBundleResourceInfo( return false; } // 2. need to process base icon and badge icon + // BundleResourceParser + BundleResourceParser parser; + if (parser.ParserCloneResourceInfo(appIndex, resourceInfos)) { + APP_LOGE("bundleName:%{public}s appIndex:%{public}d parse clone resource failed", + bundleName.c_str(), appIndex); + } // 3. need delete old clone resource info if (!DeleteCloneBundleResourceInfo(bundleName, appIndex)) { APP_LOGW("delete bundleName:%{public}s appIndex:%{public}d resource failed", bundleName.c_str(), appIndex); diff --git a/services/bundlemgr/src/bundle_resource/bundle_resource_parser.cpp b/services/bundlemgr/src/bundle_resource/bundle_resource_parser.cpp index 7173aa1f7..77df7297b 100644 --- a/services/bundlemgr/src/bundle_resource/bundle_resource_parser.cpp +++ b/services/bundlemgr/src/bundle_resource/bundle_resource_parser.cpp @@ -25,6 +25,11 @@ #include "bundle_resource_drawable.h" #include "json_util.h" +#ifdef BUNDLE_FRAMEWORK_GRAPHICS +#include "image_source.h" +#include "pixel_map.h" +#endif + namespace OHOS { namespace AppExecFwk { namespace { @@ -34,6 +39,9 @@ const char* FOREGROUND = "foreground"; const char* BACKGROUND = "background"; const char CHAR_COLON = ':'; const char* LAYERED_IMAGE = "layered-image"; +#ifdef BUNDLE_FRAMEWORK_GRAPHICS +const std::string OHOS_CLONE_APP_BADGE_RESOURCE = "ohos_clone_app_badge_"; +#endif struct LayeredImage { std::string foreground; @@ -427,5 +435,82 @@ void BundleResourceParser::ProcessResourceInfoWhenParseFailed( newResourceInfo.background_ = newResourceInfo.background_.empty() ? oldResourceInfo.background_ : newResourceInfo.background_; } + +bool BundleResourceParser::ParserCloneResourceInfo( + const int32_t appIndex, std::vector &resourceInfos) +{ +#ifdef BUNDLE_FRAMEWORK_GRAPHICS + APP_LOGI("wtt parse clone resource info appIndex:%{public}d start", appIndex); + // 1. get badge resource media + std::string resourceName = OHOS_CLONE_APP_BADGE_RESOURCE + std::to_string(appIndex); + APP_LOGI("wtt resource Name:%{public}s", resourceName.c_str()); + std::shared_ptr resMgr(Global::Resource::CreateResourceManager()); + if (!resMgr) { + APP_LOGE("wtt InitResMgr resMgr is nullptr"); + return false; + } + std::unique_ptr resConfig(Global::Resource::CreateResConfig()); + if (!resConfig) { + APP_LOGE("wtt InitResMgr resConfig is nullptr"); + return false; + } + resMgr->UpdateResConfig(*resConfig); + std::unique_ptr badgeResourceData; + size_t badgeResourceDataLength = 0; + auto ret = resMgr->GetMediaDataByName(resourceName.c_str(), badgeResourceDataLength, badgeResourceData); + if (ret != Global::Resource::RState::SUCCESS) { + APP_LOGE("wtt get badge resource(%{public}s) failed, code:%{public}d", + resourceName.c_str(), static_cast(ret)); + return false; + } + + Media::SourceOptions opts; + uint32_t errorCode = 0; + std::unique_ptr imageSource = + Media::ImageSource::CreateImageSource( + badgeResourceData.get(), badgeResourceDataLength, opts, errorCode); + Media::DecodeOptions decodeOpts; + decodeOpts.desiredPixelFormat = Media::PixelFormat::BGRA_8888; + std::shared_ptr badgePixelMap; + if (imageSource) { + auto pixelMapPtr = imageSource->CreatePixelMap(decodeOpts, errorCode); + badgePixelMap = std::shared_ptr(pixelMapPtr.release()); + } + if (errorCode != 0 || (badgePixelMap == nullptr)) { + APP_LOGE("wtt Get badge failed, errorCode:%{public}u", errorCode); + return false; + } + bool ans = true; + // 2. base64 to pixelMap + for (auto &resourceInfo : resourceInfos) { + APP_LOGI("wtt start"); + std::unique_ptr imageSource = + Media::ImageSource::CreateImageSource(resourceInfo.icon_, opts, errorCode); // base64 to image + Media::DecodeOptions decodeOpts; + decodeOpts.desiredPixelFormat = Media::PixelFormat::BGRA_8888; + std::shared_ptr baseIconResource; + if (imageSource) { + auto pixelMapPtr = imageSource->CreatePixelMap(decodeOpts, errorCode); + baseIconResource = std::shared_ptr(pixelMapPtr.release()); + } + if (errorCode != 0 || !baseIconResource) { + APP_LOGE("wtt Get base icon resource failed"); + ans = false; + continue; + } + // base icon and badge icon resource + BundleResourceDrawable drawable; + if (!drawable.GetBadgedIconResource(baseIconResource, badgePixelMap, resourceInfo)) { + APP_LOGE("wtt failed"); + ans = false; + } + } + APP_LOGI("wtt parse clone resource info appIndex:%{public}d end", appIndex); + return ans; +#else + APP_LOGI("wtt not support pixel map"); + return false; +#endif +} } // AppExecFwk } // OHOS \ No newline at end of file From 21211752605c0a74ab4a5f4c3ab03ad389df5168 Mon Sep 17 00:00:00 2001 From: Zhou Shihui Date: Wed, 5 Jun 2024 16:51:37 +0800 Subject: [PATCH 11/23] =?UTF-8?q?=E8=B0=83=E7=94=A8app=20linking=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=89=8D=E5=88=A4=E6=96=ADuri=E6=98=AF=E5=90=A6https?= =?UTF-8?q?=E5=BC=80=E5=A4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Zhou Shihui --- services/bundlemgr/src/bundle_data_mgr.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/services/bundlemgr/src/bundle_data_mgr.cpp b/services/bundlemgr/src/bundle_data_mgr.cpp index 716487761..1daf08b4c 100644 --- a/services/bundlemgr/src/bundle_data_mgr.cpp +++ b/services/bundlemgr/src/bundle_data_mgr.cpp @@ -99,6 +99,7 @@ constexpr const char* PKG_CONTEXT_PROFILE_PATH = "pkgContextInfo.json"; constexpr const char* PROFILE_PATH = "resources/base/profile/"; constexpr const char* PROFILE_PREFIX = "$profile:"; constexpr const char* JSON_SUFFIX = ".json"; +constexpr const char* SCHEME_HTTPS = "https"; const std::string BMS_EVENT_ADDITIONAL_INFO_CHANGED = "bms.event.ADDITIONAL_INFO_CHANGED"; const std::string ENTRY = "entry"; const std::string CLONE_BUNDLE_PREFIX = "clone_"; @@ -7431,6 +7432,10 @@ void BundleDataMgr::FilterAbilityInfosByAppLinking(const Want &want, int32_t fla APP_LOGD("abilityInfos is empty"); return; } + if (want.GetUriString().rfind(SCHEME_HTTPS, 0) != 0) { + APP_LOGD("scheme is not https"); + return; + } std::vector filteredAbilityInfos; // call FiltedAbilityInfos APP_LOGI("call FilterAbilities"); From 3d444633e8aa3b56dcb3f38da23bab6d5d68e7cb Mon Sep 17 00:00:00 2001 From: wangtiantian Date: Wed, 5 Jun 2024 16:17:41 +0800 Subject: [PATCH 12/23] IssueNo:#I9S5K7 Description:add badge resource Sig:SIG_ApplicaitonFramework Feature or Bugfix:Bugfix Binary Source:No Signed-off-by: wangtiantian --- .../bundle_resource_drawable.cpp | 6 +- .../bundle_resource_parser.cpp | 97 +++++++++++-------- 2 files changed, 58 insertions(+), 45 deletions(-) diff --git a/services/bundlemgr/src/bundle_resource/bundle_resource_drawable.cpp b/services/bundlemgr/src/bundle_resource/bundle_resource_drawable.cpp index 34045949b..18f5a99c9 100644 --- a/services/bundlemgr/src/bundle_resource/bundle_resource_drawable.cpp +++ b/services/bundlemgr/src/bundle_resource/bundle_resource_drawable.cpp @@ -81,19 +81,19 @@ bool BundleResourceDrawable::GetBadgedIconResource( ResourceInfo &resourceInfo) { if ((layeredPixelMap == nullptr) || (badgedPixelMap == nullptr)) { - LOG_E(BMS_TAG_DEFAULT, "wtt bundleName:%{public}s layered or badge pixelMap are nullptr", + LOG_E(BMS_TAG_DEFAULT, "bundleName:%{public}s layered or badge pixelMap are nullptr", resourceInfo.bundleName_.c_str()); return false; } Ace::Napi::LayeredDrawableDescriptor layeredDrawableDescriptor; std::shared_ptr compositePixelMap; if (!layeredDrawableDescriptor.GetCompositePixelMapWithBadge(layeredPixelMap, badgedPixelMap, compositePixelMap)) { - LOG_E(BMS_TAG_DEFAULT, "wtt bundleName:%{public}s GetCompositePixelMapWithBadge failed", + LOG_E(BMS_TAG_DEFAULT, "bundleName:%{public}s GetCompositePixelMapWithBadge failed", resourceInfo.bundleName_.c_str()); return false; } if (compositePixelMap == nullptr) { - LOG_E(BMS_TAG_DEFAULT, "wtt bundleName:%{public}s compositePixelMap is nullptr", + LOG_E(BMS_TAG_DEFAULT, "bundleName:%{public}s compositePixelMap is nullptr", resourceInfo.bundleName_.c_str()); return false; } diff --git a/services/bundlemgr/src/bundle_resource/bundle_resource_parser.cpp b/services/bundlemgr/src/bundle_resource/bundle_resource_parser.cpp index 77df7297b..772db4f0f 100644 --- a/services/bundlemgr/src/bundle_resource/bundle_resource_parser.cpp +++ b/services/bundlemgr/src/bundle_resource/bundle_resource_parser.cpp @@ -40,7 +40,8 @@ const char* BACKGROUND = "background"; const char CHAR_COLON = ':'; const char* LAYERED_IMAGE = "layered-image"; #ifdef BUNDLE_FRAMEWORK_GRAPHICS -const std::string OHOS_CLONE_APP_BADGE_RESOURCE = "ohos_clone_app_badge_"; +const std::string OHOS_CLONE_APP_BADGE_RESOURCE = "clone_app_badge_"; +const int32_t BADGE_SIZE = 62; #endif struct LayeredImage { @@ -58,6 +59,49 @@ void from_json(const nlohmann::json &jsonObject, LayeredImage &layeredImage) GetValueIfFindKey(jsonObject, jsonObjectEnd, BACKGROUND, layeredImage.background, JsonType::STRING, false, parseResult, ArrayType::NOT_ARRAY); } + +#ifdef BUNDLE_FRAMEWORK_GRAPHICS +bool GetBadgeResource(const std::string &resourceName, std::shared_ptr &badgePixelMap) +{ + std::shared_ptr resMgr(Global::Resource::CreateResourceManager()); + if (resMgr == nullptr) { + APP_LOGE("resMgr is nullptr"); + return false; + } + std::unique_ptr resConfig(Global::Resource::CreateResConfig()); + if (resConfig == nullptr) { + APP_LOGE("resConfig is nullptr"); + return false; + } + resMgr->UpdateResConfig(*resConfig); + + std::unique_ptr badgeResourceData; + size_t badgeResourceDataLength = 0; + auto ret = resMgr->GetMediaDataByName(resourceName.c_str(), badgeResourceDataLength, badgeResourceData); + if (ret != Global::Resource::RState::SUCCESS) { + APP_LOGE("get (%{public}s) failed, errorCode:%{public}d", resourceName.c_str(), static_cast(ret)); + return false; + } + + Media::SourceOptions opts; + uint32_t errorCode = 0; + std::unique_ptr imageSource = + Media::ImageSource::CreateImageSource(badgeResourceData.get(), badgeResourceDataLength, opts, errorCode); + Media::DecodeOptions decodeOpts; + decodeOpts.desiredPixelFormat = Media::PixelFormat::BGRA_8888; + decodeOpts.desiredSize.width = BADGE_SIZE; + decodeOpts.desiredSize.height = BADGE_SIZE; + if (imageSource) { + auto pixelMapPtr = imageSource->CreatePixelMap(decodeOpts, errorCode); + badgePixelMap = std::shared_ptr(pixelMapPtr.release()); + } + if (errorCode != 0 || (badgePixelMap == nullptr)) { + APP_LOGE("get badge failed, errorCode:%{public}u", errorCode); + return false; + } + return true; +} +#endif } BundleResourceParser::BundleResourceParser() @@ -440,50 +484,19 @@ bool BundleResourceParser::ParserCloneResourceInfo( const int32_t appIndex, std::vector &resourceInfos) { #ifdef BUNDLE_FRAMEWORK_GRAPHICS - APP_LOGI("wtt parse clone resource info appIndex:%{public}d start", appIndex); // 1. get badge resource media std::string resourceName = OHOS_CLONE_APP_BADGE_RESOURCE + std::to_string(appIndex); - APP_LOGI("wtt resource Name:%{public}s", resourceName.c_str()); - std::shared_ptr resMgr(Global::Resource::CreateResourceManager()); - if (!resMgr) { - APP_LOGE("wtt InitResMgr resMgr is nullptr"); - return false; - } - std::unique_ptr resConfig(Global::Resource::CreateResConfig()); - if (!resConfig) { - APP_LOGE("wtt InitResMgr resConfig is nullptr"); - return false; - } - resMgr->UpdateResConfig(*resConfig); - std::unique_ptr badgeResourceData; - size_t badgeResourceDataLength = 0; - auto ret = resMgr->GetMediaDataByName(resourceName.c_str(), badgeResourceDataLength, badgeResourceData); - if (ret != Global::Resource::RState::SUCCESS) { - APP_LOGE("wtt get badge resource(%{public}s) failed, code:%{public}d", - resourceName.c_str(), static_cast(ret)); - return false; - } - - Media::SourceOptions opts; - uint32_t errorCode = 0; - std::unique_ptr imageSource = - Media::ImageSource::CreateImageSource( - badgeResourceData.get(), badgeResourceDataLength, opts, errorCode); - Media::DecodeOptions decodeOpts; - decodeOpts.desiredPixelFormat = Media::PixelFormat::BGRA_8888; + APP_LOGI("parse clone info appIndex:%{public}d resourceName:%{public}s start", appIndex, resourceName.c_str()); std::shared_ptr badgePixelMap; - if (imageSource) { - auto pixelMapPtr = imageSource->CreatePixelMap(decodeOpts, errorCode); - badgePixelMap = std::shared_ptr(pixelMapPtr.release()); - } - if (errorCode != 0 || (badgePixelMap == nullptr)) { - APP_LOGE("wtt Get badge failed, errorCode:%{public}u", errorCode); + if (!GetBadgeResource(resourceName, badgePixelMap) || (badgePixelMap == nullptr)) { + APP_LOGE("resourceName:%{public}s get failed", resourceName.c_str()); return false; } bool ans = true; // 2. base64 to pixelMap for (auto &resourceInfo : resourceInfos) { - APP_LOGI("wtt start"); + uint32_t errorCode = 0; + Media::SourceOptions opts; std::unique_ptr imageSource = Media::ImageSource::CreateImageSource(resourceInfo.icon_, opts, errorCode); // base64 to image Media::DecodeOptions decodeOpts; @@ -493,22 +506,22 @@ bool BundleResourceParser::ParserCloneResourceInfo( auto pixelMapPtr = imageSource->CreatePixelMap(decodeOpts, errorCode); baseIconResource = std::shared_ptr(pixelMapPtr.release()); } - if (errorCode != 0 || !baseIconResource) { - APP_LOGE("wtt Get base icon resource failed"); + if ((errorCode != 0) || (baseIconResource == nullptr)) { + APP_LOGW("get base icon resource failed, key:%{public}s", resourceInfo.GetKey().c_str()); ans = false; continue; } // base icon and badge icon resource BundleResourceDrawable drawable; if (!drawable.GetBadgedIconResource(baseIconResource, badgePixelMap, resourceInfo)) { - APP_LOGE("wtt failed"); + APP_LOGE("get badge failed, key:%{public}s", resourceInfo.GetKey().c_str()); ans = false; } } - APP_LOGI("wtt parse clone resource info appIndex:%{public}d end", appIndex); + APP_LOGI("parse clone resource info appIndex:%{public}d end", appIndex); return ans; #else - APP_LOGI("wtt not support pixel map"); + APP_LOGI("not support pixel map"); return false; #endif } From 31f87b8850dc2415e9ace51f972516f50de7fef3 Mon Sep 17 00:00:00 2001 From: sunxuhui Date: Wed, 5 Jun 2024 17:29:07 +0800 Subject: [PATCH 13/23] bms add fuzz Signed-off-by: sunxuhui --- test/fuzztest/BUILD.gn | 2 + .../bmsextensionclient_fuzzer/BUILD.gn | 167 ++++++++++++++++++ .../bmsextensionclient_fuzzer.cpp | 78 ++++++++ .../bmsextensionclient_fuzzer.h | 21 +++ .../bmsextensionclient_fuzzer/corpus/init | 14 ++ .../bmsextensionclient_fuzzer/project.xml | 25 +++ .../driverinstaller_fuzzer/BUILD.gn | 166 +++++++++++++++++ .../driverinstaller_fuzzer/corpus/init | 14 ++ .../driverinstaller_fuzzer.cpp | 87 +++++++++ .../driverinstaller_fuzzer.h | 21 +++ .../driverinstaller_fuzzer/project.xml | 25 +++ 11 files changed, 620 insertions(+) create mode 100644 test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/BUILD.gn create mode 100644 test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.cpp create mode 100644 test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.h create mode 100644 test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/corpus/init create mode 100644 test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/project.xml create mode 100644 test/fuzztest/fuzztest_others/driverinstaller_fuzzer/BUILD.gn create mode 100644 test/fuzztest/fuzztest_others/driverinstaller_fuzzer/corpus/init create mode 100644 test/fuzztest/fuzztest_others/driverinstaller_fuzzer/driverinstaller_fuzzer.cpp create mode 100644 test/fuzztest/fuzztest_others/driverinstaller_fuzzer/driverinstaller_fuzzer.h create mode 100644 test/fuzztest/fuzztest_others/driverinstaller_fuzzer/project.xml diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index 9fc0fd3df..4bd1e7db6 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -78,10 +78,12 @@ group("fuzztest") { "fuzztest_information/queryallabilityinfos_fuzzer:QueryAllAbilityInfosFuzzTest", "fuzztest_information/querykeepalivebundleinfos_fuzzer:QueryKeepAliveBundleInfosFuzzTest", "fuzztest_information/remoteabilityinfo_fuzzer:RemoteAbilityInfoFuzzTest", + "fuzztest_others/bmsextensionclient_fuzzer:BmsExtensionClientFuzzTest", "fuzztest_others/commonevent_fuzzer:CommonEventFuzzTest", "fuzztest_others/copyfiles_fuzzer:CopyFilesFuzzTest", "fuzztest_others/deletequickfix_fuzzer:DeleteQuickFixFuzzTest", "fuzztest_others/deployquickfix_fuzzer:DeployQuickFixFuzzTest", + "fuzztest_others/driverinstaller_fuzzer:DriverInstallerFuzzTest", "fuzztest_others/elementname_fuzzer:ElementNameFuzzTest", "fuzztest_others/installparamunmarshalling_fuzzer:InstallParamUnmarshallingFuzzTest", "fuzztest_others/launcherservice_fuzzer:LauncherServiceFuzzTest", diff --git a/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/BUILD.gn new file mode 100644 index 000000000..dee73bd36 --- /dev/null +++ b/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/BUILD.gn @@ -0,0 +1,167 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") +import("../../../../appexecfwk.gni") +import("../../../../services/bundlemgr/appexecfwk_bundlemgr.gni") +module_output_path = fuzz_test_path + +##############################fuzztest########################################## +ohos_fuzztest("BmsExtensionClientFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "../../../fuzztest/fuzztest_others/bmsextensionclient_fuzzer" + use_exceptions = true + include_dirs = [ "//third_party/jsoncpp/include" ] + sources = bundle_mgr_source + sources += [ + "${services_path}/bundlemgr/src/aot/aot_executor.cpp", + "${services_path}/bundlemgr/src/installd/installd_host_impl.cpp", + "${services_path}/bundlemgr/src/installd/installd_operator.cpp", + "${services_path}/bundlemgr/src/installd/installd_permission_mgr.cpp", + "${services_path}/bundlemgr/src/installd/installd_service.cpp", + ] + + sources += bundle_install_sources + + sources += [ "bmsextensionclient_fuzzer.cpp" ] + + configs = [ "${services_path}/bundlemgr/test:bundlemgr_test_config" ] + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + deps = bundle_install_deps + + external_deps = [ + "ability_base:want", + "access_token:el5_filekey_manager_sdk", + "access_token:libaccesstoken_sdk", + "access_token:libnativetoken", + "access_token:libprivacy_sdk", + "access_token:libtoken_setproc", + "access_token:libtokenid_sdk", + "appspawn:hnpapi", + "appverify:libhapverify", + "common_event_service:cesfwk_innerkits", + "eventhandler:libeventhandler", + "hilog:libhilog", + "hitrace:hitrace_meter", + "init:libbegetutil", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] + external_deps += bundle_install_external_deps + + defines = [] + + if (configpolicy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLOCY_ENABLE" ] + } + + if (bundle_framework_app_control) { + defines += [ "BUNDLE_FRAMEWORK_APP_CONTROL" ] + sources += [ + "${services_path}/bundlemgr/src/app_control/app_control_manager.cpp", + "${services_path}/bundlemgr/src/app_control/app_control_manager_host_impl.cpp", + "${services_path}/bundlemgr/src/app_control/app_control_manager_rdb.cpp", + "${services_path}/bundlemgr/src/app_control/app_jump_interceptor_event_subscriber.cpp", + "${services_path}/bundlemgr/src/app_control/app_jump_interceptor_manager_rdb.cpp", + ] + include_dirs += [ "${services_path}/bundlemgr/include/app_control" ] + external_deps += [ "c_utils:utils" ] + } + + if (build_selinux) { + external_deps += [ "selinux_adapter:libhap_restorecon" ] + cflags += [ "-DWITH_SELINUX" ] + } + if (account_enable) { + external_deps += [ "os_account:os_account_innerkits" ] + defines += [ "ACCOUNT_ENABLE" ] + } + if (bundle_framework_free_install) { + sources += aging + sources += free_install + sources += distributed_manager + external_deps += [ + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "battery_manager:batterysrv_client", + "device_usage_statistics:usagestatsinner", + "display_manager:displaymgr", + "power_manager:powermgr_client", + "syscap_codec:syscap_interface_shared", + ] + defines += [ "BUNDLE_FRAMEWORK_FREE_INSTALL" ] + } + if (global_resmgr_enable) { + defines += [ "GLOBAL_RESMGR_ENABLE" ] + external_deps += [ "resource_management:global_resmgr" ] + } + if (hicollie_enable) { + external_deps += [ "hicollie:libhicollie" ] + defines += [ "HICOLLIE_ENABLE" ] + } + + if (hisysevent_enable) { + sources += [ "${services_path}/bundlemgr/src/inner_event_report.cpp" ] + external_deps += [ "hisysevent:libhisysevent" ] + defines += [ "HISYSEVENT_ENABLE" ] + } + + if (bundle_framework_quick_fix) { + include_dirs += [ "${services_path}/bundlemgr/src/include/quick_fix" ] + sources += quick_fix + defines += [ "BUNDLE_FRAMEWORK_QUICK_FIX" ] + } + + if (storage_service_enable) { + external_deps += [ "storage_service:storage_manager_sa_proxy" ] + defines += [ "STORAGE_SERVICE_ENABLE" ] + } + + external_deps += [ "kv_store:distributeddata_inner" ] + configs += [ "../../../../services/bundlemgr:rdb_config" ] + external_deps += [ "relational_store:native_rdb" ] + sources += [ + "${services_path}/bundlemgr/src/bundle_data_storage_rdb.cpp", + "${services_path}/bundlemgr/src/preinstall_data_storage_rdb.cpp", + "${services_path}/bundlemgr/src/rdb/bms_rdb_open_callback.cpp", + "${services_path}/bundlemgr/src/rdb/rdb_data_manager.cpp", + ] + if (udmf_enabled) { + defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ] + external_deps += [ "udmf:udmf_client" ] + } + + if (bms_device_info_manager_part_enabled) { + external_deps += [ + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", + ] + defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] + } + + if (app_domain_verify_enabled) { + external_deps += [ + "app_domain_verify:app_domain_verify_common", + "app_domain_verify:app_domain_verify_mgr_client", + ] + defines += [ "APP_DOMAIN_VERIFY_ENABLED" ] + } +} diff --git a/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.cpp b/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.cpp new file mode 100644 index 000000000..e404ed50e --- /dev/null +++ b/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include "bms_extension_client.h" + +#include "bmsextensionclient_fuzzer.h" + +using Want = OHOS::AAFwk::Want; + +using namespace OHOS::AppExecFwk; +namespace OHOS { + constexpr uint8_t ENABLE = 2; + bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) + { + Want want; + std::string bundleName (reinterpret_cast(data), size); + bool boolParam = *data % ENABLE; + want.SetAction(bundleName); + std::vector abilityInfos; + AbilityInfo abilityInfo; + std::vector wants; + const std::vector bundleNames; + std::vector bundleInfos; + std::vector bundleStats; + sptr callback; + BmsExtensionClient bmsExtensionClient; + BundleInfo bundleInfo; + bmsExtensionClient.QueryLauncherAbility(want, reinterpret_cast(data), + abilityInfos); + bmsExtensionClient.QueryAbilityInfos(want, reinterpret_cast(data), + reinterpret_cast(data), + abilityInfos); + bmsExtensionClient.BatchQueryAbilityInfos(wants, reinterpret_cast(data), + reinterpret_cast(data), + abilityInfos); + bmsExtensionClient.QueryAbilityInfo(want, reinterpret_cast(data), reinterpret_cast(data), abilityInfo); + bmsExtensionClient.GetBundleInfos(reinterpret_cast(data), bundleInfos, reinterpret_cast(data)); + bmsExtensionClient.GetBundleInfo(bundleName, reinterpret_cast(data), bundleInfo, reinterpret_cast(data), boolParam); + bmsExtensionClient.BatchGetBundleInfo(bundleNames, reinterpret_cast(data), + bundleInfos, reinterpret_cast(data)); + bmsExtensionClient.ImplicitQueryAbilityInfos(want, reinterpret_cast(data), + reinterpret_cast(data), + abilityInfos, boolParam); + bmsExtensionClient.GetBundleStats(bundleName, reinterpret_cast(data), bundleStats); + bmsExtensionClient.ClearCache(bundleName, callback, reinterpret_cast(data)); + bmsExtensionClient.ClearData(bundleName, reinterpret_cast(data)); + int32_t uid = reinterpret_cast(data); + bmsExtensionClient.GetUidByBundleName(bundleName, reinterpret_cast(data), + uid); + bmsExtensionClient.GetBundleNameByUid(reinterpret_cast(data), bundleName); + + return true; + + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + // Run your code on data. + OHOS::DoSomethingInterestingWithMyAPI(data, size); + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.h b/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.h new file mode 100644 index 000000000..55a12ac5e --- /dev/null +++ b/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TEST_FUZZTEST_BMSEXTENSIONCLIENT_FUZZER_H +#define TEST_FUZZTEST_BMSEXTENSIONCLIENT_FUZZER_H + +#define FUZZ_PROJECT_NAME "BmsExtensionClient_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/corpus/init b/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/corpus/init new file mode 100644 index 000000000..e7c3fecd8 --- /dev/null +++ b/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/project.xml b/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/project.xml new file mode 100644 index 000000000..7133b2b92 --- /dev/null +++ b/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/BUILD.gn new file mode 100644 index 000000000..7b39f021a --- /dev/null +++ b/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/BUILD.gn @@ -0,0 +1,166 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") +import("../../../../appexecfwk.gni") +import("../../../../services/bundlemgr/appexecfwk_bundlemgr.gni") +module_output_path = fuzz_test_path + +##############################fuzztest########################################## +ohos_fuzztest("DriverInstallerFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = "../../../fuzztest/fuzztest_others/driverinstaller_fuzzer" + use_exceptions = true + include_dirs = [ "//third_party/jsoncpp/include" ] + sources = bundle_mgr_source + sources += [ + "${services_path}/bundlemgr/src/aot/aot_executor.cpp", + "${services_path}/bundlemgr/src/installd/installd_host_impl.cpp", + "${services_path}/bundlemgr/src/installd/installd_operator.cpp", + "${services_path}/bundlemgr/src/installd/installd_permission_mgr.cpp", + "${services_path}/bundlemgr/src/installd/installd_service.cpp", + ] + + sources += bundle_install_sources + + sources += [ "driverinstaller_fuzzer.cpp" ] + + configs = [ "${services_path}/bundlemgr/test:bundlemgr_test_config" ] + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + deps = bundle_install_deps + + external_deps = [ + "ability_base:want", + "access_token:el5_filekey_manager_sdk", + "access_token:libaccesstoken_sdk", + "access_token:libnativetoken", + "access_token:libprivacy_sdk", + "access_token:libtoken_setproc", + "access_token:libtokenid_sdk", + "appspawn:hnpapi", + "appverify:libhapverify", + "common_event_service:cesfwk_innerkits", + "eventhandler:libeventhandler", + "hilog:libhilog", + "hitrace:hitrace_meter", + "init:libbegetutil", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] + external_deps += bundle_install_external_deps + + defines = [] + + if (configpolicy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLOCY_ENABLE" ] + } + + if (bundle_framework_app_control) { + defines += [ "BUNDLE_FRAMEWORK_APP_CONTROL" ] + sources += [ + "${services_path}/bundlemgr/src/app_control/app_control_manager.cpp", + "${services_path}/bundlemgr/src/app_control/app_control_manager_host_impl.cpp", + "${services_path}/bundlemgr/src/app_control/app_control_manager_rdb.cpp", + "${services_path}/bundlemgr/src/app_control/app_jump_interceptor_event_subscriber.cpp", + "${services_path}/bundlemgr/src/app_control/app_jump_interceptor_manager_rdb.cpp", + ] + include_dirs += [ "${services_path}/bundlemgr/include/app_control" ] + external_deps += [ "c_utils:utils" ] + } + + if (build_selinux) { + external_deps += [ "selinux_adapter:libhap_restorecon" ] + cflags += [ "-DWITH_SELINUX" ] + } + if (account_enable) { + external_deps += [ "os_account:os_account_innerkits" ] + defines += [ "ACCOUNT_ENABLE" ] + } + if (bundle_framework_free_install) { + sources += aging + sources += free_install + sources += distributed_manager + external_deps += [ + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "battery_manager:batterysrv_client", + "device_usage_statistics:usagestatsinner", + "display_manager:displaymgr", + "power_manager:powermgr_client", + "syscap_codec:syscap_interface_shared", + ] + defines += [ "BUNDLE_FRAMEWORK_FREE_INSTALL" ] + } + if (global_resmgr_enable) { + defines += [ "GLOBAL_RESMGR_ENABLE" ] + external_deps += [ "resource_management:global_resmgr" ] + } + if (hicollie_enable) { + external_deps += [ "hicollie:libhicollie" ] + defines += [ "HICOLLIE_ENABLE" ] + } + + if (hisysevent_enable) { + sources += [ "${services_path}/bundlemgr/src/inner_event_report.cpp" ] + external_deps += [ "hisysevent:libhisysevent" ] + defines += [ "HISYSEVENT_ENABLE" ] + } + + if (bundle_framework_quick_fix) { + include_dirs += [ "${services_path}/bundlemgr/src/include/quick_fix" ] + sources += quick_fix + defines += [ "BUNDLE_FRAMEWORK_QUICK_FIX" ] + } + + if (storage_service_enable) { + external_deps += [ "storage_service:storage_manager_sa_proxy" ] + defines += [ "STORAGE_SERVICE_ENABLE" ] + } + + external_deps += [ "kv_store:distributeddata_inner" ] + configs += [ "../../../../services/bundlemgr:rdb_config" ] + external_deps += [ "relational_store:native_rdb" ] + sources += [ + "${services_path}/bundlemgr/src/bundle_data_storage_rdb.cpp", + "${services_path}/bundlemgr/src/preinstall_data_storage_rdb.cpp", + "${services_path}/bundlemgr/src/rdb/bms_rdb_open_callback.cpp", + "${services_path}/bundlemgr/src/rdb/rdb_data_manager.cpp", + ] + if (udmf_enabled) { + defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ] + external_deps += [ "udmf:udmf_client" ] + } + + if (bms_device_info_manager_part_enabled) { + external_deps += [ + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", + ] + defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] + } + + if (app_domain_verify_enabled) { + external_deps += [ + "app_domain_verify:app_domain_verify_common", + "app_domain_verify:app_domain_verify_mgr_client", + ] + defines += [ "APP_DOMAIN_VERIFY_ENABLED" ] + } +} diff --git a/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/corpus/init b/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/corpus/init new file mode 100644 index 000000000..e7c3fecd8 --- /dev/null +++ b/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/driverinstaller_fuzzer.cpp b/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/driverinstaller_fuzzer.cpp new file mode 100644 index 000000000..4075f2dd7 --- /dev/null +++ b/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/driverinstaller_fuzzer.cpp @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include "driver_installer.h" + +#include "driverinstaller_fuzzer.h" +#include "securec.h" + +using namespace OHOS::AppExecFwk; +using namespace OHOS::AAFwk; +namespace OHOS { + +constexpr size_t FOO_MAX_LEN = 1024; +constexpr size_t U32_AT_SIZE = 4; +constexpr uint8_t ENABLE = 2; + bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) + { + std::shared_ptr driverInstaller = std::make_shared(); + InnerBundleInfo info; + std::string bundleName(reinterpret_cast(data), size); + std::string moduleName(reinterpret_cast(data), size); + std::string fileName(reinterpret_cast(data), size); + std::string destinedDir(reinterpret_cast(data), size); + bool isModuleExisted = *data % ENABLE; + auto res = driverInstaller->CreateDriverSoDestinedDir(bundleName, + moduleName, fileName, destinedDir, isModuleExisted); + + driverInstaller->RemoveDriverSoFile(info, moduleName, isModuleExisted); + + Metadata meta; + std::unordered_multimap dirMap; + driverInstaller->FilterDriverSoFile(info, meta, dirMap, isModuleExisted); + + std::unordered_map newInfos; + InnerBundleInfo oldInfo; + driverInstaller->CopyAllDriverFile(newInfos, oldInfo); + return true; + } +} + +// Fuzzer entry point. +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + return 0; + } + + /* Validate the length of size */ + if (size < OHOS::U32_AT_SIZE || size > OHOS::FOO_MAX_LEN) { + return 0; + } + + char* ch = (char*)malloc(size + 1); + if (ch == nullptr) { + std::cout << "malloc failed." << std::endl; + return 0; + } + + (void)memset_s(ch, size + 1, 0x00, size + 1); + if (memcpy_s(ch, size, data, size) != EOK) { + std::cout << "copy failed." << std::endl; + free(ch); + ch = nullptr; + return 0; + } + + OHOS::DoSomethingInterestingWithMyAPI(ch, size); + free(ch); + ch = nullptr; + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/driverinstaller_fuzzer.h b/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/driverinstaller_fuzzer.h new file mode 100644 index 000000000..17a4d08c1 --- /dev/null +++ b/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/driverinstaller_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TEST_FUZZTEST_DRIVERINSTALLER_FUZZER_H +#define TEST_FUZZTEST_DRIVERINSTALLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "driverinstaller_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/project.xml b/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/project.xml new file mode 100644 index 000000000..7133b2b92 --- /dev/null +++ b/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + From 35d710614d36eb2b410d3c24f51e6d7e11862db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E6=97=AD=E8=BE=89?= Date: Wed, 5 Jun 2024 11:14:23 +0000 Subject: [PATCH 14/23] update test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙旭辉 --- .../bmsextensionclient_fuzzer.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.cpp b/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.cpp index e404ed50e..76d7dbc8c 100644 --- a/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.cpp +++ b/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.cpp @@ -26,7 +26,7 @@ using namespace OHOS::AppExecFwk; namespace OHOS { constexpr uint8_t ENABLE = 2; bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) - { + { Want want; std::string bundleName (reinterpret_cast(data), size); bool boolParam = *data % ENABLE; @@ -43,14 +43,16 @@ namespace OHOS { bmsExtensionClient.QueryLauncherAbility(want, reinterpret_cast(data), abilityInfos); bmsExtensionClient.QueryAbilityInfos(want, reinterpret_cast(data), - reinterpret_cast(data), - abilityInfos); + reinterpret_cast(data), abilityInfos); bmsExtensionClient.BatchQueryAbilityInfos(wants, reinterpret_cast(data), reinterpret_cast(data), abilityInfos); - bmsExtensionClient.QueryAbilityInfo(want, reinterpret_cast(data), reinterpret_cast(data), abilityInfo); - bmsExtensionClient.GetBundleInfos(reinterpret_cast(data), bundleInfos, reinterpret_cast(data)); - bmsExtensionClient.GetBundleInfo(bundleName, reinterpret_cast(data), bundleInfo, reinterpret_cast(data), boolParam); + bmsExtensionClient.QueryAbilityInfo(want, reinterpret_cast(data), + reinterpret_cast(data), abilityInfo); + bmsExtensionClient.GetBundleInfos(reinterpret_cast(data), bundleInfos, + reinterpret_cast(data)); + bmsExtensionClient.GetBundleInfo(bundleName, reinterpret_cast(data), bundleInfo, + reinterpret_cast(data), boolParam); bmsExtensionClient.BatchGetBundleInfo(bundleNames, reinterpret_cast(data), bundleInfos, reinterpret_cast(data)); bmsExtensionClient.ImplicitQueryAbilityInfos(want, reinterpret_cast(data), @@ -65,8 +67,7 @@ namespace OHOS { bmsExtensionClient.GetBundleNameByUid(reinterpret_cast(data), bundleName); return true; - - } + } } // Fuzzer entry point. From 4070d7b6ea9f4eddad430f2b2c137045600fe32f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E6=97=AD=E8=BE=89?= Date: Wed, 5 Jun 2024 11:15:24 +0000 Subject: [PATCH 15/23] update test/fuzztest/fuzztest_others/driverinstaller_fuzzer/driverinstaller_fuzzer.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙旭辉 --- .../driverinstaller_fuzzer/driverinstaller_fuzzer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/driverinstaller_fuzzer.cpp b/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/driverinstaller_fuzzer.cpp index 4075f2dd7..53acdbdfc 100644 --- a/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/driverinstaller_fuzzer.cpp +++ b/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/driverinstaller_fuzzer.cpp @@ -73,7 +73,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) } (void)memset_s(ch, size + 1, 0x00, size + 1); - if (memcpy_s(ch, size, data, size) != EOK) { + if (memcpy_s(ch, size + 1, data, size) != EOK) { std::cout << "copy failed." << std::endl; free(ch); ch = nullptr; From 3b56103063f1c3c377844378c65ecc61d30ff15d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E6=97=AD=E8=BE=89?= Date: Wed, 5 Jun 2024 11:15:58 +0000 Subject: [PATCH 16/23] update test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙旭辉 --- .../bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.cpp b/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.cpp index 76d7dbc8c..49352632f 100644 --- a/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.cpp +++ b/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.cpp @@ -24,7 +24,7 @@ using Want = OHOS::AAFwk::Want; using namespace OHOS::AppExecFwk; namespace OHOS { - constexpr uint8_t ENABLE = 2; +constexpr uint8_t ENABLE = 2; bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) { Want want; From d5c2ce058c7960ae5587c4c70c50a8bd87a76c0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=BB=E6=9D=B0?= Date: Wed, 5 Jun 2024 14:38:06 +0800 Subject: [PATCH 17/23] Issue:#I9V6CM Description: remove clone other information Sig: SIG_ApplicaitonFramework Feature or Bugfix: Feature Binary Source: No Signed-off-by: renjie84 renjie84@huawei.com MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 任杰 --- .../bundlemgr/include/inner_bundle_clone_info.h | 7 ------- services/bundlemgr/src/bundle_data_mgr.cpp | 3 --- services/bundlemgr/src/inner_bundle_clone_info.cpp | 8 -------- services/bundlemgr/src/inner_bundle_info.cpp | 5 ----- .../bms_bundle_clone_app_datastruct_test.cpp | 14 -------------- 5 files changed, 37 deletions(-) diff --git a/services/bundlemgr/include/inner_bundle_clone_info.h b/services/bundlemgr/include/inner_bundle_clone_info.h index d29cf838c..0ffc00c9b 100644 --- a/services/bundlemgr/include/inner_bundle_clone_info.h +++ b/services/bundlemgr/include/inner_bundle_clone_info.h @@ -37,10 +37,6 @@ struct InnerBundleCloneInfo { // disabled abilities of the user. std::vector disabledAbilities; - // overlay module state - // element is moduleName_state - std::vector overlayModulesState; - uint32_t accessTokenId = 0; uint64_t accessTokenIdEx = 0; @@ -52,9 +48,6 @@ struct InnerBundleCloneInfo { // The time(unix time) will be recalculated // if the application is uninstalled after being installed. int64_t updateTime = 0; - - // app install control - bool isRemovable = true; }; void from_json(const nlohmann::json& jsonObject, InnerBundleCloneInfo& bundleCloneInfo); diff --git a/services/bundlemgr/src/bundle_data_mgr.cpp b/services/bundlemgr/src/bundle_data_mgr.cpp index 716487761..7a2c49a93 100644 --- a/services/bundlemgr/src/bundle_data_mgr.cpp +++ b/services/bundlemgr/src/bundle_data_mgr.cpp @@ -1828,9 +1828,6 @@ void BundleDataMgr::GetMatchLauncherAbilityInfosForCloneInfos( void BundleDataMgr::ModifyApplicationInfoByCloneInfo(const InnerBundleCloneInfo &cloneInfo, ApplicationInfo &applicationInfo) const { - if (applicationInfo.removable && !cloneInfo.isRemovable) { - applicationInfo.removable = false; - } applicationInfo.accessTokenId = cloneInfo.accessTokenId; applicationInfo.accessTokenIdEx = cloneInfo.accessTokenIdEx; applicationInfo.enabled = cloneInfo.enabled; diff --git a/services/bundlemgr/src/inner_bundle_clone_info.cpp b/services/bundlemgr/src/inner_bundle_clone_info.cpp index 7f165887e..53ac6671a 100644 --- a/services/bundlemgr/src/inner_bundle_clone_info.cpp +++ b/services/bundlemgr/src/inner_bundle_clone_info.cpp @@ -33,13 +33,11 @@ const std::string BUNDLE_CLONE_INFO_UID = "uid"; const std::string BUNDLE_CLONE_INFO_GIDS = "gids"; const std::string BUNDLE_CLONE_INFO_ENABLE = "enabled"; const std::string BUNDLE_CLONE_INFO_DISABLE_ABILITIES = "disabledAbilities"; -const std::string BUNDLE_CLONE_INFO_OVERLAY_STATE = "overlayState"; const std::string BUNDLE_CLONE_INFO_ACCESS_TOKEN_ID = "accessTokenId"; const std::string BUNDLE_CLONE_INFO_ACCESS_TOKEN_ID_EX = "accessTokenIdEx"; const std::string BUNDLE_CLONE_INFO_INSTALL_TIME = "installTime"; const std::string BUNDLE_CLONE_INFO_UPDATE_TIME = "updateTime"; -const std::string BUNDLE_CLONE_INFO_IS_REMOVABLE = "isRemovable"; } // namespace void to_json(nlohmann::json& jsonObject, const InnerBundleCloneInfo& bundleCloneInfo) @@ -51,12 +49,10 @@ void to_json(nlohmann::json& jsonObject, const InnerBundleCloneInfo& bundleClone {BUNDLE_CLONE_INFO_GIDS, bundleCloneInfo.gids}, {BUNDLE_CLONE_INFO_ENABLE, bundleCloneInfo.enabled}, {BUNDLE_CLONE_INFO_DISABLE_ABILITIES, bundleCloneInfo.disabledAbilities}, - {BUNDLE_CLONE_INFO_OVERLAY_STATE, bundleCloneInfo.overlayModulesState}, {BUNDLE_CLONE_INFO_ACCESS_TOKEN_ID, bundleCloneInfo.accessTokenId}, {BUNDLE_CLONE_INFO_ACCESS_TOKEN_ID_EX, bundleCloneInfo.accessTokenIdEx}, {BUNDLE_CLONE_INFO_INSTALL_TIME, bundleCloneInfo.installTime}, {BUNDLE_CLONE_INFO_UPDATE_TIME, bundleCloneInfo.updateTime}, - {BUNDLE_CLONE_INFO_IS_REMOVABLE, bundleCloneInfo.isRemovable}, }; } @@ -76,8 +72,6 @@ void from_json(const nlohmann::json& jsonObject, InnerBundleCloneInfo& bundleClo bundleCloneInfo.enabled, JsonType::BOOLEAN, false, parseResult, ArrayType::NOT_ARRAY); GetValueIfFindKey>(jsonObject, jsonObjectEnd, BUNDLE_CLONE_INFO_DISABLE_ABILITIES, bundleCloneInfo.disabledAbilities, JsonType::ARRAY, false, parseResult, ArrayType::STRING); - GetValueIfFindKey>(jsonObject, jsonObjectEnd, BUNDLE_CLONE_INFO_OVERLAY_STATE, - bundleCloneInfo.overlayModulesState, JsonType::ARRAY, false, parseResult, ArrayType::STRING); GetValueIfFindKey(jsonObject, jsonObjectEnd, BUNDLE_CLONE_INFO_ACCESS_TOKEN_ID, bundleCloneInfo.accessTokenId, JsonType::NUMBER, false, parseResult, ArrayType::NOT_ARRAY); GetValueIfFindKey(jsonObject, jsonObjectEnd, BUNDLE_CLONE_INFO_ACCESS_TOKEN_ID_EX, @@ -86,8 +80,6 @@ void from_json(const nlohmann::json& jsonObject, InnerBundleCloneInfo& bundleClo bundleCloneInfo.installTime, JsonType::NUMBER, false, parseResult, ArrayType::NOT_ARRAY); GetValueIfFindKey(jsonObject, jsonObjectEnd, BUNDLE_CLONE_INFO_UPDATE_TIME, bundleCloneInfo.updateTime, JsonType::NUMBER, false, parseResult, ArrayType::NOT_ARRAY); - GetValueIfFindKey(jsonObject, jsonObjectEnd, BUNDLE_CLONE_INFO_IS_REMOVABLE, - bundleCloneInfo.isRemovable, JsonType::BOOLEAN, false, parseResult, ArrayType::NOT_ARRAY); if (parseResult != ERR_OK) { APP_LOGE("read module bundleCloneInfo from jsonObject error, error code : %{public}d", parseResult); } diff --git a/services/bundlemgr/src/inner_bundle_info.cpp b/services/bundlemgr/src/inner_bundle_info.cpp index 14c08b799..de8f417fe 100644 --- a/services/bundlemgr/src/inner_bundle_info.cpp +++ b/services/bundlemgr/src/inner_bundle_info.cpp @@ -3532,7 +3532,6 @@ ErrCode InnerBundleInfo::AddCloneBundle(const InnerBundleCloneInfo &attr) // copy from user cloneInfo.enabled = userInfo.bundleUserInfo.enabled; cloneInfo.disabledAbilities = userInfo.bundleUserInfo.disabledAbilities; - cloneInfo.overlayModulesState = userInfo.bundleUserInfo.overlayModulesState; cloneInfo.accessTokenId = attr.accessTokenId; cloneInfo.accessTokenIdEx = attr.accessTokenIdEx; cloneInfo.uid = attr.uid; @@ -3540,7 +3539,6 @@ ErrCode InnerBundleInfo::AddCloneBundle(const InnerBundleCloneInfo &attr) int64_t now = BundleUtil::GetCurrentTime(); cloneInfo.installTime = now; cloneInfo.updateTime = now; - cloneInfo.isRemovable = userInfo.isRemovable; cloneInfos[appIndexKey] = cloneInfo; APP_LOGD("Add clone app userId: %{public}d appIndex: %{public}d in bundle: %{public}s", @@ -3626,9 +3624,6 @@ bool InnerBundleInfo::GetApplicationInfoAdaptBundleClone( APP_LOGE("appIndex %{public}d not exist", appIndex); return false; } - if (appInfo.removable && !iter->second.isRemovable) { - appInfo.removable = false; - } appInfo.accessTokenId = iter->second.accessTokenId; appInfo.accessTokenIdEx = iter->second.accessTokenIdEx; appInfo.enabled = iter->second.enabled; diff --git a/services/bundlemgr/test/unittest/bms_bundle_clone_app_test/bms_bundle_clone_app_datastruct_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_clone_app_test/bms_bundle_clone_app_datastruct_test.cpp index 457bee063..e5453b038 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_clone_app_test/bms_bundle_clone_app_datastruct_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_clone_app_test/bms_bundle_clone_app_datastruct_test.cpp @@ -119,8 +119,6 @@ HWTEST_F(BmsBundleCloneAppDataStructTest, OTA_BundleCloneInfoJsonSerializer_0001 bundleCloneInfo.disabledAbilities = {"a", "b"}; bundleCloneInfo.enabled = true; bundleCloneInfo.installTime = 10; - bundleCloneInfo.isRemovable = true; - bundleCloneInfo.overlayModulesState = {"c", "d"}; bundleCloneInfo.uid = 20; bundleCloneInfo.updateTime = 21; @@ -139,11 +137,6 @@ HWTEST_F(BmsBundleCloneAppDataStructTest, OTA_BundleCloneInfoJsonSerializer_0001 ); EXPECT_EQ(bundleCloneInfo.enabled, bundleCloneInfo2.enabled); EXPECT_EQ(bundleCloneInfo.installTime, bundleCloneInfo2.installTime); - EXPECT_EQ(bundleCloneInfo.isRemovable, bundleCloneInfo2.isRemovable); - EXPECT_TRUE( - std::equal(bundleCloneInfo.overlayModulesState.begin(), bundleCloneInfo.overlayModulesState.end(), - bundleCloneInfo2.overlayModulesState.begin()) - ); EXPECT_EQ(bundleCloneInfo.uid, bundleCloneInfo2.uid); EXPECT_EQ(bundleCloneInfo.updateTime, bundleCloneInfo2.updateTime); } @@ -166,8 +159,6 @@ HWTEST_F(BmsBundleCloneAppDataStructTest, OTA_BundleUserInfoJsonSerializer_0001, bundleCloneInfo.disabledAbilities = {"a", "b"}; bundleCloneInfo.enabled = true; bundleCloneInfo.installTime = 10; - bundleCloneInfo.isRemovable = true; - bundleCloneInfo.overlayModulesState = {"c", "d"}; bundleCloneInfo.uid = 20; bundleCloneInfo.updateTime = 21; @@ -194,11 +185,6 @@ HWTEST_F(BmsBundleCloneAppDataStructTest, OTA_BundleUserInfoJsonSerializer_0001, ); EXPECT_EQ(bundleCloneInfo.enabled, bundleCloneInfo2.enabled); EXPECT_EQ(bundleCloneInfo.installTime, bundleCloneInfo2.installTime); - EXPECT_EQ(bundleCloneInfo.isRemovable, bundleCloneInfo2.isRemovable); - EXPECT_TRUE( - std::equal(bundleCloneInfo.overlayModulesState.begin(), bundleCloneInfo.overlayModulesState.end(), - bundleCloneInfo2.overlayModulesState.begin()) - ); EXPECT_EQ(bundleCloneInfo.uid, bundleCloneInfo2.uid); EXPECT_EQ(bundleCloneInfo.updateTime, bundleCloneInfo2.updateTime); } From 4e09cbed1883f5acd1c6e123bcbb27e8a6a6a071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E6=97=AD=E8=BE=89?= Date: Wed, 5 Jun 2024 11:23:52 +0000 Subject: [PATCH 18/23] update test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.cpp. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 孙旭辉 --- test/fuzztest/BUILD.gn | 1 + .../bmsextensionclient_fuzzer.cpp | 4 +- .../bundlecloneinstaller_fuzzer/BUILD.gn | 176 ++++++++++++++++++ .../bundlecloneinstaller_fuzzer.cpp | 100 ++++++++++ .../bundlecloneinstaller_fuzzer.h | 21 +++ .../bundlecloneinstaller_fuzzer/corpus/init | 14 ++ .../bundlecloneinstaller_fuzzer/project.xml | 25 +++ .../driverinstaller_fuzzer.cpp | 9 + 8 files changed, 348 insertions(+), 2 deletions(-) create mode 100644 test/fuzztest/fuzztest_others/bundlecloneinstaller_fuzzer/BUILD.gn create mode 100644 test/fuzztest/fuzztest_others/bundlecloneinstaller_fuzzer/bundlecloneinstaller_fuzzer.cpp create mode 100644 test/fuzztest/fuzztest_others/bundlecloneinstaller_fuzzer/bundlecloneinstaller_fuzzer.h create mode 100644 test/fuzztest/fuzztest_others/bundlecloneinstaller_fuzzer/corpus/init create mode 100644 test/fuzztest/fuzztest_others/bundlecloneinstaller_fuzzer/project.xml diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index 4bd1e7db6..1351a5308 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -79,6 +79,7 @@ group("fuzztest") { "fuzztest_information/querykeepalivebundleinfos_fuzzer:QueryKeepAliveBundleInfosFuzzTest", "fuzztest_information/remoteabilityinfo_fuzzer:RemoteAbilityInfoFuzzTest", "fuzztest_others/bmsextensionclient_fuzzer:BmsExtensionClientFuzzTest", + "fuzztest_others/bundlecloneinstaller_fuzzer:BundlecloneinstallerFuzzTest", "fuzztest_others/commonevent_fuzzer:CommonEventFuzzTest", "fuzztest_others/copyfiles_fuzzer:CopyFilesFuzzTest", "fuzztest_others/deletequickfix_fuzzer:DeleteQuickFixFuzzTest", diff --git a/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.cpp b/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.cpp index 49352632f..530a32fe7 100644 --- a/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.cpp +++ b/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.cpp @@ -26,7 +26,7 @@ using namespace OHOS::AppExecFwk; namespace OHOS { constexpr uint8_t ENABLE = 2; bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) - { + { Want want; std::string bundleName (reinterpret_cast(data), size); bool boolParam = *data % ENABLE; @@ -41,7 +41,7 @@ constexpr uint8_t ENABLE = 2; BmsExtensionClient bmsExtensionClient; BundleInfo bundleInfo; bmsExtensionClient.QueryLauncherAbility(want, reinterpret_cast(data), - abilityInfos); + abilityInfos); bmsExtensionClient.QueryAbilityInfos(want, reinterpret_cast(data), reinterpret_cast(data), abilityInfos); bmsExtensionClient.BatchQueryAbilityInfos(wants, reinterpret_cast(data), diff --git a/test/fuzztest/fuzztest_others/bundlecloneinstaller_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_others/bundlecloneinstaller_fuzzer/BUILD.gn new file mode 100644 index 000000000..06cc0cdd9 --- /dev/null +++ b/test/fuzztest/fuzztest_others/bundlecloneinstaller_fuzzer/BUILD.gn @@ -0,0 +1,176 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") +import("../../../../appexecfwk.gni") +import("../../../../services/bundlemgr/appexecfwk_bundlemgr.gni") +module_output_path = fuzz_test_path + +##############################fuzztest########################################## +ohos_fuzztest("BundlecloneinstallerFuzzTest") { + module_out_path = module_output_path + include_dirs = [ "//third_party/jsoncpp/include" ] + fuzz_config_file = + "../../../fuzztest/fuzztest_others/bundlecloneinstaller_fuzzer" + + sources = bundle_mgr_source + sources += [ "bundlecloneinstaller_fuzzer.cpp" ] + sources += bundle_install_sources + configs = [ "${services_path}/bundlemgr/test:bundlemgr_test_config" ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + cflags += [ "-frtti" ] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + + deps = [ + "${base_path}:appexecfwk_base", + "${common_path}:libappexecfwk_common", + "${core_path}:appexecfwk_core", + ] + deps += bundle_install_deps + + external_deps = [ + "ability_base:want", + "access_token:libprivacy_sdk", + "access_token:libtokenid_sdk", + "appverify:libhapverify", + "common_event_service:cesfwk_innerkits", + "eventhandler:libeventhandler", + "hilog:libhilog", + "hitrace:hitrace_meter", + "init:libbegetutil", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] + external_deps += bundle_install_external_deps + + defines = [] + if (code_signature_enable) { + sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ] + include_dirs += [ "${services_path}/bundlemgr/include" ] + external_deps += [ + "code_signature:libcode_sign_utils", + "ets_runtime:libcompiler_service", + ] + defines += [ "CODE_SIGNATURE_ENABLE" ] + } + + if (configpolicy_enable) { + external_deps += [ "config_policy:configpolicy_util" ] + defines += [ "CONFIG_POLOCY_ENABLE" ] + } + + if (bundle_framework_app_control) { + defines += [ "BUNDLE_FRAMEWORK_APP_CONTROL" ] + sources += [ + "${services_path}/bundlemgr/src/app_control/app_control_manager.cpp", + "${services_path}/bundlemgr/src/app_control/app_control_manager_host_impl.cpp", + "${services_path}/bundlemgr/src/app_control/app_control_manager_rdb.cpp", + "${services_path}/bundlemgr/src/app_control/app_jump_interceptor_event_subscriber.cpp", + "${services_path}/bundlemgr/src/app_control/app_jump_interceptor_manager_rdb.cpp", + ] + include_dirs += [ "${services_path}/bundlemgr/include/app_control" ] + external_deps += [ "c_utils:utils" ] + } + if (current_cpu == "arm64") { + defines += [ "USE_BUNDLE_EXTENSION" ] + } + + if (build_selinux) { + external_deps += [ "selinux_adapter:libhap_restorecon" ] + cflags += [ "-DWITH_SELINUX" ] + } + if (account_enable) { + external_deps += [ "os_account:os_account_innerkits" ] + defines += [ "ACCOUNT_ENABLE" ] + } + if (bundle_framework_free_install) { + sources += aging + sources += free_install + sources += distributed_manager + external_deps += [ + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "battery_manager:batterysrv_client", + "device_usage_statistics:usagestatsinner", + "display_manager:displaymgr", + "power_manager:powermgr_client", + "syscap_codec:syscap_interface_shared", + ] + defines += [ "BUNDLE_FRAMEWORK_FREE_INSTALL" ] + } + if (global_resmgr_enable) { + defines += [ "GLOBAL_RESMGR_ENABLE" ] + external_deps += [ "resource_management:global_resmgr" ] + } + if (hicollie_enable) { + external_deps += [ "hicollie:libhicollie" ] + defines += [ "HICOLLIE_ENABLE" ] + } + + if (hisysevent_enable) { + sources += [ "${services_path}/bundlemgr/src/inner_event_report.cpp" ] + external_deps += [ "hisysevent:libhisysevent" ] + defines += [ "HISYSEVENT_ENABLE" ] + } + + if (bundle_framework_quick_fix) { + include_dirs += [ "${services_path}/bundlemgr/src/include/quick_fix" ] + sources += quick_fix + defines += [ "BUNDLE_FRAMEWORK_QUICK_FIX" ] + } + + if (storage_service_enable) { + external_deps += [ "storage_service:storage_manager_sa_proxy" ] + defines += [ "STORAGE_SERVICE_ENABLE" ] + } + + external_deps += [ "kv_store:distributeddata_inner" ] + configs += [ "../../../../services/bundlemgr:rdb_config" ] + external_deps += [ "relational_store:native_rdb" ] + sources += [ + "${services_path}/bundlemgr/src/bundle_data_storage_rdb.cpp", + "${services_path}/bundlemgr/src/preinstall_data_storage_rdb.cpp", + "${services_path}/bundlemgr/src/rdb/bms_rdb_open_callback.cpp", + "${services_path}/bundlemgr/src/rdb/rdb_data_manager.cpp", + ] + if (udmf_enabled) { + defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ] + external_deps += [ "udmf:udmf_client" ] + } + + if (bms_device_info_manager_part_enabled) { + external_deps += [ + "device_info_manager:distributed_device_profile_common", + "device_info_manager:distributed_device_profile_sdk", + ] + defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] + } + + if (app_domain_verify_enabled) { + external_deps += [ + "app_domain_verify:app_domain_verify_common", + "app_domain_verify:app_domain_verify_mgr_client", + ] + defines += [ "APP_DOMAIN_VERIFY_ENABLED" ] + } +} diff --git a/test/fuzztest/fuzztest_others/bundlecloneinstaller_fuzzer/bundlecloneinstaller_fuzzer.cpp b/test/fuzztest/fuzztest_others/bundlecloneinstaller_fuzzer/bundlecloneinstaller_fuzzer.cpp new file mode 100644 index 000000000..e52086365 --- /dev/null +++ b/test/fuzztest/fuzztest_others/bundlecloneinstaller_fuzzer/bundlecloneinstaller_fuzzer.cpp @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#define private public +#include +#include + +#include "securec.h" +#include "bundle_clone_installer.h" +#include "bundle_installer.h" +#include "bundle_constants.h" +#include "bundle_mgr_service.h" +#include "bundlecloneinstaller_fuzzer.h" + +using namespace OHOS::AppExecFwk; +using OHOS::DelayedSingleton; + +namespace OHOS { + namespace { + constexpr int INPUT_ZERO = 0; + constexpr int INPUT_ONE = 1; + constexpr int INPUT_TWO = 2; + constexpr int INPUT_THREE = 3; + constexpr size_t FOO_MAX_LEN = 1024; + constexpr size_t U32_AT_SIZE = 4; + constexpr size_t OFFSET_ZERO = 24; + constexpr size_t OFFSET_ONE = 16; + constexpr size_t OFFSET_TWO = 8; + } + + void SetBundleDataMgr() + { + DelayedSingleton::GetInstance()->dataMgr_ = std::make_shared(); + } + + uint32_t GetU32Data(const char* ptr) + { + // convert fuzz input data to an integer + return (ptr[INPUT_ZERO] << OFFSET_ZERO) | (ptr[INPUT_ONE] << OFFSET_ONE) | (ptr[INPUT_TWO] << OFFSET_TWO) | + ptr[INPUT_THREE]; + } + + bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) + { + BundleCloneInstaller bundleCloneInstall; + + std::string bundleName(data, size); + int32_t userId = static_cast(GetU32Data(data)); + int32_t appIndex = static_cast(GetU32Data(data)); + SetBundleDataMgr(); + bundleCloneInstall.InstallCloneApp(bundleName, userId, appIndex); + bundleCloneInstall.UninstallCloneApp(bundleName, userId, appIndex); + bundleCloneInstall.UninstallAllCloneApps(bundleName, userId); + return true; + } +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + return 0; + } + + /* Validate the length of size */ + if (size < OHOS::U32_AT_SIZE || size > OHOS::FOO_MAX_LEN) { + return 0; + } + + char* ch = (char *)malloc(size + 1); + if (ch == nullptr) { + std::cout << "malloc failed." << std::endl; + return 0; + } + + (void)memset_s(ch, size + 1, 0x00, size + 1); + if (memcpy_s(ch, size + 1, data, size) != EOK) { + std::cout << "copy failed." << std::endl; + free(ch); + ch = nullptr; + return 0; + } + + OHOS::DoSomethingInterestingWithMyAPI(ch, size); + free(ch); + ch = nullptr; + return 0; +} \ No newline at end of file diff --git a/test/fuzztest/fuzztest_others/bundlecloneinstaller_fuzzer/bundlecloneinstaller_fuzzer.h b/test/fuzztest/fuzztest_others/bundlecloneinstaller_fuzzer/bundlecloneinstaller_fuzzer.h new file mode 100644 index 000000000..c56adfde8 --- /dev/null +++ b/test/fuzztest/fuzztest_others/bundlecloneinstaller_fuzzer/bundlecloneinstaller_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef TEST_FUZZTEST_BUNDLECLONEINSTALLER_FUZZER_H +#define TEST_FUZZTEST_BUNDLECLONEINSTALLER_FUZZER_H + +#define FUZZ_PROJECT_NAME "Bundlecloneinstaller_fuzzer" + +#endif \ No newline at end of file diff --git a/test/fuzztest/fuzztest_others/bundlecloneinstaller_fuzzer/corpus/init b/test/fuzztest/fuzztest_others/bundlecloneinstaller_fuzzer/corpus/init new file mode 100644 index 000000000..e7c3fecd8 --- /dev/null +++ b/test/fuzztest/fuzztest_others/bundlecloneinstaller_fuzzer/corpus/init @@ -0,0 +1,14 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/fuzztest_others/bundlecloneinstaller_fuzzer/project.xml b/test/fuzztest/fuzztest_others/bundlecloneinstaller_fuzzer/project.xml new file mode 100644 index 000000000..7133b2b92 --- /dev/null +++ b/test/fuzztest/fuzztest_others/bundlecloneinstaller_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/driverinstaller_fuzzer.cpp b/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/driverinstaller_fuzzer.cpp index 53acdbdfc..77a836df9 100644 --- a/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/driverinstaller_fuzzer.cpp +++ b/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/driverinstaller_fuzzer.cpp @@ -13,6 +13,7 @@ * limitations under the License. */ +#define private public #include #include #include @@ -49,6 +50,14 @@ constexpr uint8_t ENABLE = 2; std::unordered_map newInfos; InnerBundleInfo oldInfo; driverInstaller->CopyAllDriverFile(newInfos, oldInfo); + + std::string srcPath(reinterpret_cast(data), size); + driverInstaller->CopyDriverSoFile(info, srcPath, isModuleExisted); + + driverInstaller->RemoveAndReNameDriverFile(newInfos, oldInfo); + + driverInstaller->RenameDriverFile(info); + return true; } } From 061468b3d63da80170f758025e444a6520381b49 Mon Sep 17 00:00:00 2001 From: wangtiantian Date: Wed, 5 Jun 2024 18:49:29 +0800 Subject: [PATCH 19/23] IssueNo:#I9VB5P Description:fix theme bug Sig:SIG_ApplicaitonFramework Feature or Bugfix:Bugfix Binary Source:No Signed-off-by: wangtiantian --- .../bundle_resource_manager.cpp | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/services/bundlemgr/src/bundle_resource/bundle_resource_manager.cpp b/services/bundlemgr/src/bundle_resource/bundle_resource_manager.cpp index bc5b2ff24..6485ae3fc 100644 --- a/services/bundlemgr/src/bundle_resource/bundle_resource_manager.cpp +++ b/services/bundlemgr/src/bundle_resource/bundle_resource_manager.cpp @@ -22,6 +22,7 @@ #include "app_log_wrapper.h" #include "bundle_common_event_mgr.h" #include "bundle_promise.h" +#include "bundle_util.h" #include "bundle_memory_guard.h" #include "bundle_resource_parser.h" #include "bundle_resource_process.h" @@ -37,6 +38,9 @@ const std::string THREAD_POOL_NAME = "BundleResourceThreadPool"; constexpr int32_t CHECK_INTERVAL = 50; // 50ms constexpr const char* FOUNDATION_PROCESS_NAME = "foundation"; constexpr int32_t SCENE_ID_UPDATE_RESOURCE = 1 << 1; +const std::string SYSTEM_THEME_PATH = "/data/service/el1/public/themes/"; +const std::string THEME_ICONS_A = "/a/app/icons/"; +const std::string THEME_ICONS_B = "/b/app/icons/"; } BundleResourceManager::BundleResourceManager() @@ -119,8 +123,26 @@ bool BundleResourceManager::AddAllResourceInfo(const int32_t userId, const uint3 APP_LOGE("GetAllResourceInfo failed, userId:%{public}d", userId); return false; } + bool needDeleteAllResource = true; + if (type == static_cast(BundleResourceChangeType::SYSTEM_THEME_CHANGE)) { + // judge whether the bundle theme exists + for (auto iter = resourceInfosMap.begin(); iter != resourceInfosMap.end();) { + if (!BundleUtil::IsExistDir(SYSTEM_THEME_PATH + std::to_string(userId) + THEME_ICONS_A + iter->first) && + !BundleUtil::IsExistDir(SYSTEM_THEME_PATH + std::to_string(userId) + THEME_ICONS_B + iter->first)) { + iter = resourceInfosMap.erase(iter); + } else { + ++iter; + } + } + needDeleteAllResource = false; + } + if (resourceInfosMap.empty()) { + SendBundleResourcesChangedEvent(userId, type); + APP_LOGI("add all resource end, no theme changed"); + return true; + } - if (!AddResourceInfos(resourceInfosMap, true, tempTaskNum)) { + if (!AddResourceInfos(resourceInfosMap, needDeleteAllResource, tempTaskNum)) { APP_LOGE("add all resource info failed, userId:%{public}d", userId); return false; } From d8d9eb8fab12547b1c1cdba21312675d5bbf6832 Mon Sep 17 00:00:00 2001 From: ChenYC009 Date: Tue, 4 Jun 2024 23:01:02 +0800 Subject: [PATCH 20/23] pending sign modification Signed-off-by: ChenYC009 Change-Id: Id64e7c4c22fcdab94bc733cfd79061a4193c0998 --- appexecfwk.gni | 6 + bundle.json | 1 + .../include/appexecfwk_errors.h | 1 + services/bundlemgr/BUILD.gn | 5 + services/bundlemgr/include/aot/aot_executor.h | 7 +- services/bundlemgr/include/aot/aot_handler.h | 59 ++++- ...le_framework_services_ipc_interface_code.h | 1 + .../include/installd/installd_host_impl.h | 4 +- services/bundlemgr/include/installd_client.h | 4 +- .../bundlemgr/include/ipc/installd_host.h | 2 + .../include/ipc/installd_interface.h | 7 +- .../bundlemgr/include/ipc/installd_proxy.h | 4 +- services/bundlemgr/src/aot/aot_executor.cpp | 47 ++-- services/bundlemgr/src/aot/aot_handler.cpp | 223 ++++++++++++++++-- .../src/bundle_mgr_service_event_handler.cpp | 3 + .../src/installd/installd_host_impl.cpp | 16 +- services/bundlemgr/src/installd_client.cpp | 9 +- services/bundlemgr/src/ipc/installd_host.cpp | 21 +- services/bundlemgr/src/ipc/installd_proxy.cpp | 28 ++- .../test/mock/src/installd_client.cpp | 9 +- .../test/mock/src/mock_install_client.cpp | 7 +- .../test/mock/src/mock_installd_host_impl.cpp | 7 +- .../bms_ability_manager_helper_test/BUILD.gn | 5 + .../bms_bundle_accesstokenid_test/BUILD.gn | 5 + .../unittest/bms_bundle_aot_test/BUILD.gn | 5 + .../bms_bundle_aot_test/bms_data_aot_test.cpp | 24 +- .../bms_bundle_app_control_test/BUILD.gn | 10 + .../BUILD.gn | 5 + .../bms_bundle_clone_app_test/BUILD.gn | 10 + .../bms_bundle_clone_installer_test/BUILD.gn | 5 + .../unittest/bms_bundle_common_test/BUILD.gn | 5 + .../bms_bundle_crowdtesting_test/BUILD.gn | 5 + .../bms_bundle_data_group_test/BUILD.gn | 5 + .../bms_bundle_default_app_test/BUILD.gn | 5 + .../bms_bundle_dependencies_test/BUILD.gn | 5 + .../bms_bundle_free_install_test/BUILD.gn | 10 + .../bms_bundle_hap_verify_test/BUILD.gn | 5 + .../unittest/bms_bundle_hsp_test/BUILD.gn | 15 ++ .../BUILD.gn | 5 + .../bms_bundle_installer_test/BUILD.gn | 45 ++++ .../bms_bundle_installer_test.cpp | 3 +- .../bms_bundle_installers_test/BUILD.gn | 5 + .../bms_bundle_kit_service_base_test/BUILD.gn | 5 + .../bms_bundle_kit_service_test/BUILD.gn | 15 ++ .../unittest/bms_bundle_manager_test/BUILD.gn | 5 + .../bms_bundle_navigation_test/BUILD.gn | 4 + .../unittest/bms_bundle_overlay_test/BUILD.gn | 20 ++ .../bms_bundle_permission_grant_test/BUILD.gn | 35 +++ .../BUILD.gn | 5 + .../BUILD.gn | 5 + .../BUILD.gn | 5 + .../BUILD.gn | 5 + .../bms_bundle_quick_fix_query_test/BUILD.gn | 5 + .../BUILD.gn | 5 + .../bms_bundle_quick_fix_test/BUILD.gn | 5 + .../bms_bundle_resource_manager_test/BUILD.gn | 5 + .../bms_bundle_resource_test/BUILD.gn | 5 + .../bms_bundle_sandbox_app_test/BUILD.gn | 10 + .../bms_bundle_uninstaller_test/BUILD.gn | 5 + .../unittest/bms_bundle_updater_test/BUILD.gn | 5 + .../bms_bundle_verifymanager_test/BUILD.gn | 5 + .../test/unittest/bms_data_mgr_test/BUILD.gn | 10 + .../unittest/bms_event_handler_test/BUILD.gn | 10 + .../bms_extend_resource_manager_test/BUILD.gn | 4 + .../unittest/bms_install_daemon_test/BUILD.gn | 8 + .../bms_install_daemon_host_impl_test.cpp | 3 +- .../bms_install_daemon_ipc_test.cpp | 3 +- .../unittest/bms_installd_host_test/BUILD.gn | 5 + .../bms_rdb_data_manager_test/BUILD.gn | 5 + .../bms_service_bundle_scan_test/BUILD.gn | 5 + .../bms_service_startup_test/BUILD.gn | 5 + .../unittest/bms_syscap_tool_test/BUILD.gn | 5 + .../bundleinstalldhost_fuzzer/BUILD.gn | 4 + .../bundleinstallerhost_fuzzer/BUILD.gn | 4 + 74 files changed, 804 insertions(+), 74 deletions(-) diff --git a/appexecfwk.gni b/appexecfwk.gni index e8bdca898..5fb32f4e9 100644 --- a/appexecfwk.gni +++ b/appexecfwk.gni @@ -71,6 +71,7 @@ declare_args() { bms_device_info_manager_part_enabled = true app_domain_verify_enabled = true device_usage_statistics_enabled = true + pend_sign_screenlock_mgr_enable = false if (defined(global_parts_info) && !defined(global_parts_info.resourceschedule_device_usage_statistics)) { @@ -187,6 +188,11 @@ declare_args() { !defined(global_parts_info.bundlemanager_app_domain_verify)) { app_domain_verify_enabled = false } + + if (defined(global_parts_info) && + defined(global_parts_info.theme_screenlock_mgr)) { + pend_sign_screenlock_mgr_enable = true + } } print("bundle_framework_power_mgr_enable = " + diff --git a/bundle.json b/bundle.json index 5b72f0908..ea33c7542 100644 --- a/bundle.json +++ b/bundle.json @@ -67,6 +67,7 @@ "safwk", "resource_management", "samgr", + "screenlock_mgr", "selinux_adapter", "syscap_codec", "storage_service", diff --git a/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h b/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h index 170303345..b2d6e749b 100644 --- a/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h +++ b/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h @@ -234,6 +234,7 @@ enum { ERR_APPEXECFWK_INSTALLD_GENERATE_KEY_FAILED = 8519930, ERR_APPEXECFWK_INSTALLD_DELETE_KEY_FAILED = 8519931, ERR_APPEXECFWK_INSTALLD_SIGN_AOT_FAILED = 8519932, + ERR_APPEXECFWK_INSTALLD_SIGN_AOT_DISABLE = 8519933, ERR_APPEXECFWK_RECOVER_GET_BUNDLEPATH_ERROR = APPEXECFWK_BUNDLEMGR_ERR_OFFSET + 0x0201, // 8520193 ERR_APPEXECFWK_RECOVER_INVALID_BUNDLE_NAME = 8520194, diff --git a/services/bundlemgr/BUILD.gn b/services/bundlemgr/BUILD.gn index 96a060d87..c29167c5c 100644 --- a/services/bundlemgr/BUILD.gn +++ b/services/bundlemgr/BUILD.gn @@ -439,6 +439,11 @@ ohos_shared_library("libbms") { defines += [ "APP_DOMAIN_VERIFY_ENABLED" ] } + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } + subsystem_name = "bundlemanager" part_name = "bundle_framework" } diff --git a/services/bundlemgr/include/aot/aot_executor.h b/services/bundlemgr/include/aot/aot_executor.h index b1b1d4283..b3a210413 100644 --- a/services/bundlemgr/include/aot/aot_executor.h +++ b/services/bundlemgr/include/aot/aot_executor.h @@ -34,7 +34,8 @@ struct AOTState { class AOTExecutor final { public: static AOTExecutor& GetInstance(); - void ExecuteAOT(const AOTArgs &aotArgs, ErrCode &ret); + void ExecuteAOT(const AOTArgs &aotArgs, ErrCode &ret, std::vector &pendSignData); + ErrCode PendSignAOT(const std::string &anFileName, const std::vector &signData) const; ErrCode StopAOT(); private: AOTExecutor() = default; @@ -47,8 +48,8 @@ private: ErrCode PrepareArgs(const AOTArgs &aotArgs, AOTArgs &completeArgs) const; nlohmann::json GetSubjectInfo(const AOTArgs &aotArgs) const; void MapArgs(const AOTArgs &aotArgs, std::unordered_map &argsMap); - ErrCode EnforceCodeSign(const AOTArgs &aotArgs, const std::vector &sigData) const; - ErrCode StartAOTCompiler(const AOTArgs &aotArgs, std::vector &sigData); + ErrCode EnforceCodeSign(const std::string &anFileName, const std::vector &signData) const; + ErrCode StartAOTCompiler(const AOTArgs &aotArgs, std::vector &signData); void InitState(const AOTArgs &aotArgs); void ResetState(); private: diff --git a/services/bundlemgr/include/aot/aot_handler.h b/services/bundlemgr/include/aot/aot_handler.h index e9429170a..b855c2137 100644 --- a/services/bundlemgr/include/aot/aot_handler.h +++ b/services/bundlemgr/include/aot/aot_handler.h @@ -28,16 +28,22 @@ #include "nocopyable.h" #include "serial_queue.h" +#ifdef PEND_SIGN_SCREENLOCK_MGR_ENABLED +#include "common_event_manager.h" +#include "common_event_support.h" +#include "iservice_registry.h" +#endif + namespace OHOS { namespace AppExecFwk { class AOTHandler final { public: static AOTHandler& GetInstance(); - void HandleInstall(const std::unordered_map &infos) const; + void HandleInstall(const std::unordered_map &infos); void HandleOTA(); - void HandleIdle() const; + void HandleIdle(); ErrCode HandleCompile(const std::string &bundleName, const std::string &compileMode, bool isAllBundle, - std::vector &compileResults) const; + std::vector &compileResults); void HandleResetAOT(const std::string &bundleName, bool isAllBundle) const; ErrCode HandleCopyAp(const std::string &bundleName, bool isAllBundle, std::vector &results) const; private: @@ -53,25 +59,25 @@ private: std::string GetArkProfilePath(const std::string &bundleName, const std::string &moduleName) const; std::optional BuildAOTArgs( const InnerBundleInfo &info, const std::string &moduleName, const std::string &compileMode) const; - void HandleInstallWithSingleHap(const InnerBundleInfo &info, const std::string &compileMode) const; + void HandleInstallWithSingleHap(const InnerBundleInfo &info, const std::string &compileMode); ErrCode HandleCompileWithSingleHap( - const InnerBundleInfo &info, const std::string &moduleName, const std::string &compileMode) const; + const InnerBundleInfo &info, const std::string &moduleName, const std::string &compileMode); EventInfo HandleCompileWithBundle(const std::string &bundleName, const std::string &compileMode, - std::shared_ptr dataMgr) const; + std::shared_ptr dataMgr); ErrCode HandleCompileBundles(const std::vector &bundleNames, const std::string &compileMode, - std::shared_ptr &dataMgr, std::vector &compileResults) const; + std::shared_ptr &dataMgr, std::vector &compileResults); ErrCode HandleCompileModules(const std::vector &moduleNames, const std::string &compileMode, - InnerBundleInfo &info, std::string &compileResult) const; + InnerBundleInfo &info, std::string &compileResult); void ClearArkCacheDir() const; void ResetAOTFlags() const; void HandleIdleWithSingleHap( - const InnerBundleInfo &info, const std::string &moduleName, const std::string &compileMode) const; + const InnerBundleInfo &info, const std::string &moduleName, const std::string &compileMode); bool CheckDeviceState() const; - ErrCode AOTInternal(std::optional aotArgs, uint32_t versionCode) const; + ErrCode AOTInternal(std::optional aotArgs, uint32_t versionCode); void HandleOTACompile(); void BeforeOTACompile(); - void OTACompile() const; - void OTACompileInternal() const; + void OTACompile(); + void OTACompileInternal(); bool GetOTACompileList(std::vector &bundleNames) const; bool GetUserBehaviourAppList(std::vector &bundleNames, int32_t size) const; bool IsOTACompileSwitchOn() const; @@ -82,6 +88,35 @@ private: mutable std::mutex compileMutex_; std::atomic OTACompileDeadline_ { false }; std::shared_ptr serialQueue_; + +#ifdef PEND_SIGN_SCREENLOCK_MGR_ENABLED +public: + void RegisterScreenUnlockListener(); +private: + bool StartPendingSignEvent(); + bool ExecutePendingSign(); + ErrCode FinishPendingSign(); + bool WaitForCommonEventManager() const; + bool RegisterScreenUnlockEvent(); + void UnregisterScreenUnlockEvent(); + void FinishWaiting(); + class UnlockEventSubscriber : public OHOS::EventFwk::CommonEventSubscriber { + public: + UnlockEventSubscriber(const OHOS::EventFwk::CommonEventSubscribeInfo &info) : CommonEventSubscriber(info) {} + ~UnlockEventSubscriber() override = default; + void OnReceiveEvent(const OHOS::EventFwk::CommonEventData &event) override; + }; +private: + struct PendingData { + uint32_t versionCode {0}; + std::vector signData; + }; + mutable std::mutex unlockMutex_; + std::condition_variable unlockConVar_; + std::atomic hasUnlocked_ { false }; + std::shared_ptr unlockEventSubscriber_; + std::unordered_map> pendingSignData_; +#endif }; } // namespace AppExecFwk } // namespace OHOS diff --git a/services/bundlemgr/include/bundle_framework_services_ipc_interface_code.h b/services/bundlemgr/include/bundle_framework_services_ipc_interface_code.h index f5ccbeabb..7b9425bf2 100644 --- a/services/bundlemgr/include/bundle_framework_services_ipc_interface_code.h +++ b/services/bundlemgr/include/bundle_framework_services_ipc_interface_code.h @@ -74,6 +74,7 @@ enum class InstalldInterfaceCode : uint32_t { IS_EXIST_EXTENSION_DIR, CREATE_EXTENSION_DATA_DIR, GET_DISK_USAGE, + PEND_SIGN_AOT, }; } // namespace AppExecFwk diff --git a/services/bundlemgr/include/installd/installd_host_impl.h b/services/bundlemgr/include/installd/installd_host_impl.h index 75f429b6a..3b55b38e1 100644 --- a/services/bundlemgr/include/installd/installd_host_impl.h +++ b/services/bundlemgr/include/installd/installd_host_impl.h @@ -63,7 +63,9 @@ public: virtual ErrCode ProcessBundleUnInstallNative(const std::string &userId, const std::string &bundleName) override; - virtual ErrCode ExecuteAOT(const AOTArgs &aotArgs) override; + virtual ErrCode ExecuteAOT(const AOTArgs &aotArgs, std::vector &pendSignData) override; + + virtual ErrCode PendSignAOT(const std::string &anFileName, const std::vector &signData) override; virtual ErrCode StopAOT() override; /** diff --git a/services/bundlemgr/include/installd_client.h b/services/bundlemgr/include/installd_client.h index 0cffe7def..a771ea2fc 100644 --- a/services/bundlemgr/include/installd_client.h +++ b/services/bundlemgr/include/installd_client.h @@ -186,7 +186,9 @@ public: ErrCode GetNativeLibraryFileNames(const std::string &filePath, const std::string &cpuAbi, std::vector &fileNames); - ErrCode ExecuteAOT(const AOTArgs &aotArgs); + ErrCode ExecuteAOT(const AOTArgs &aotArgs, std::vector &pendSignData); + + ErrCode PendSignAOT(const std::string &anFileName, const std::vector &signData); ErrCode StopAOT(); diff --git a/services/bundlemgr/include/ipc/installd_host.h b/services/bundlemgr/include/ipc/installd_host.h index 8021d5ee1..01a492eeb 100644 --- a/services/bundlemgr/include/ipc/installd_host.h +++ b/services/bundlemgr/include/ipc/installd_host.h @@ -69,6 +69,8 @@ private: bool HandleExecuteAOT(MessageParcel &data, MessageParcel &reply); + bool HandlePendSignAOT(MessageParcel &data, MessageParcel &reply); + bool HandleStopAOT(MessageParcel &data, MessageParcel &reply); /** * @brief Handles the RenameModuleDir function called from a IInstalld proxy object. diff --git a/services/bundlemgr/include/ipc/installd_interface.h b/services/bundlemgr/include/ipc/installd_interface.h index 439232570..f19ff3006 100644 --- a/services/bundlemgr/include/ipc/installd_interface.h +++ b/services/bundlemgr/include/ipc/installd_interface.h @@ -89,11 +89,16 @@ public: return ERR_OK; } - virtual ErrCode ExecuteAOT(const AOTArgs &aotArgs) + virtual ErrCode ExecuteAOT(const AOTArgs &aotArgs, std::vector &pendSignData) { return ERR_APPEXECFWK_INSTALLD_AOT_EXECUTE_FAILED; } + virtual ErrCode PendSignAOT(const std::string &anFileName, const std::vector &signData) + { + return ERR_APPEXECFWK_INSTALLD_SIGN_AOT_FAILED; + } + virtual ErrCode StopAOT() { return ERR_APPEXECFWK_INSTALLD_STOP_AOT_FAILED; diff --git a/services/bundlemgr/include/ipc/installd_proxy.h b/services/bundlemgr/include/ipc/installd_proxy.h index 2b20a5852..5b6ec223c 100644 --- a/services/bundlemgr/include/ipc/installd_proxy.h +++ b/services/bundlemgr/include/ipc/installd_proxy.h @@ -66,7 +66,9 @@ public: virtual ErrCode ProcessBundleUnInstallNative(const std::string &userId, const std::string &bundleName) override; - virtual ErrCode ExecuteAOT(const AOTArgs &aotArgs) override; + virtual ErrCode ExecuteAOT(const AOTArgs &aotArgs, std::vector &pendSignData) override; + + virtual ErrCode PendSignAOT(const std::string &anFileName, const std::vector &signData) override; virtual ErrCode StopAOT() override; /** diff --git a/services/bundlemgr/src/aot/aot_executor.cpp b/services/bundlemgr/src/aot/aot_executor.cpp index 9d3cd7f73..c7cd3a048 100644 --- a/services/bundlemgr/src/aot/aot_executor.cpp +++ b/services/bundlemgr/src/aot/aot_executor.cpp @@ -182,25 +182,26 @@ void AOTExecutor::MapArgs(const AOTArgs &aotArgs, std::unordered_map &sigData) const +ErrCode AOTExecutor::PendSignAOT(const std::string &anFileName, const std::vector &signData) const +{ + return EnforceCodeSign(anFileName, signData); +} + +ErrCode AOTExecutor::EnforceCodeSign(const std::string &anFileName, const std::vector &signData) const { #if defined(CODE_SIGNATURE_ENABLE) - if (sigData.empty()) { + if (signData.empty()) { APP_LOGI("not enforce code sign if no aot file save"); return ERR_OK; } - uint32_t byteSize = static_cast(sigData.size()); - std::vector byteData; - for (uint32_t i = 0; i < byteSize; ++i) { - byteData.emplace_back(static_cast(sigData[i])); + uint32_t dataSize = static_cast(signData.size()); + auto retCS = + Security::CodeSign::CodeSignUtils::EnforceCodeSignForFile(anFileName, signData.data(), dataSize); + if (retCS == VerifyErrCode::CS_ERR_ENABLE) { + APP_LOGI("pending enforce code sign as screen not first unlock after reboot"); + return ERR_APPEXECFWK_INSTALLD_SIGN_AOT_DISABLE; } - Security::CodeSign::ByteBuffer sigBuffer; - if (!sigBuffer.CopyFrom(byteData.data(), byteSize)) { - APP_LOGE("fail to receive code signature ByteBuffer"); - return ERR_APPEXECFWK_INSTALLD_SIGN_AOT_FAILED; - } - if (Security::CodeSign::CodeSignUtils::EnforceCodeSignForFile(aotArgs.anFileName, sigBuffer) - != CommonErrCode::CS_SUCCESS) { + if (retCS != CommonErrCode::CS_SUCCESS) { APP_LOGE("fail to enable code signature for the aot file"); return ERR_APPEXECFWK_INSTALLD_SIGN_AOT_FAILED; } @@ -212,7 +213,7 @@ ErrCode AOTExecutor::EnforceCodeSign(const AOTArgs &aotArgs, const std::vector &sigData) +ErrCode AOTExecutor::StartAOTCompiler(const AOTArgs &aotArgs, std::vector &signData) { #if defined(CODE_SIGNATURE_ENABLE) std::unordered_map argsMap; @@ -225,7 +226,8 @@ ErrCode AOTExecutor::StartAOTCompiler(const AOTArgs &aotArgs, std::vector fileData; + ret = ArkCompiler::AotCompilerClient::GetInstance().AotCompiler(argsMap, fileData); if (ret == ERR_AOT_COMPILER_SIGN_FAILED) { APP_LOGE("aot compiler local signature fail"); return ERR_APPEXECFWK_INSTALLD_SIGN_AOT_FAILED; @@ -234,6 +236,10 @@ ErrCode AOTExecutor::StartAOTCompiler(const AOTArgs &aotArgs, std::vector(fileData.size()); + for (uint32_t i = 0; i < byteSize; ++i) { + signData.emplace_back(static_cast(fileData[i])); + } APP_LOGI("aot compiler success"); return ERR_OK; #else @@ -242,7 +248,7 @@ ErrCode AOTExecutor::StartAOTCompiler(const AOTArgs &aotArgs, std::vector &pendSignData) { #if defined(CODE_SIGNATURE_ENABLE) APP_LOGI("begin to execute AOT"); @@ -265,10 +271,13 @@ void AOTExecutor::ExecuteAOT(const AOTArgs &aotArgs, ErrCode &ret) InitState(aotArgs); } APP_LOGI("begin to call aot compiler"); - std::vector fileData; - ret = StartAOTCompiler(completeArgs, fileData); + std::vector signData; + ret = StartAOTCompiler(completeArgs, signData); if (ret == ERR_OK) { - ret = EnforceCodeSign(completeArgs, fileData); + ret = EnforceCodeSign(completeArgs.anFileName, signData); + } + if (ret == ERR_APPEXECFWK_INSTALLD_SIGN_AOT_DISABLE) { + pendSignData = signData; } APP_LOGI("aot compiler finish"); { diff --git a/services/bundlemgr/src/aot/aot_handler.cpp b/services/bundlemgr/src/aot/aot_handler.cpp index 1f2b7abc3..d83944573 100644 --- a/services/bundlemgr/src/aot/aot_handler.cpp +++ b/services/bundlemgr/src/aot/aot_handler.cpp @@ -36,6 +36,11 @@ #include "user_status_client.h" #endif +#ifdef PEND_SIGN_SCREENLOCK_MGR_ENABLED +#include "datetime_ex.h" +#include "screenlock_manager.h" +#endif + namespace OHOS { namespace AppExecFwk { namespace { @@ -82,6 +87,14 @@ constexpr const char* PGO_MERGED_AP_PREFIX = "merged_"; constexpr const char* PGO_RT_AP_PREFIX = "rt_"; constexpr const char* COPY_AP_DEST_PATH = "/data/local/pgo/"; constexpr const char* COMPILE_NONE = "none"; + +#ifdef PEND_SIGN_SCREENLOCK_MGR_ENABLED +constexpr int32_t SLEEP_TIME_FOR_COMMON_EVENT_MGR = 500 * 1000; // 500 ms +constexpr int32_t SLEEP_TIME_FOR_COMMON_EVENT_MGR_TIME_OUT = 10 * 60; // 10 min +constexpr int32_t COMMON_EVENT_MANAGER_ID = 3299; +constexpr int32_t SLEEP_TIME_FOR_WAIT_SIGN_ENABLE = 1; // 1 s +constexpr int32_t LOOP_TIMES_FOR_WAIT_SIGN_ENABLE = 5; +#endif } AOTHandler::AOTHandler() @@ -196,19 +209,28 @@ std::optional AOTHandler::BuildAOTArgs( return aotArgs; } -ErrCode AOTHandler::AOTInternal(std::optional aotArgs, uint32_t versionCode) const +ErrCode AOTHandler::AOTInternal(std::optional aotArgs, uint32_t versionCode) { if (!aotArgs) { APP_LOGI("aotArgs empty"); return ERR_APPEXECFWK_AOT_ARGS_EMPTY; } ErrCode ret = ERR_OK; + std::vector pendSignData; { std::lock_guard lock(executeMutex_); - ret = InstalldClient::GetInstance()->ExecuteAOT(*aotArgs); + ret = InstalldClient::GetInstance()->ExecuteAOT(*aotArgs, pendSignData); } APP_LOGI("ExecuteAOT ret : %{public}d", ret); - +#ifdef PEND_SIGN_SCREENLOCK_MGR_ENABLED + if (!hasUnlocked_ && !pendSignData.empty()) { + PendingData pendingData = {versionCode, pendSignData}; + { + std::lock_guard lock(unlockMutex_); + pendingSignData_[aotArgs->bundleName][aotArgs->moduleName] = pendingData; + } + } +#endif auto dataMgr = DelayedSingleton::GetInstance()->GetDataMgr(); if (!dataMgr) { APP_LOGE("dataMgr is null"); @@ -219,13 +241,13 @@ ErrCode AOTHandler::AOTInternal(std::optional aotArgs, uint32_t version return ret; } -void AOTHandler::HandleInstallWithSingleHap(const InnerBundleInfo &info, const std::string &compileMode) const +void AOTHandler::HandleInstallWithSingleHap(const InnerBundleInfo &info, const std::string &compileMode) { std::optional aotArgs = BuildAOTArgs(info, info.GetCurrentModulePackage(), compileMode); (void)AOTInternal(aotArgs, info.GetVersionCode()); } -void AOTHandler::HandleInstall(const std::unordered_map &infos) const +void AOTHandler::HandleInstall(const std::unordered_map &infos) { auto task = [this, infos]() { APP_LOGD("HandleInstall begin"); @@ -463,7 +485,7 @@ void AOTHandler::BeforeOTACompile() serialQueue_->ScheduleDelayTask(TASK_NAME, delayTimeSeconds * CONVERSION_FACTOR, task); } -void AOTHandler::OTACompile() const +void AOTHandler::OTACompile() { auto OTACompileTask = [this]() { OTACompileInternal(); @@ -471,7 +493,7 @@ void AOTHandler::OTACompile() const std::thread(OTACompileTask).detach(); } -void AOTHandler::OTACompileInternal() const +void AOTHandler::OTACompileInternal() { APP_LOGI("OTACompileInternal begin"); system::SetParameter(OTA_COMPILE_STATUS, OTA_COMPILE_STATUS_BEGIN); @@ -546,7 +568,7 @@ bool AOTHandler::GetUserBehaviourAppList(std::vector &bundleNames, } EventInfo AOTHandler::HandleCompileWithBundle(const std::string &bundleName, const std::string &compileMode, - std::shared_ptr dataMgr) const + std::shared_ptr dataMgr) { APP_LOGI("handle compile bundle : %{public}s", bundleName.c_str()); EventInfo eventInfo; @@ -624,7 +646,7 @@ void AOTHandler::ReportSysEvent(const std::map &sysEvent } void AOTHandler::HandleIdleWithSingleHap( - const InnerBundleInfo &info, const std::string &moduleName, const std::string &compileMode) const + const InnerBundleInfo &info, const std::string &moduleName, const std::string &compileMode) { APP_LOGD("HandleIdleWithSingleHap, moduleName : %{public}s", moduleName.c_str()); if (info.GetAOTCompileStatus(moduleName) == AOTCompileStatus::COMPILE_SUCCESS) { @@ -636,7 +658,7 @@ void AOTHandler::HandleIdleWithSingleHap( } ErrCode AOTHandler::HandleCompileWithSingleHap( - const InnerBundleInfo &info, const std::string &moduleName, const std::string &compileMode) const + const InnerBundleInfo &info, const std::string &moduleName, const std::string &compileMode) { APP_LOGI("HandleCompileWithSingleHap, moduleName : %{public}s", moduleName.c_str()); std::optional aotArgs = BuildAOTArgs(info, moduleName, compileMode); @@ -659,7 +681,7 @@ bool AOTHandler::CheckDeviceState() const #endif } -void AOTHandler::HandleIdle() const +void AOTHandler::HandleIdle() { APP_LOGI("HandleIdle begin"); std::unique_lock lock(idleMutex_, std::defer_lock); @@ -708,7 +730,7 @@ void AOTHandler::HandleIdle() const } ErrCode AOTHandler::HandleCompile(const std::string &bundleName, const std::string &compileMode, bool isAllBundle, - std::vector &compileResults) const + std::vector &compileResults) { APP_LOGI("HandleCompile begin"); std::unique_lock lock(compileMutex_, std::defer_lock); @@ -752,7 +774,7 @@ ErrCode AOTHandler::HandleCompile(const std::string &bundleName, const std::stri } ErrCode AOTHandler::HandleCompileBundles(const std::vector &bundleNames, const std::string &compileMode, - std::shared_ptr &dataMgr, std::vector &compileResults) const + std::shared_ptr &dataMgr, std::vector &compileResults) { ErrCode ret = ERR_OK; std::for_each(bundleNames.cbegin(), bundleNames.cend(), @@ -788,7 +810,7 @@ ErrCode AOTHandler::HandleCompileBundles(const std::vector &bundleN } ErrCode AOTHandler::HandleCompileModules(const std::vector &moduleNames, const std::string &compileMode, - InnerBundleInfo &info, std::string &compileResult) const + InnerBundleInfo &info, std::string &compileResult) { ErrCode ret = ERR_OK; std::for_each(moduleNames.cbegin(), moduleNames.cend(), @@ -801,6 +823,7 @@ ErrCode AOTHandler::HandleCompileModules(const std::vector &moduleN compileResult += " " + moduleName + ":compile-fail"; break; case ERR_APPEXECFWK_INSTALLD_SIGN_AOT_FAILED: + case ERR_APPEXECFWK_INSTALLD_SIGN_AOT_DISABLE: compileResult += " " + moduleName + ":signature-fail"; break; case ERR_APPEXECFWK_AOT_ARGS_EMPTY: @@ -816,5 +839,177 @@ ErrCode AOTHandler::HandleCompileModules(const std::vector &moduleN }); return ret; } + +#ifdef PEND_SIGN_SCREENLOCK_MGR_ENABLED +void AOTHandler::RegisterScreenUnlockListener() +{ + auto PendingSignTask = [this]() { + if (!StartPendingSignEvent()) { + APP_LOGE("pending sign AOT event error"); + } + }; + std::thread(PendingSignTask).detach(); +} + +bool AOTHandler::StartPendingSignEvent() +{ + if (hasUnlocked_) { + return true; + } + { + std::unique_lock lock(unlockMutex_); + bool lockStatus = false; + if (ScreenLock::ScreenLockManager::GetInstance()->IsLocked(lockStatus) == ScreenLock::E_SCREENLOCK_OK) { + APP_LOGI("screen lock status = %{public}d", lockStatus); + hasUnlocked_ = !lockStatus; + } else { + APP_LOGE("unable get lock screen status"); + } + if (hasUnlocked_) { + return true; + } + if (!WaitForCommonEventManager()) { + return false; + } + if (!RegisterScreenUnlockEvent()) { + return false; + } + unlockConVar_.wait(lock, [this]() { + bool ret = this->hasUnlocked_; + return ret; + }); + APP_LOGI("thread is wake up"); + UnregisterScreenUnlockEvent(); + } + return ExecutePendingSign(); +} + +bool AOTHandler::ExecutePendingSign() +{ + sleep(SLEEP_TIME_FOR_WAIT_SIGN_ENABLE); + int32_t loopTimes = 0; + while (FinishPendingSign() != ERR_OK) { + if (++loopTimes > LOOP_TIMES_FOR_WAIT_SIGN_ENABLE) { + APP_LOGE("wait for enforce sign enable time out"); + return false; + } + sleep(SLEEP_TIME_FOR_WAIT_SIGN_ENABLE); + } + { + std::lock_guard lock(unlockMutex_); + pendingSignData_.clear(); + } + APP_LOGI("pending enforce sign success"); + return true; +} + +ErrCode AOTHandler::FinishPendingSign() +{ + std::lock_guard lock(unlockMutex_); + ErrCode ret = ERR_OK; + for (auto itBundle = pendingSignData_.begin(); itBundle != pendingSignData_.end(); ++itBundle) { + auto &bundleName = itBundle->first; + auto &moduleSignData = itBundle->second; + for (auto itModule = moduleSignData.begin(); itModule != moduleSignData.end();) { + auto &moduleName = itModule->first; + auto &signData = itModule->second.signData; + std::string anFileName = ServiceConstants::ARK_CACHE_PATH + bundleName + ServiceConstants::PATH_SEPARATOR + + ServiceConstants::ARM64 + ServiceConstants::PATH_SEPARATOR + moduleName + ServiceConstants::AN_SUFFIX; + + ErrCode retCS = InstalldClient::GetInstance()->PendSignAOT(anFileName, signData); + if (retCS == ERR_APPEXECFWK_INSTALLD_SIGN_AOT_DISABLE) { + APP_LOGE("enforce sign service is disable"); + ret = ERR_APPEXECFWK_INSTALLD_SIGN_AOT_FAILED; + ++itModule; + continue; + } else if (retCS != ERR_OK) { + itModule = moduleSignData.erase(itModule); + continue; + } + auto dataMgr = DelayedSingleton::GetInstance()->GetDataMgr(); + if (!dataMgr) { + APP_LOGE("dataMgr is null"); + ret = ERR_APPEXECFWK_INSTALLD_SIGN_AOT_FAILED; + ++itModule; + continue; + } + auto versionCode = itModule->second.versionCode; + dataMgr->SetAOTCompileStatus(bundleName, moduleName, AOTCompileStatus::COMPILE_SUCCESS, versionCode); + itModule = moduleSignData.erase(itModule); + } + } + return ret; +} + +bool AOTHandler::WaitForCommonEventManager() const +{ + struct tm doingTime = {0}; + struct tm startTime = {0}; + int64_t seconds = 0; + bool ret = false; + if (!OHOS::GetSystemCurrentTime(&startTime)) { + return false; + } + while (seconds <= SLEEP_TIME_FOR_COMMON_EVENT_MGR_TIME_OUT) { + auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager(); + if (samgr != nullptr && samgr->CheckSystemAbility(COMMON_EVENT_MANAGER_ID) != nullptr) { + APP_LOGI("common event manager is loaded"); + ret = true; + break; + } + APP_LOGD("get common event manager failed"); + usleep(SLEEP_TIME_FOR_COMMON_EVENT_MGR); + if (OHOS::GetSystemCurrentTime(&doingTime)) { + seconds = OHOS::GetSecondsBetween(startTime, doingTime); + } + } + return ret; +} + +bool AOTHandler::RegisterScreenUnlockEvent() +{ + APP_LOGI("register screen unlock event start"); + EventFwk::MatchingSkills matchingSkill; + // use COMMON_EVENT_USER_UNLOCKED if only for device with PIN + matchingSkill.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_UNLOCKED); + EventFwk::CommonEventSubscribeInfo eventInfo(matchingSkill); + unlockEventSubscriber_ = std::make_shared(eventInfo); + const auto result = EventFwk::CommonEventManager::SubscribeCommonEvent(unlockEventSubscriber_); + if (!result) { + APP_LOGE("register screen unlock event error"); + return false; + } + APP_LOGI("register screen unlock event success"); + return true; +} + +void AOTHandler::UnregisterScreenUnlockEvent() +{ + APP_LOGI("unregister screen unlock event start"); + const auto result = EventFwk::CommonEventManager::UnSubscribeCommonEvent(unlockEventSubscriber_); + if (!result) { + APP_LOGE("unregister screen unlock event error"); + return; + } + APP_LOGI("unregister screen unlock event success"); +} + +void AOTHandler::UnlockEventSubscriber::OnReceiveEvent(const EventFwk::CommonEventData &event) +{ + const auto want = event.GetWant(); + const auto action = want.GetAction(); + if (action == EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_UNLOCKED) { + APP_LOGI("receive screen unlock event"); + AOTHandler::GetInstance().FinishWaiting(); + } +} + +void AOTHandler::FinishWaiting() +{ + std::unique_lock lock(unlockMutex_); + hasUnlocked_ = true; + unlockConVar_.notify_one(); +} +#endif } // namespace AppExecFwk } // namespace OHOS diff --git a/services/bundlemgr/src/bundle_mgr_service_event_handler.cpp b/services/bundlemgr/src/bundle_mgr_service_event_handler.cpp index ec57bae2a..54f8819a2 100644 --- a/services/bundlemgr/src/bundle_mgr_service_event_handler.cpp +++ b/services/bundlemgr/src/bundle_mgr_service_event_handler.cpp @@ -273,6 +273,9 @@ void BMSEventHandler::AfterBmsStart() } ListeningUserUnlocked(); RemoveUnreservedSandbox(); +#ifdef PEND_SIGN_SCREENLOCK_MGR_ENABLED + AOTHandler::GetInstance().RegisterScreenUnlockListener(); +#endif DelayedSingleton::GetInstance()->RegisterChargeIdleListener(); BundleResourceHelper::RegisterCommonEventSubscriber(); BundleResourceHelper::RegisterConfigurationObserver(); diff --git a/services/bundlemgr/src/installd/installd_host_impl.cpp b/services/bundlemgr/src/installd/installd_host_impl.cpp index f50451fcb..0f46c1b16 100644 --- a/services/bundlemgr/src/installd/installd_host_impl.cpp +++ b/services/bundlemgr/src/installd/installd_host_impl.cpp @@ -200,7 +200,7 @@ ErrCode InstalldHostImpl::ProcessBundleUnInstallNative(const std::string &userId return ERR_OK; } -ErrCode InstalldHostImpl::ExecuteAOT(const AOTArgs &aotArgs) +ErrCode InstalldHostImpl::ExecuteAOT(const AOTArgs &aotArgs, std::vector &pendSignData) { LOG_D(BMS_TAG_INSTALLD, "begin to execute AOT, args : %{public}s", aotArgs.ToString().c_str()); if (!InstalldPermissionMgr::VerifyCallingPermission(Constants::FOUNDATION_UID)) { @@ -208,11 +208,23 @@ ErrCode InstalldHostImpl::ExecuteAOT(const AOTArgs &aotArgs) return ERR_APPEXECFWK_INSTALLD_PERMISSION_DENIED; } ErrCode ret = ERR_OK; - AOTExecutor::GetInstance().ExecuteAOT(aotArgs, ret); + AOTExecutor::GetInstance().ExecuteAOT(aotArgs, ret, pendSignData); LOG_D(BMS_TAG_INSTALLD, "execute AOT ret : %{public}d", ret); return ret; } +ErrCode InstalldHostImpl::PendSignAOT(const std::string &anFileName, const std::vector &signData) +{ + LOG_D(BMS_TAG_INSTALLD, "begin to pend sign AOT, anFileName : %{public}s", anFileName.c_str()); + if (!InstalldPermissionMgr::VerifyCallingPermission(Constants::FOUNDATION_UID)) { + LOG_E(BMS_TAG_INSTALLD, "installd permission denied, only used for foundation process"); + return ERR_APPEXECFWK_INSTALLD_PERMISSION_DENIED; + } + ErrCode ret = AOTExecutor::GetInstance().PendSignAOT(anFileName, signData); + LOG_D(BMS_TAG_INSTALLD, "pend sign AOT ret : %{public}d", ret); + return ret; +} + ErrCode InstalldHostImpl::StopAOT() { LOG_I(BMS_TAG_INSTALLD, "StopAOT begin"); diff --git a/services/bundlemgr/src/installd_client.cpp b/services/bundlemgr/src/installd_client.cpp index bbdd23ec7..4dafe43e4 100644 --- a/services/bundlemgr/src/installd_client.cpp +++ b/services/bundlemgr/src/installd_client.cpp @@ -80,9 +80,14 @@ ErrCode InstalldClient::ProcessBundleUnInstallNative(const std::string &userId, return CallService(&IInstalld::ProcessBundleUnInstallNative, userId, packageName); } -ErrCode InstalldClient::ExecuteAOT(const AOTArgs &aotArgs) +ErrCode InstalldClient::ExecuteAOT(const AOTArgs &aotArgs, std::vector &pendSignData) { - return CallService(&IInstalld::ExecuteAOT, aotArgs); + return CallService(&IInstalld::ExecuteAOT, aotArgs, pendSignData); +} + +ErrCode InstalldClient::PendSignAOT(const std::string &anFileName, const std::vector &signData) +{ + return CallService(&IInstalld::PendSignAOT, anFileName, signData); } ErrCode InstalldClient::StopAOT() diff --git a/services/bundlemgr/src/ipc/installd_host.cpp b/services/bundlemgr/src/ipc/installd_host.cpp index 4f8720390..7165db448 100644 --- a/services/bundlemgr/src/ipc/installd_host.cpp +++ b/services/bundlemgr/src/ipc/installd_host.cpp @@ -96,6 +96,7 @@ void InstalldHost::Init() funcMap_.emplace(static_cast(InstalldInterfaceCode::GET_NATIVE_LIBRARY_FILE_NAMES), &InstalldHost::HandGetNativeLibraryFileNames); funcMap_.emplace(static_cast(InstalldInterfaceCode::EXECUTE_AOT), &InstalldHost::HandleExecuteAOT); + funcMap_.emplace(static_cast(InstalldInterfaceCode::PEND_SIGN_AOT), &InstalldHost::HandlePendSignAOT); funcMap_.emplace(static_cast(InstalldInterfaceCode::IS_EXIST_FILE), &InstalldHost::HandleIsExistFile); funcMap_.emplace(static_cast(InstalldInterfaceCode::IS_EXIST_AP_FILE), &InstalldHost::HandleIsExistApFile); @@ -248,7 +249,25 @@ bool InstalldHost::HandleExecuteAOT(MessageParcel &data, MessageParcel &reply) return false; } - ErrCode result = ExecuteAOT(*aotArgs); + std::vector pendSignData; + ErrCode result = ExecuteAOT(*aotArgs, pendSignData); + WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, reply, result); + if (!reply.WriteUInt8Vector(pendSignData)) { + LOG_E(BMS_TAG_INSTALLD, "WriteParcelable ExecuteAOT failed"); + return false; + } + return true; +} + +bool InstalldHost::HandlePendSignAOT(MessageParcel &data, MessageParcel &reply) +{ + std::string anFileName = Str16ToStr8(data.ReadString16()); + std::vector signData; + if (!data.ReadUInt8Vector(&signData)) { + LOG_E(BMS_TAG_INSTALLD, "ReadUInt8Vector PendSignAOT failed"); + return false; + } + ErrCode result = PendSignAOT(anFileName, signData); WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, reply, result); return true; } diff --git a/services/bundlemgr/src/ipc/installd_proxy.cpp b/services/bundlemgr/src/ipc/installd_proxy.cpp index a78d65520..794c1abb0 100644 --- a/services/bundlemgr/src/ipc/installd_proxy.cpp +++ b/services/bundlemgr/src/ipc/installd_proxy.cpp @@ -124,7 +124,7 @@ ErrCode InstalldProxy::ProcessBundleUnInstallNative(const std::string &userId, c } -ErrCode InstalldProxy::ExecuteAOT(const AOTArgs &aotArgs) +ErrCode InstalldProxy::ExecuteAOT(const AOTArgs &aotArgs, std::vector &pendSignData) { MessageParcel data; INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor())); @@ -135,7 +135,31 @@ ErrCode InstalldProxy::ExecuteAOT(const AOTArgs &aotArgs) MessageParcel reply; MessageOption option; - return TransactInstalldCmd(InstalldInterfaceCode::EXECUTE_AOT, data, reply, option); + ErrCode ret = TransactInstalldCmd(InstalldInterfaceCode::EXECUTE_AOT, data, reply, option); + if (ret != ERR_OK) { + LOG_E(BMS_TAG_INSTALLD, "TransactInstalldCmd ExecuteAOT failed"); + if (!reply.ReadUInt8Vector(&pendSignData)) { + LOG_E(BMS_TAG_INSTALLD, "ReadUInt8Vector ExecuteAOT failed"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + return ret; + } + return ERR_OK; +} + +ErrCode InstalldProxy::PendSignAOT(const std::string &anFileName, const std::vector &signData) +{ + MessageParcel data; + INSTALLD_PARCEL_WRITE_INTERFACE_TOKEN(data, (GetDescriptor())); + INSTALLD_PARCEL_WRITE(data, String16, Str8ToStr16(anFileName)); + if (!data.WriteUInt8Vector(signData)) { + LOG_E(BMS_TAG_INSTALLD, "WriteParcelable PendSignAOT failed"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + + MessageParcel reply; + MessageOption option; + return TransactInstalldCmd(InstalldInterfaceCode::PEND_SIGN_AOT, data, reply, option); } ErrCode InstalldProxy::StopAOT() diff --git a/services/bundlemgr/test/mock/src/installd_client.cpp b/services/bundlemgr/test/mock/src/installd_client.cpp index f13e31fbf..a5d5a56b1 100644 --- a/services/bundlemgr/test/mock/src/installd_client.cpp +++ b/services/bundlemgr/test/mock/src/installd_client.cpp @@ -72,9 +72,14 @@ ErrCode InstalldClient::ProcessBundleUnInstallNative(const std::string &userId, return CallService(&IInstalld::ProcessBundleUnInstallNative, userId, packageName); } -ErrCode InstalldClient::ExecuteAOT(const AOTArgs &aotArgs) +ErrCode InstalldClient::ExecuteAOT(const AOTArgs &aotArgs, std::vector &pendSignData) { - return CallService(&IInstalld::ExecuteAOT, aotArgs); + return CallService(&IInstalld::ExecuteAOT, aotArgs, pendSignData); +} + +ErrCode InstalldClient::PendSignAOT(const std::string &anFileName, const std::vector &signData) +{ + return CallService(&IInstalld::PendSignAOT, anFileName, signData); } ErrCode InstalldClient::StopAOT() diff --git a/services/bundlemgr/test/mock/src/mock_install_client.cpp b/services/bundlemgr/test/mock/src/mock_install_client.cpp index d56dd4380..8b4655469 100644 --- a/services/bundlemgr/test/mock/src/mock_install_client.cpp +++ b/services/bundlemgr/test/mock/src/mock_install_client.cpp @@ -49,7 +49,12 @@ ErrCode InstalldClient::ProcessBundleUnInstallNative(const std::string &userId, return 0; } -ErrCode InstalldClient::ExecuteAOT(const AOTArgs &aotArgs) +ErrCode InstalldClient::ExecuteAOT(const AOTArgs &aotArgs, std::vector &pendSignData) +{ + return 0; +} + +ErrCode InstalldClient::PendSignAOT(const std::string &anFileName, const std::vector &signData) { return 0; } diff --git a/services/bundlemgr/test/mock/src/mock_installd_host_impl.cpp b/services/bundlemgr/test/mock/src/mock_installd_host_impl.cpp index d2921ee17..9179e9f0c 100755 --- a/services/bundlemgr/test/mock/src/mock_installd_host_impl.cpp +++ b/services/bundlemgr/test/mock/src/mock_installd_host_impl.cpp @@ -205,7 +205,12 @@ ErrCode InstalldHostImpl::ExtractFiles(const ExtractParam &extractParam) return ERR_OK; } -ErrCode InstalldHostImpl::ExecuteAOT(const AOTArgs &aotArgs) +ErrCode InstalldHostImpl::ExecuteAOT(const AOTArgs &aotArgs, std::vector &pendSignData) +{ + return ERR_OK; +} + +ErrCode InstalldHostImpl::PendSignAOT(const std::string &anFileName, const std::vector &signData) { return ERR_OK; } diff --git a/services/bundlemgr/test/unittest/bms_ability_manager_helper_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_ability_manager_helper_test/BUILD.gn index 44f98b6b0..417c6b517 100644 --- a/services/bundlemgr/test/unittest/bms_ability_manager_helper_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_ability_manager_helper_test/BUILD.gn @@ -154,6 +154,11 @@ ohos_unittest("BmsAbilityManagerHelperTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_accesstokenid_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_accesstokenid_test/BUILD.gn index e29578827..654540103 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_accesstokenid_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_accesstokenid_test/BUILD.gn @@ -181,6 +181,11 @@ ohos_unittest("BmsBundleAccessTokenIdTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_aot_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_aot_test/BUILD.gn index 580c05807..7b9d72750 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_aot_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_aot_test/BUILD.gn @@ -173,6 +173,11 @@ ohos_unittest("BmsAOTMgrTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_aot_test/bms_data_aot_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_aot_test/bms_data_aot_test.cpp index 4e9a5e363..643556275 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_aot_test/bms_data_aot_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_aot_test/bms_data_aot_test.cpp @@ -161,7 +161,8 @@ HWTEST_F(BmsAOTMgrTest, AOTExecutor_0100, Function | SmallTest | Level0) { AOTArgs aotArgs; ErrCode ret; - AOTExecutor::GetInstance().ExecuteAOT(aotArgs, ret); + std::vector pendSignData; + AOTExecutor::GetInstance().ExecuteAOT(aotArgs, ret, pendSignData); EXPECT_NE(ret, ERR_OK); } @@ -175,8 +176,9 @@ HWTEST_F(BmsAOTMgrTest, AOTExecutor_0200, Function | SmallTest | Level0) { AOTArgs aotArgs; ErrCode ret; + std::vector pendSignData; aotArgs.compileMode = ServiceConstants::COMPILE_PARTIAL; - AOTExecutor::GetInstance().ExecuteAOT(aotArgs, ret); + AOTExecutor::GetInstance().ExecuteAOT(aotArgs, ret, pendSignData); EXPECT_NE(ret, ERR_OK); } @@ -190,8 +192,9 @@ HWTEST_F(BmsAOTMgrTest, AOTExecutor_0300, Function | SmallTest | Level0) { AOTArgs aotArgs; ErrCode ret; + std::vector pendSignData; aotArgs.hapPath = HAP_PATH; - AOTExecutor::GetInstance().ExecuteAOT(aotArgs, ret); + AOTExecutor::GetInstance().ExecuteAOT(aotArgs, ret, pendSignData); EXPECT_NE(ret, ERR_OK); } @@ -205,8 +208,9 @@ HWTEST_F(BmsAOTMgrTest, AOTExecutor_0400, Function | SmallTest | Level0) { AOTArgs aotArgs; ErrCode ret; + std::vector pendSignData; aotArgs.outputPath = OUT_PUT_PATH; - AOTExecutor::GetInstance().ExecuteAOT(aotArgs, ret); + AOTExecutor::GetInstance().ExecuteAOT(aotArgs, ret, pendSignData); EXPECT_NE(ret, ERR_OK); } @@ -220,10 +224,11 @@ HWTEST_F(BmsAOTMgrTest, AOTExecutor_0500, Function | SmallTest | Level0) { AOTArgs aotArgs; ErrCode ret; + std::vector pendSignData; aotArgs.compileMode = ServiceConstants::COMPILE_PARTIAL; aotArgs.hapPath = ABC_RELATIVE_PATH; aotArgs.outputPath = OUT_PUT_PATH; - AOTExecutor::GetInstance().ExecuteAOT(aotArgs, ret); + AOTExecutor::GetInstance().ExecuteAOT(aotArgs, ret, pendSignData); EXPECT_NE(ret, ERR_OK); } @@ -237,11 +242,12 @@ HWTEST_F(BmsAOTMgrTest, AOTExecutor_0600, Function | SmallTest | Level0) { AOTArgs aotArgs; ErrCode ret; + std::vector pendSignData; aotArgs.compileMode = COMPILE_FULL; aotArgs.hapPath = NOHAP_PATH; aotArgs.outputPath = OUT_PUT_PATH; aotArgs.arkProfilePath = OUT_PUT_PATH; - AOTExecutor::GetInstance().ExecuteAOT(aotArgs, ret); + AOTExecutor::GetInstance().ExecuteAOT(aotArgs, ret, pendSignData); EXPECT_NE(ret, ERR_OK); } @@ -255,12 +261,13 @@ HWTEST_F(BmsAOTMgrTest, AOTExecutor_0700, Function | SmallTest | Level0) { AOTArgs aotArgs; ErrCode ret; + std::vector pendSignData; aotArgs.compileMode = COMPILE_FULL; aotArgs.hapPath = HAP_PATH; aotArgs.outputPath = OUT_PUT_PATH; aotArgs.arkProfilePath = OUT_PUT_PATH; - AOTExecutor::GetInstance().ExecuteAOT(aotArgs, ret); + AOTExecutor::GetInstance().ExecuteAOT(aotArgs, ret, pendSignData); EXPECT_NE(ret, ERR_OK); } @@ -274,12 +281,13 @@ HWTEST_F(BmsAOTMgrTest, AOTExecutor_0800, Function | SmallTest | Level0) { AOTArgs aotArgs; ErrCode ret; + std::vector pendSignData; aotArgs.compileMode = COMPILE_FULL; aotArgs.hapPath = HAP_PATH; aotArgs.outputPath = OUT_PUT_PATH; aotArgs.arkProfilePath = OUT_PUT_PATH; - AOTExecutor::GetInstance().ExecuteAOT(aotArgs, ret); + AOTExecutor::GetInstance().ExecuteAOT(aotArgs, ret, pendSignData); EXPECT_NE(ret, ERR_OK); } diff --git a/services/bundlemgr/test/unittest/bms_bundle_app_control_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_app_control_test/BUILD.gn index 460ee3615..96180afbe 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_app_control_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_app_control_test/BUILD.gn @@ -170,6 +170,11 @@ ohos_unittest("BmsBundleAppControlTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsBundleMockAppControlTest") { @@ -322,6 +327,11 @@ ohos_unittest("BmsBundleMockAppControlTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_app_provision_info_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_app_provision_info_test/BUILD.gn index eb49b3129..3508b1cdc 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_app_provision_info_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_app_provision_info_test/BUILD.gn @@ -174,6 +174,11 @@ ohos_unittest("BmsBundleAppProvisionInfoTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_clone_app_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_clone_app_test/BUILD.gn index 406edc610..63c2cf357 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_clone_app_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_clone_app_test/BUILD.gn @@ -164,6 +164,11 @@ ohos_unittest("BmsBundleCloneAppBundleLogicTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsBundleCloneAppDataStructTest") { @@ -377,6 +382,11 @@ ohos_unittest("BmsBundleCloneAppIpcTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_clone_installer_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_clone_installer_test/BUILD.gn index 977f945f7..5ad48208a 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_clone_installer_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_clone_installer_test/BUILD.gn @@ -199,6 +199,11 @@ ohos_unittest("BmsBundleCloneInstallerTest") { ] defines += [ "APP_DOMAIN_VERIFY_ENABLED" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { testonly = true diff --git a/services/bundlemgr/test/unittest/bms_bundle_common_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_common_test/BUILD.gn index e409bc408..e561dfda5 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_common_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_common_test/BUILD.gn @@ -170,6 +170,11 @@ ohos_unittest("BmsBundleCommonTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_crowdtesting_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_crowdtesting_test/BUILD.gn index baa63e386..13abfdc1f 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_crowdtesting_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_crowdtesting_test/BUILD.gn @@ -165,6 +165,11 @@ ohos_unittest("BmsBundleCrowdtestingTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_data_group_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_data_group_test/BUILD.gn index 5bc8e1703..66d07e4e8 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_data_group_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_data_group_test/BUILD.gn @@ -157,6 +157,11 @@ ohos_unittest("BmsBundleDataGroupTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_default_app_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_default_app_test/BUILD.gn index ff1b2e748..ac07bf131 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_default_app_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_default_app_test/BUILD.gn @@ -174,6 +174,11 @@ ohos_unittest("BmsBundleDefaultAppTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_dependencies_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_dependencies_test/BUILD.gn index 3728d380c..88d06d9ce 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_dependencies_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_dependencies_test/BUILD.gn @@ -166,6 +166,11 @@ ohos_unittest("BmsBundleDependenciesTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_free_install_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_free_install_test/BUILD.gn index de39afef0..99dcf79b4 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_free_install_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_free_install_test/BUILD.gn @@ -179,6 +179,11 @@ ohos_unittest("BmsBundleFreeInstallBaseTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsBundleFreeInstallTest") { @@ -343,6 +348,11 @@ ohos_unittest("BmsBundleFreeInstallTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_hap_verify_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_hap_verify_test/BUILD.gn index 2ea0c5631..6486c1888 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_hap_verify_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_hap_verify_test/BUILD.gn @@ -167,6 +167,11 @@ ohos_unittest("BmsBundleHapVerifyTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_hsp_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_hsp_test/BUILD.gn index 7a80f97cd..9d98a9595 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_hsp_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_hsp_test/BUILD.gn @@ -168,6 +168,11 @@ ohos_unittest("BmsBundleHspTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsBundleSharedLibraryInstallTest") { @@ -324,6 +329,11 @@ ohos_unittest("BmsBundleSharedLibraryInstallTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsBundleSharedLibraryUninstallTest") { @@ -475,6 +485,11 @@ ohos_unittest("BmsBundleSharedLibraryUninstallTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_installer_manager_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_installer_manager_test/BUILD.gn index d0f6d2e2b..b265dbdaf 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_installer_manager_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_installer_manager_test/BUILD.gn @@ -173,6 +173,11 @@ ohos_unittest("BmsBundleInstallerManagerTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_installer_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_installer_test/BUILD.gn index 7484fe2db..29741f72d 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_installer_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_installer_test/BUILD.gn @@ -205,6 +205,11 @@ ohos_unittest("BmsBundleInstallerTest") { ] defines += [ "APP_DOMAIN_VERIFY_ENABLED" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsBundleOtaUpdateTest") { @@ -379,6 +384,11 @@ ohos_unittest("BmsBundleOtaUpdateTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsMultipleBundleInstallerTest") { @@ -562,6 +572,11 @@ ohos_unittest("BmsMultipleBundleInstallerTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsBundleInstallIpcTest") { @@ -717,6 +732,11 @@ ohos_unittest("BmsBundleInstallIpcTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsBundleInstallCheckerTest") { @@ -853,6 +873,11 @@ ohos_unittest("BmsBundleInstallCheckerTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsBundleInstallDeviceTypeTest") { @@ -989,6 +1014,11 @@ ohos_unittest("BmsBundleInstallDeviceTypeTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsSystemBundleInstallerTest") { @@ -1129,6 +1159,11 @@ ohos_unittest("BmsSystemBundleInstallerTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsBundleInstallDriverTest") { @@ -1313,6 +1348,11 @@ ohos_unittest("BmsBundleInstallDriverTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsBundleAppServiceFwkInstallerTest") { @@ -1480,6 +1520,11 @@ ohos_unittest("BmsBundleAppServiceFwkInstallerTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_bundle_installer_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_bundle_installer_test.cpp index e943ab9ac..435fc8a99 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_bundle_installer_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_bundle_installer_test.cpp @@ -4631,7 +4631,8 @@ HWTEST_F(BmsBundleInstallerTest, ExecuteAOT_0100, Function | SmallTest | Level0) { InstalldHostImpl impl; AOTArgs aotArgs; - auto ret = impl.ExecuteAOT(aotArgs); + std::vector pendSignData; + auto ret = impl.ExecuteAOT(aotArgs, pendSignData); EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALLD_PARAM_ERROR); } diff --git a/services/bundlemgr/test/unittest/bms_bundle_installers_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_installers_test/BUILD.gn index 3920ab64c..af7272def 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_installers_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_installers_test/BUILD.gn @@ -173,6 +173,11 @@ ohos_unittest("BmsBundleInstallersTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_kit_service_base_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_kit_service_base_test/BUILD.gn index b7850ce43..78dbe5b55 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_kit_service_base_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_kit_service_base_test/BUILD.gn @@ -169,6 +169,11 @@ ohos_unittest("BmsBundleKitServiceBaseTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/BUILD.gn index b4f67ce98..d8446ec91 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/BUILD.gn @@ -182,6 +182,11 @@ ohos_unittest("BmsBundleDataMgrTest") { ] defines += [ "APP_DOMAIN_VERIFY_ENABLED" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsBundleKitServiceTest") { @@ -343,6 +348,11 @@ ohos_unittest("BmsBundleKitServiceTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsBundleGetWindowPropertiesTest") { @@ -500,6 +510,11 @@ ohos_unittest("BmsBundleGetWindowPropertiesTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_manager_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_manager_test/BUILD.gn index bd8982a1b..26145c105 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_manager_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_manager_test/BUILD.gn @@ -171,6 +171,11 @@ ohos_unittest("BmsBundleManagerTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_navigation_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_navigation_test/BUILD.gn index 85d20dabc..059729bd0 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_navigation_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_navigation_test/BUILD.gn @@ -162,6 +162,10 @@ ohos_unittest("BmsBundleNavigationTest") { defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ] external_deps += [ "udmf:udmf_client" ] } + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_overlay_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_overlay_test/BUILD.gn index f9392ef0e..8127ecdd3 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_overlay_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_overlay_test/BUILD.gn @@ -142,6 +142,10 @@ ohos_unittest("BmsBundleOverlayCheckerTest") { defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ] external_deps += [ "udmf:udmf_client" ] } + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsBundleOverlayInfoTest") { @@ -344,6 +348,10 @@ ohos_unittest("BmsBundleOverlayIpcTest") { defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ] external_deps += [ "udmf:udmf_client" ] } + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsBundleManagerOverlayIpcTest") { @@ -470,6 +478,10 @@ ohos_unittest("BmsBundleManagerOverlayIpcTest") { defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ] external_deps += [ "udmf:udmf_client" ] } + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsBundleSetOverlayEnabledTest") { @@ -598,6 +610,10 @@ ohos_unittest("BmsBundleSetOverlayEnabledTest") { defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ] external_deps += [ "udmf:udmf_client" ] } + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsBundleGetOverlayModuleInfoTest") { @@ -726,6 +742,10 @@ ohos_unittest("BmsBundleGetOverlayModuleInfoTest") { defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ] external_deps += [ "udmf:udmf_client" ] } + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/BUILD.gn index c811e7b0d..11e042ed4 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/BUILD.gn @@ -181,6 +181,11 @@ ohos_unittest("BmsBundlePermissionDefListTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsBundlePermissionGrantTest") { @@ -346,6 +351,11 @@ ohos_unittest("BmsBundlePermissionGrantTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsBundlePermissionFalseTest") { @@ -517,6 +527,11 @@ ohos_unittest("BmsBundlePermissionFalseTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsBundlePermissionStartFullTest") { @@ -687,6 +702,11 @@ ohos_unittest("BmsBundlePermissionStartFullTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsBundlePermissionSyetemAppFalseTest") { @@ -858,6 +878,11 @@ ohos_unittest("BmsBundlePermissionSyetemAppFalseTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsBundlePermissionTokenTest") { @@ -1024,6 +1049,11 @@ ohos_unittest("BmsBundlePermissionTokenTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsBundlePermissionGetRequestTest") { @@ -1187,6 +1217,11 @@ ohos_unittest("BmsBundlePermissionGetRequestTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_boot_scanner_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_boot_scanner_test/BUILD.gn index 512960a5d..a17a83c6f 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_boot_scanner_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_boot_scanner_test/BUILD.gn @@ -172,6 +172,11 @@ ohos_unittest("BmsBundleQuickFixBootScannerTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_deleter_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_deleter_test/BUILD.gn index 8298b254e..a73fc72de 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_deleter_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_deleter_test/BUILD.gn @@ -174,6 +174,11 @@ ohos_unittest("BmsBundleQuickFixDeleterTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_manager_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_manager_test/BUILD.gn index ffbcd94d1..1fd6e6521 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_manager_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_manager_test/BUILD.gn @@ -173,6 +173,11 @@ ohos_unittest("BmsBundleQuickFixManagerTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_mgr_rdb_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_mgr_rdb_test/BUILD.gn index fd456c60d..c361111e4 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_mgr_rdb_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_mgr_rdb_test/BUILD.gn @@ -181,6 +181,11 @@ ohos_unittest("BmsBundleQuickFixMgrRdbTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_query_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_query_test/BUILD.gn index 3ad911c7b..c7bbf94c3 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_query_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_query_test/BUILD.gn @@ -153,6 +153,11 @@ ohos_unittest("BmsBundleQuickFixQueryTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_switcher_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_switcher_test/BUILD.gn index 980ccfb8c..0197645bd 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_switcher_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_switcher_test/BUILD.gn @@ -175,6 +175,11 @@ ohos_unittest("BmsBundleQuickFixSwitcherTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/BUILD.gn index a0652bb9d..d50085179 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/BUILD.gn @@ -176,6 +176,11 @@ ohos_unittest("BmsBundleQuickFixTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_resource_manager_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_resource_manager_test/BUILD.gn index 30ea9c272..9d5a4ea80 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_resource_manager_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_resource_manager_test/BUILD.gn @@ -173,6 +173,11 @@ ohos_unittest("BmsBundleResourceManagerTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_resource_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_resource_test/BUILD.gn index 52992a210..05621076b 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_resource_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_resource_test/BUILD.gn @@ -197,6 +197,11 @@ ohos_unittest("BmsBundleResourceTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_sandbox_app_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_sandbox_app_test/BUILD.gn index 1cc96d65f..ba2263182 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_sandbox_app_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_sandbox_app_test/BUILD.gn @@ -174,6 +174,11 @@ ohos_unittest("BmsSandboxAppTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsSandboxRdbTest") { @@ -333,6 +338,11 @@ ohos_unittest("BmsSandboxRdbTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/BUILD.gn index 1fb86f507..e0ea3c689 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/BUILD.gn @@ -183,6 +183,11 @@ ohos_unittest("BmsBundleUninstallerTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_updater_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_updater_test/BUILD.gn index f780cdf45..9a219dadd 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_updater_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_updater_test/BUILD.gn @@ -186,6 +186,11 @@ ohos_unittest("BmsBundleUpdaterTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_bundle_verifymanager_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_verifymanager_test/BUILD.gn index eb4752b4f..1ac64d065 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_verifymanager_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_verifymanager_test/BUILD.gn @@ -167,6 +167,11 @@ ohos_unittest("BmsBundleVerifyManagerTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_data_mgr_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_data_mgr_test/BUILD.gn index 6b1b0d0ac..65156e04c 100644 --- a/services/bundlemgr/test/unittest/bms_data_mgr_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_data_mgr_test/BUILD.gn @@ -143,6 +143,11 @@ ohos_unittest("BmsDataMgrTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsExtensionDataMgrTest") { @@ -275,6 +280,11 @@ ohos_unittest("BmsExtensionDataMgrTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_event_handler_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_event_handler_test/BUILD.gn index 7af02357b..5cf724351 100644 --- a/services/bundlemgr/test/unittest/bms_event_handler_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_event_handler_test/BUILD.gn @@ -124,6 +124,11 @@ ohos_unittest("BmsEventHandlerTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsEventHandlerUnLockedTest") { @@ -228,6 +233,11 @@ ohos_unittest("BmsEventHandlerUnLockedTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_extend_resource_manager_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_extend_resource_manager_test/BUILD.gn index 51d80735e..cca1f3889 100644 --- a/services/bundlemgr/test/unittest/bms_extend_resource_manager_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_extend_resource_manager_test/BUILD.gn @@ -168,6 +168,10 @@ ohos_unittest("BmsExtendResourceManagerTest") { defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ] external_deps += [ "udmf:udmf_client" ] } + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_install_daemon_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_install_daemon_test/BUILD.gn index 2036cc8be..8ea22295d 100644 --- a/services/bundlemgr/test/unittest/bms_install_daemon_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_install_daemon_test/BUILD.gn @@ -169,6 +169,10 @@ ohos_unittest("BmsInstallDaemonIpcTest") { defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ] external_deps += [ "udmf:udmf_client" ] } + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsInstallDaemonHostImplTest") { @@ -252,6 +256,10 @@ ohos_unittest("BmsInstallDaemonHostImplTest") { defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ] external_deps += [ "udmf:udmf_client" ] } + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } ohos_unittest("BmsInstallDaemonOperatorTest") { diff --git a/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_host_impl_test.cpp b/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_host_impl_test.cpp index c16a2bb33..c3ff55ae5 100755 --- a/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_host_impl_test.cpp +++ b/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_host_impl_test.cpp @@ -810,7 +810,8 @@ HWTEST_F(BmsInstallDaemonHostImplTest, InstalldHostImplTest_4500, Function | Sma { InstalldHostImpl impl; AOTArgs aotArgs; - auto ret = impl.ExecuteAOT(aotArgs); + std::vector pendSignData; + auto ret = impl.ExecuteAOT(aotArgs, pendSignData); EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALLD_PERMISSION_DENIED); } diff --git a/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_ipc_test.cpp b/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_ipc_test.cpp index bc15b4019..618c259f7 100755 --- a/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_ipc_test.cpp +++ b/services/bundlemgr/test/unittest/bms_install_daemon_test/bms_install_daemon_ipc_test.cpp @@ -590,7 +590,8 @@ HWTEST_F(BmsInstallDaemonIpcTest, InstalldProxyTest_2700, Function | SmallTest | EXPECT_NE(installdProxy, nullptr); AOTArgs aotArgs; - auto ret = installdProxy->ExecuteAOT(aotArgs); + std::vector pendSignData; + auto ret = installdProxy->ExecuteAOT(aotArgs, pendSignData); EXPECT_EQ(ret, ERR_APPEXECFWK_INSTALL_INSTALLD_SERVICE_ERROR); } diff --git a/services/bundlemgr/test/unittest/bms_installd_host_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_installd_host_test/BUILD.gn index e709fb46a..84b767322 100644 --- a/services/bundlemgr/test/unittest/bms_installd_host_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_installd_host_test/BUILD.gn @@ -165,6 +165,11 @@ ohos_unittest("BmsInstalldHostTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_rdb_data_manager_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_rdb_data_manager_test/BUILD.gn index d6ed81783..2db158e37 100755 --- a/services/bundlemgr/test/unittest/bms_rdb_data_manager_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_rdb_data_manager_test/BUILD.gn @@ -157,6 +157,11 @@ ohos_unittest("BmsRdbDataManagerTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_service_bundle_scan_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_service_bundle_scan_test/BUILD.gn index 69fdff4f8..497544922 100644 --- a/services/bundlemgr/test/unittest/bms_service_bundle_scan_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_service_bundle_scan_test/BUILD.gn @@ -139,6 +139,11 @@ ohos_unittest("BmsServiceBundleScanTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_service_startup_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_service_startup_test/BUILD.gn index 0b100e5f5..5be5d6b8c 100644 --- a/services/bundlemgr/test/unittest/bms_service_startup_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_service_startup_test/BUILD.gn @@ -136,6 +136,11 @@ ohos_unittest("BmsServiceStartupTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/services/bundlemgr/test/unittest/bms_syscap_tool_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_syscap_tool_test/BUILD.gn index 2887ad06c..07300e8bc 100755 --- a/services/bundlemgr/test/unittest/bms_syscap_tool_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_syscap_tool_test/BUILD.gn @@ -163,6 +163,11 @@ ohos_unittest("BmsSyscapToolTest") { ] defines += [ "BMS_DEVICE_INFO_MANAGER_ENABLE" ] } + + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } } group("unittest") { diff --git a/test/fuzztest/fuzztest_application/bundleinstalldhost_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_application/bundleinstalldhost_fuzzer/BUILD.gn index 5ae2aa3da..60160bf7a 100644 --- a/test/fuzztest/fuzztest_application/bundleinstalldhost_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_application/bundleinstalldhost_fuzzer/BUILD.gn @@ -135,6 +135,10 @@ ohos_fuzztest("BundleInstalldHostFuzzTest") { defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ] external_deps += [ "udmf:udmf_client" ] } + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } sources += [ "bundleinstalldhost_fuzzer.cpp" ] } diff --git a/test/fuzztest/fuzztest_application/bundleinstallerhost_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_application/bundleinstallerhost_fuzzer/BUILD.gn index 4905f39fd..2f8ea48ce 100644 --- a/test/fuzztest/fuzztest_application/bundleinstallerhost_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_application/bundleinstallerhost_fuzzer/BUILD.gn @@ -135,6 +135,10 @@ ohos_fuzztest("BundleInstallerHostFuzzTest") { defines += [ "BUNDLE_FRAMEWORK_UDMF_ENABLED" ] external_deps += [ "udmf:udmf_client" ] } + if (code_signature_enable && pend_sign_screenlock_mgr_enable) { + defines += [ "PEND_SIGN_SCREENLOCK_MGR_ENABLED" ] + external_deps += [ "screenlock_mgr:screenlock_client" ] + } sources += [ "bundleinstallerhost_fuzzer.cpp" ] } From 8b6a91b491d2d2fc5aff07d847b2924fea713400 Mon Sep 17 00:00:00 2001 From: sunxuhui Date: Thu, 6 Jun 2024 10:32:02 +0800 Subject: [PATCH 21/23] update gn Signed-off-by: sunxuhui --- .../bmsextensionclient_fuzzer/BUILD.gn | 21 ++++++++++++++++++- .../bmsextensionclient_fuzzer.cpp | 2 +- .../bundlecloneinstaller_fuzzer.cpp | 4 ++++ .../driverinstaller_fuzzer/BUILD.gn | 20 ++++++++++++++++-- 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/BUILD.gn index dee73bd36..f4cfba8b7 100644 --- a/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/BUILD.gn @@ -44,7 +44,12 @@ ohos_fuzztest("BmsExtensionClientFuzzTest") { if (target_cpu == "arm") { cflags += [ "-DBINDER_IPC_32BIT" ] } - deps = bundle_install_deps + deps = [ + "${base_path}:appexecfwk_base", + "${common_path}:libappexecfwk_common", + "${core_path}:appexecfwk_core", + ] + deps += bundle_install_deps external_deps = [ "ability_base:want", @@ -68,6 +73,16 @@ ohos_fuzztest("BmsExtensionClientFuzzTest") { defines = [] + if (code_signature_enable) { + sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ] + include_dirs += [ "${services_path}/bundlemgr/include" ] + external_deps += [ + "code_signature:libcode_sign_utils", + "ets_runtime:libcompiler_service", + ] + defines += [ "CODE_SIGNATURE_ENABLE" ] + } + if (configpolicy_enable) { external_deps += [ "config_policy:configpolicy_util" ] defines += [ "CONFIG_POLOCY_ENABLE" ] @@ -86,6 +101,10 @@ ohos_fuzztest("BmsExtensionClientFuzzTest") { external_deps += [ "c_utils:utils" ] } + if (current_cpu == "arm64") { + defines += [ "USE_BUNDLE_EXTENSION" ] + } + if (build_selinux) { external_deps += [ "selinux_adapter:libhap_restorecon" ] cflags += [ "-DWITH_SELINUX" ] diff --git a/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.cpp b/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.cpp index 530a32fe7..4ef6b8954 100644 --- a/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.cpp +++ b/test/fuzztest/fuzztest_others/bmsextensionclient_fuzzer/bmsextensionclient_fuzzer.cpp @@ -61,7 +61,7 @@ constexpr uint8_t ENABLE = 2; bmsExtensionClient.GetBundleStats(bundleName, reinterpret_cast(data), bundleStats); bmsExtensionClient.ClearCache(bundleName, callback, reinterpret_cast(data)); bmsExtensionClient.ClearData(bundleName, reinterpret_cast(data)); - int32_t uid = reinterpret_cast(data); + int32_t uid = 3024; bmsExtensionClient.GetUidByBundleName(bundleName, reinterpret_cast(data), uid); bmsExtensionClient.GetBundleNameByUid(reinterpret_cast(data), bundleName); diff --git a/test/fuzztest/fuzztest_others/bundlecloneinstaller_fuzzer/bundlecloneinstaller_fuzzer.cpp b/test/fuzztest/fuzztest_others/bundlecloneinstaller_fuzzer/bundlecloneinstaller_fuzzer.cpp index e52086365..9a373dc3b 100644 --- a/test/fuzztest/fuzztest_others/bundlecloneinstaller_fuzzer/bundlecloneinstaller_fuzzer.cpp +++ b/test/fuzztest/fuzztest_others/bundlecloneinstaller_fuzzer/bundlecloneinstaller_fuzzer.cpp @@ -37,6 +37,7 @@ namespace OHOS { constexpr size_t OFFSET_ZERO = 24; constexpr size_t OFFSET_ONE = 16; constexpr size_t OFFSET_TWO = 8; + constexpr int32_t UID = 3024; } void SetBundleDataMgr() @@ -56,12 +57,15 @@ namespace OHOS { BundleCloneInstaller bundleCloneInstall; std::string bundleName(data, size); + InnerBundleInfo info; int32_t userId = static_cast(GetU32Data(data)); int32_t appIndex = static_cast(GetU32Data(data)); SetBundleDataMgr(); bundleCloneInstall.InstallCloneApp(bundleName, userId, appIndex); bundleCloneInstall.UninstallCloneApp(bundleName, userId, appIndex); bundleCloneInstall.UninstallAllCloneApps(bundleName, userId); + bundleCloneInstall.CreateCloneDataDir(info, userId, UID, appIndex); + bundleCloneInstall.RemoveCloneDataDir(bundleName, userId, appIndex); return true; } } diff --git a/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/BUILD.gn index 7b39f021a..76a90f439 100644 --- a/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_others/driverinstaller_fuzzer/BUILD.gn @@ -43,7 +43,12 @@ ohos_fuzztest("DriverInstallerFuzzTest") { if (target_cpu == "arm") { cflags += [ "-DBINDER_IPC_32BIT" ] } - deps = bundle_install_deps + deps = [ + "${base_path}:appexecfwk_base", + "${common_path}:libappexecfwk_common", + "${core_path}:appexecfwk_core", + ] + deps += bundle_install_deps external_deps = [ "ability_base:want", @@ -66,7 +71,15 @@ ohos_fuzztest("DriverInstallerFuzzTest") { external_deps += bundle_install_external_deps defines = [] - + if (code_signature_enable) { + sources += [ "${services_path}/bundlemgr/src/code_sign_helper.cpp" ] + include_dirs += [ "${services_path}/bundlemgr/include" ] + external_deps += [ + "code_signature:libcode_sign_utils", + "ets_runtime:libcompiler_service", + ] + defines += [ "CODE_SIGNATURE_ENABLE" ] + } if (configpolicy_enable) { external_deps += [ "config_policy:configpolicy_util" ] defines += [ "CONFIG_POLOCY_ENABLE" ] @@ -85,6 +98,9 @@ ohos_fuzztest("DriverInstallerFuzzTest") { external_deps += [ "c_utils:utils" ] } + if (current_cpu == "arm64") { + defines += [ "USE_BUNDLE_EXTENSION" ] + } if (build_selinux) { external_deps += [ "selinux_adapter:libhap_restorecon" ] cflags += [ "-DWITH_SELINUX" ] From 8089d0355a86e22ff8b97b2ff85a773b01f30cb4 Mon Sep 17 00:00:00 2001 From: atreeof_wind Date: Thu, 6 Jun 2024 16:19:15 +0800 Subject: [PATCH 22/23] bm fix Signed-off-by: atreeof_wind --- interfaces/kits/cj/src/bundle_manager_convert.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/interfaces/kits/cj/src/bundle_manager_convert.cpp b/interfaces/kits/cj/src/bundle_manager_convert.cpp index 9a04aebf0..dec03e7ba 100755 --- a/interfaces/kits/cj/src/bundle_manager_convert.cpp +++ b/interfaces/kits/cj/src/bundle_manager_convert.cpp @@ -101,7 +101,6 @@ CArrMetadata ConvertArrMetadata(std::vector cdata) } } else { LOGE("ConvertArrMetadata malloc failed"); - data.head = nullptr; return data; } return data; @@ -122,7 +121,6 @@ CArrMoMeta ConvertArrMoMeta(std::map ab abInfo.head = retValue; } else { LOGE("ConvertArrAbilityInfo malloc failed"); - abInfo.head = nullptr; return abInfo; } } @@ -371,7 +368,7 @@ RetHapModuleInfo ConvertHapModuleInfo(AppExecFwk::HapModuleInfo hapModuleInfo) if (!hapModuleInfo.fileContextMenu.empty()) { hapInfo.fileContextMenuConfig = MallocCString(hapModuleInfo.fileContextMenu); } else { - hapInfo.fileContextMenuConfig = nullptr; + hapInfo.fileContextMenuConfig = MallocCString(""); } return hapInfo; } From 09479507a446d3146cbe4c7cdaaa8121e0710123 Mon Sep 17 00:00:00 2001 From: chenwei Date: Mon, 3 Jun 2024 16:43:51 +0800 Subject: [PATCH 23/23] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E5=88=86=E8=BA=AB?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=A6=82=E6=9E=9CappIndex=E5=8F=82=E6=95=B0?= =?UTF-8?q?=E7=BB=990=EF=BC=8C=E5=BA=94=E8=AF=A5=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenwei --- .../src/bundlemgr/bundle_mgr_proxy.cpp | 4 +-- .../kits/js/bundle_manager/bundle_manager.cpp | 30 ++++++++++--------- interfaces/kits/js/installer/installer.cpp | 12 ++++++-- services/bundlemgr/src/bundle_data_mgr.cpp | 5 +++- .../acts_bms_kit_system_test.cpp | 1 + 5 files changed, 32 insertions(+), 20 deletions(-) diff --git a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp index 5d8f8d7ea..4ff35d38f 100644 --- a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp +++ b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp @@ -4931,7 +4931,7 @@ ErrCode BundleMgrProxy::QueryCloneAbilityInfo(const ElementName &element, } if (!data.WriteParcelable(&element)) { LOG_E(BMS_TAG_QUERY_ABILITY, "write element fail"); - return false; + return ERR_APPEXECFWK_PARCEL_ERROR; } if (!data.WriteInt32(flags)) { LOG_E(BMS_TAG_QUERY_ABILITY, "write flags failed"); @@ -4957,7 +4957,7 @@ ErrCode BundleMgrProxy::GetCloneBundleInfo(const std::string &bundleName, int32_ MessageParcel data; if (!data.WriteInterfaceToken(GetDescriptor())) { APP_LOGE("fail to GetCloneBundleInfo due to write InterfaceToken fail"); - return false; + return ERR_APPEXECFWK_PARCEL_ERROR; } if (!data.WriteString(bundleName)) { APP_LOGE("failed to GetCloneBundleInfo due to write bundleName fail"); diff --git a/interfaces/kits/js/bundle_manager/bundle_manager.cpp b/interfaces/kits/js/bundle_manager/bundle_manager.cpp index 714194fe8..700bb0ab4 100644 --- a/interfaces/kits/js/bundle_manager/bundle_manager.cpp +++ b/interfaces/kits/js/bundle_manager/bundle_manager.cpp @@ -5115,7 +5115,7 @@ static ErrCode InnerGetAppCloneBundleInfo(const std::string &bundleName, int32_t APP_LOGE("can not get iBundleMgr"); return ERROR_BUNDLE_SERVICE_EXCEPTION; } - ErrCode ret = iBundleMgr->GetCloneBundleInfo(bundleName, bundleFlags, appIndex, bundleInfo); + ErrCode ret = iBundleMgr->GetCloneBundleInfo(bundleName, bundleFlags, appIndex, bundleInfo, userId); APP_LOGD("GetCloneBundleInfo result is %{public}d", ret); return CommonFunc::ConvertErrCode(ret); } @@ -5150,7 +5150,8 @@ void GetAppCloneBundleInfoComplete(napi_env env, napi_status status, void *data) if (asyncCallbackInfo->err == NO_ERROR) { NAPI_CALL_RETURN_VOID(env, napi_get_null(env, &result[ARGS_POS_ZERO])); NAPI_CALL_RETURN_VOID(env, napi_create_object(env, &result[ARGS_POS_ONE])); - CommonFunc::ConvertBundleInfo(env, asyncCallbackInfo->bundleInfo, result[ARGS_POS_ONE], true); + CommonFunc::ConvertBundleInfo(env, asyncCallbackInfo->bundleInfo, result[ARGS_POS_ONE], + asyncCallbackInfo->bundleFlags); } else { result[ARGS_POS_ZERO] = BusinessError::CreateCommonError(env, asyncCallbackInfo->err, GET_APP_CLONE_BUNDLE_INFO, Constants::PERMISSION_GET_BUNDLE_INFO); @@ -5209,27 +5210,29 @@ static ErrCode InnerGetAllAppCloneBundleInfo(const std::string &bundleName, int3 } BundleInfo bundleInfoMain; ErrCode ret = iBundleMgr->GetCloneBundleInfo(bundleName, bundleFlags, 0, bundleInfoMain, userId); - APP_LOGD("InnerGetAllAppCloneBundleInfo: GetMainBundleInfo ret=%{public}d", ret); - if (ret != NO_ERROR) { + APP_LOGD("GetMainBundleInfo appIndex = 0, ret=%{public}d", ret); + if (ret == ERR_OK) { + bundleInfos.emplace_back(bundleInfoMain); + } + if (ret != ERR_OK && ret != ERR_BUNDLE_MANAGER_APPLICATION_DISABLED) { return CommonFunc::ConvertErrCode(ret); } - bundleInfos.emplace_back(bundleInfoMain); // handle clone apps std::vector appIndexes; ret = iBundleMgr->GetCloneAppIndexes(bundleName, appIndexes, userId); - if (ret != NO_ERROR) { + if (ret != ERR_OK) { return CommonFunc::ConvertErrCode(ret); } - if (appIndexes.empty()) { - return SUCCESS; - } for (int32_t appIndex : appIndexes) { BundleInfo bundleInfo; ret = iBundleMgr->GetCloneBundleInfo(bundleName, bundleFlags, appIndex, bundleInfo, userId); - if (ret == NO_ERROR) { + if (ret == ERR_OK) { bundleInfos.emplace_back(bundleInfo); } } + if (bundleInfos.empty()) { + return ERROR_BUNDLE_IS_DISABLED; + } return SUCCESS; } @@ -5251,7 +5254,7 @@ void GetAllAppCloneBundleInfoExec(napi_env env, void *data) } static void CloneAppBundleInfos( - napi_env env, napi_value result, const std::vector &bundleInfos) + napi_env env, napi_value result, const std::vector &bundleInfos, int32_t flags) { if (bundleInfos.size() == 0) { APP_LOGD("bundleInfos is null"); @@ -5259,10 +5262,9 @@ static void CloneAppBundleInfos( } size_t index = 0; for (const auto &item : bundleInfos) { - APP_LOGD("name: %{public}s ", item.name.c_str()); napi_value objBundleInfo; NAPI_CALL_RETURN_VOID(env, napi_create_object(env, &objBundleInfo)); - CommonFunc::ConvertBundleInfo(env, item, objBundleInfo, true); + CommonFunc::ConvertBundleInfo(env, item, objBundleInfo, flags); NAPI_CALL_RETURN_VOID(env, napi_set_element(env, result, index++, objBundleInfo)); } } @@ -5279,7 +5281,7 @@ void GetAllAppCloneBundleInfoComplete(napi_env env, napi_status status, void *da if (asyncCallbackInfo->err == NO_ERROR) { NAPI_CALL_RETURN_VOID(env, napi_get_null(env, &result[ARGS_POS_ZERO])); NAPI_CALL_RETURN_VOID(env, napi_create_array(env, &result[ARGS_POS_ONE])); - CloneAppBundleInfos(env, result[ARGS_POS_ONE], asyncCallbackInfo->bundleInfos); + CloneAppBundleInfos(env, result[ARGS_POS_ONE], asyncCallbackInfo->bundleInfos, asyncCallbackInfo->bundleFlags); } else { result[ARGS_POS_ZERO] = BusinessError::CreateCommonError(env, asyncCallbackInfo->err, GET_ALL_APP_CLONE_BUNDLE_INFO, Constants::PERMISSION_GET_BUNDLE_INFO); diff --git a/interfaces/kits/js/installer/installer.cpp b/interfaces/kits/js/installer/installer.cpp index 3b48d49ce..361a75c5b 100644 --- a/interfaces/kits/js/installer/installer.cpp +++ b/interfaces/kits/js/installer/installer.cpp @@ -88,6 +88,7 @@ constexpr int32_t SECOND_PARAM = 1; constexpr int32_t SPECIFIED_DISTRIBUTION_TYPE_MAX_SIZE = 128; constexpr int32_t ADDITIONAL_INFO_MAX_SIZE = 3000; +constexpr int32_t ILLEGAL_APP_INDEX = -1; } // namespace napi_ref thread_local g_classBundleInstaller; bool g_isSystemApp = false; @@ -663,7 +664,7 @@ static bool ParseAppIndex(napi_env env, napi_value args, int32_t &appIndex) APP_LOGD("start to parse appIndex"); PropertyInfo propertyInfo = { .propertyName = APP_INDEX, - .isNecessary = false, + .isNecessary = true, .propertyType = napi_number }; napi_value property = nullptr; @@ -1643,7 +1644,12 @@ void ParseAppCloneParam(napi_env env, napi_value args, int32_t &userId, int32_t if (!ParseUserId(env, args, userId)) { APP_LOGI("parse userId failed. assign a default value = %{public}d.", userId); } - if (!ParseAppIndex(env, args, appIndex)) { + if (ParseAppIndex(env, args, appIndex)) { + if (appIndex == 0) { + APP_LOGI("parse appIndex success, but appIndex is 0, assign a value: %{public}d.", ILLEGAL_APP_INDEX); + appIndex = ILLEGAL_APP_INDEX; + } + } else { APP_LOGI("parse appIndex failed. assign a default value = %{public}d.", appIndex); } } @@ -1677,7 +1683,7 @@ napi_value CreateAppClone(napi_env env, napi_callback_info info) ParseAppCloneParam(env, args[i], asyncCallbackInfo->userId, asyncCallbackInfo->appIndex); } } else { - APP_LOGE("The number of parameters is incorrect."); + APP_LOGW("The number of parameters is incorrect."); BusinessError::ThrowTooFewParametersError(env, ERROR_PARAM_CHECK_ERROR); return nullptr; } diff --git a/services/bundlemgr/src/bundle_data_mgr.cpp b/services/bundlemgr/src/bundle_data_mgr.cpp index 753afda87..fb9e3ec1b 100644 --- a/services/bundlemgr/src/bundle_data_mgr.cpp +++ b/services/bundlemgr/src/bundle_data_mgr.cpp @@ -738,9 +738,12 @@ ErrCode BundleDataMgr::QueryAbilityInfosV9( return ERR_OK; } // implicit query - (void)ImplicitQueryAbilityInfosV9(want, flags, requestUserId, abilityInfos); + ErrCode ret = ImplicitQueryAbilityInfosV9(want, flags, requestUserId, abilityInfos); ImplicitQueryCloneAbilityInfosV9(want, flags, requestUserId, abilityInfos); if (abilityInfos.empty()) { + if (ret != ERR_OK) { + return ret; + } LOG_W(BMS_TAG_QUERY_ABILITY, "no matching abilityInfo action:%{public}s uri:%{private}s type:%{public}s", want.GetAction().c_str(), want.GetUriString().c_str(), want.GetType().c_str()); return ERR_BUNDLE_MANAGER_ABILITY_NOT_EXIST; diff --git a/test/systemtest/common/bms/acts_bms_kit_system_test/acts_bms_kit_system_test.cpp b/test/systemtest/common/bms/acts_bms_kit_system_test/acts_bms_kit_system_test.cpp index 3eb4a0d7e..2d11448df 100644 --- a/test/systemtest/common/bms/acts_bms_kit_system_test/acts_bms_kit_system_test.cpp +++ b/test/systemtest/common/bms/acts_bms_kit_system_test/acts_bms_kit_system_test.cpp @@ -6614,6 +6614,7 @@ HWTEST_F(ActsBmsKitSystemTest, UninstallAndRecover_0200, Function | MediumTest | HWTEST_F(ActsBmsKitSystemTest, InstallCloneApp_0100, Function | MediumTest | Level1) { sptr installerProxy = GetInstallerProxy(); + ASSERT_NE(installerProxy, nullptr); std::string bundleName = ""; int32_t appIndex = TEST_APP_INDEX1; ErrCode ret = installerProxy->InstallCloneApp(bundleName, TEST_INSTALLER_UID, appIndex);