diff --git a/interfaces/innerkits/code_sign_utils/src/code_sign_utils.cpp b/interfaces/innerkits/code_sign_utils/src/code_sign_utils.cpp index 762526473d86e93c47ac414ff77902249660947a..dc16c1ab8a4be4ed190972e002d06a7e5482e7a6 100644 --- a/interfaces/innerkits/code_sign_utils/src/code_sign_utils.cpp +++ b/interfaces/innerkits/code_sign_utils/src/code_sign_utils.cpp @@ -231,13 +231,14 @@ void CodeSignUtils::ShowCodeSignInfo(const std::string &path, const struct code_ int32_t CodeSignUtils::EnforceCodeSignForAppWithOwnerId(const std::string &ownerId, const std::string &path, const EntryMap &entryPathMap, FileType type) { - if (type == FILE_ENTRY_ADD || type == FILE_ALL) { + if (type == FILE_ENTRY_ADD || type == FILE_ENTRY_ONLY || type == FILE_ALL) { + if (type == FILE_ENTRY_ONLY && !isSupportOHCodeSign()) { + return CS_SUCCESS; + } storedEntryMap_.insert(entryPathMap.begin(), entryPathMap.end()); if (type == FILE_ENTRY_ADD) { return CS_SUCCESS; } - } else if (type == FILE_ENTRY_ONLY) { - return CS_SUCCESS; } std::string realPath; int32_t ret = IsValidPathAndFileType(path, realPath, type); diff --git a/test/unittest/code_sign_utils_test.cpp b/test/unittest/code_sign_utils_test.cpp index be9b131bfd1407a95612840620025d9d69d14529..50593c4d9b6c8f6b64deb219dab4cd16644fa23a 100644 --- a/test/unittest/code_sign_utils_test.cpp +++ b/test/unittest/code_sign_utils_test.cpp @@ -465,7 +465,7 @@ HWTEST_F(CodeSignUtilsTest, CodeSignUtilsTest_0016, TestSize.Level0) std::string targetPath2 = TEST_APP_DTAT_DIR + "libs/arm64/libentry.so"; entryMap.emplace(filePath2, targetPath2); - ret = utils.EnforceCodeSignForApp(hapRealPath, entryMap, FILE_ENTRY_ONLY); + ret = utils.EnforceCodeSignForApp(hapRealPath, entryMap, FILE_ENTRY_ADD); EXPECT_EQ(ret, CS_SUCCESS); ret = utils.EnforceCodeSignForApp(hapRealPath, entryMap, FILE_ALL);