diff --git a/README_zh.md b/README_zh.md index d820b86f75f81d9041393c8dc6aea10e3a9dee06..baad5d9272464b4061c59184fbec40d2c73746a3 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 5e844e246fff0625198b5470d6d3a3f9c76eefab..6f0209f531d74f01604a1c1ae3317fa9cd47c0c3 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 984071c3862325046530a33be6bc68b41665aaa8..b0ff2d9be93e2191157f1de62740b519732f3c5e 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 1e5ea8bf9866c1152c159d1c67c74a9d478b64e8..71625cc12c1d37ff0d41793465104c5550c7fc7a 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);