From 0c6612485db7abb60ec666d7e92c95a37344748b Mon Sep 17 00:00:00 2001 From: z30034863 Date: Tue, 20 May 2025 11:47:12 +0800 Subject: [PATCH] fix pac.json doc Signed-off-by: z30034863 --- README_zh.md | 2 +- .../frameworks/include/json/module_json_utils.h | 6 ++++-- .../frameworks/src/json/module_json_utils.cpp | 14 +++++++++----- .../mock/mock_module_json_utils.cpp | 2 +- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/README_zh.md b/README_zh.md index d820b86f..baad5d92 100644 --- a/README_zh.md +++ b/README_zh.md @@ -124,7 +124,7 @@ java -jar app_packing_tool.jar --mode multiApp --hap-list <1.hap,2.hap> --hsp-li | --out-path | 是 | NA | 目标文件路径,文件名必须以.app为后缀。 | | --force | 否 | 默认值为false | 默认值为false,如果为true,表示当目标文件存在时,强制删除。 | | --encrypt-path | 否 | encrypt.json的路径 | 文件名必须为encrypt.json。 | -| --pac-json-path | 否 | NA | 文件名必须为pac.json。 | +| --pac-json-path | 否 | NA | 文件名必须为pac.json。最终app产物中pac.json文件只来源于该参数,不配置的话,最终app产物不包含该文件。--app-list参数指定的app包中的pac.json不会打包进最终app。 | #### 1.4.3 多工程打包hap合法性校验 diff --git a/packing_tool/frameworks/include/json/module_json_utils.h b/packing_tool/frameworks/include/json/module_json_utils.h index 5e844e24..6f0209f5 100644 --- a/packing_tool/frameworks/include/json/module_json_utils.h +++ b/packing_tool/frameworks/include/json/module_json_utils.h @@ -34,8 +34,10 @@ public: static bool GetFaHapVerifyInfo(const std::string& hapFilePath, HapVerifyInfo& hapVerifyInfo); static bool CheckHapsIsValid(const std::list& fileList, const bool& isSharedApp); static bool IsModuleHap(const std::string hapFilePath); - static bool GetHapVerifyInfosMapfromFileList(const std::list& fileList, std::map>& hapVerifyInfoMap); - static bool CheckAppAtomicServiceCompressedSizeValid(std::map parameterMap, std::map>& hapVerifyInfoMap); + static bool GetHapVerifyInfosMapfromFileList(const std::list& fileList, + std::map>& hapVerifyInfoMap); + static bool CheckAppAtomicServiceCompressedSizeValid(std::map parameterMap, std::map>& hapVerifyInfoMap); private: static bool CheckSharedAppIsValid(const std::list& hapVerifyInfos, bool& isOverlay); diff --git a/packing_tool/frameworks/src/json/module_json_utils.cpp b/packing_tool/frameworks/src/json/module_json_utils.cpp index 984071c3..b0ff2d9b 100644 --- a/packing_tool/frameworks/src/json/module_json_utils.cpp +++ b/packing_tool/frameworks/src/json/module_json_utils.cpp @@ -172,7 +172,8 @@ bool ModuleJsonUtils::GetHapVerifyInfosfromFileList(const std::list return true; } -bool ModuleJsonUtils::GetHapVerifyInfosMapfromFileList(const std::list& fileList, std::map>& hapVerifyInfoMap) +bool ModuleJsonUtils::GetHapVerifyInfosMapfromFileList(const std::list& fileList, std::map>& hapVerifyInfoMap) { for (auto& hapPath : fileList) { if (hapPath.empty()) { @@ -207,7 +208,8 @@ bool ModuleJsonUtils::GetHapVerifyInfosMapfromFileList(const std::list parameterMap, std::map>& hapVerifyInfoMap) +bool ModuleJsonUtils::CheckAppAtomicServiceCompressedSizeValid(std::map parameterMap, + std::map>& hapVerifyInfoMap) { std::string packMode; std::string outPath; @@ -217,7 +219,9 @@ bool ModuleJsonUtils::CheckAppAtomicServiceCompressedSizeValid(std::map fileNameBuffer(fileInfo.size_filename + 1); if (unzGetCurrentFileInfo(zipApp, &fileInfo, fileNameBuffer.data(), fileNameBuffer.size(), - nullptr, 0, nullptr, 0) != UNZ_OK) { + nullptr, 0, nullptr, 0) != UNZ_OK) { unzClose(zipApp); LOGE("ModuleJsonUtils::CheckAppAtomicServiceCompressedSizeValid: failed to get file info (phase 2)"); return false; } std::string fileName(fileNameBuffer.data()); auto it = hapVerifyInfoMap.find(fileName); - if (it == hapVerifyInfoMap.end()) { + if (it == hapVerifyInfoMap.end() || it->second == nullptr) { continue; } it->second->SetFileLength(fileInfo.compressed_size); diff --git a/packing_tool/frameworks/test/unittest/app_packager_test/mock/mock_module_json_utils.cpp b/packing_tool/frameworks/test/unittest/app_packager_test/mock/mock_module_json_utils.cpp index 1e5ea8bf..71625cc1 100644 --- a/packing_tool/frameworks/test/unittest/app_packager_test/mock/mock_module_json_utils.cpp +++ b/packing_tool/frameworks/test/unittest/app_packager_test/mock/mock_module_json_utils.cpp @@ -277,7 +277,7 @@ bool ModuleJsonUtils::CheckAppAtomicServiceCompressedSizeValid(std::mapsecond == nullptr) { continue; } it->second->SetFileLength(fileInfo.compressed_size); -- Gitee