diff --git a/services/bundlemgr/include/base_bundle_installer.h b/services/bundlemgr/include/base_bundle_installer.h index 446ee0de21761052bd89fcc00e2962c7b3de7c2d..0cda6dad19bea22be3d945bcbefdb1135e33e0e8 100644 --- a/services/bundlemgr/include/base_bundle_installer.h +++ b/services/bundlemgr/include/base_bundle_installer.h @@ -597,6 +597,9 @@ private: bool CheckReleaseTypeIsCompatible(const InnerBundleInfo &oldInfo, const InnerBundleInfo &newInfo) const; void SendBundleSystemEvent(const std::string &bundleName, BundleEventType bundleEventType, const InstallParam &installParam, InstallScene preBundleScene, ErrCode errCode); + void SetAPIAndSdkVersions(int32_t targetAPIVersion, uint32_t minAPIVersion, const std::string &compileSdlVersion); + void SetUid(int32_t uid); + void SetIsAbcCompressed(); ErrCode CheckNativeFileWithOldInfo( const InnerBundleInfo &oldInfo, std::unordered_map &newInfos); bool HasAllOldModuleUpdate( diff --git a/services/bundlemgr/include/bundle_extractor.h b/services/bundlemgr/include/bundle_extractor.h index 1be34ccb59ac3dc163576bf6c3b31d031907d3b0..7e8116a5a42df80e061c8d1c21cf5c15353daab7 100644 --- a/services/bundlemgr/include/bundle_extractor.h +++ b/services/bundlemgr/include/bundle_extractor.h @@ -44,6 +44,8 @@ public: * @return Returns true if the Profile is successfully extracted; returns false otherwise. */ bool ExtractModuleProfile(std::ostream &dest) const; + + void IsHapCompress(bool &isAbcCompressed) const; }; class BundleParallelExtractor : public BundleExtractor { diff --git a/services/bundlemgr/include/bundle_install_checker.h b/services/bundlemgr/include/bundle_install_checker.h index e43813e4e30545691a746a2a66fa7f1798194005..b1abd515a62aed385f4f8bef74728297b18088d3 100644 --- a/services/bundlemgr/include/bundle_install_checker.h +++ b/services/bundlemgr/include/bundle_install_checker.h @@ -198,6 +198,9 @@ public: ErrCode CheckNoU1Enable(const std::unordered_map &newInfos); + bool GetIsAbcCompressed() const; + void SetIsAbcCompressed(const bool &isAbcCompressed); + ErrCode CheckU1EnableSameInHaps(const std::unordered_map &infos, const std::string &bundleName, bool &u1Enable); bool DetermineCloneApp(InnerBundleInfo &innerBundleInfo); @@ -261,6 +264,8 @@ private: bool isContainEntry_ = false; + bool isAbcCompressed_ = false; + void SetAppProvisionMetadata(const std::vector &provisionMetadatas, InnerBundleInfo &newInfo); diff --git a/services/bundlemgr/include/bundle_parser.h b/services/bundlemgr/include/bundle_parser.h index 672f4b98d80ad4991dc9b2814df580b4b70b4f79..0bb4f69d14b528601d8f19693d3749543df8703b 100644 --- a/services/bundlemgr/include/bundle_parser.h +++ b/services/bundlemgr/include/bundle_parser.h @@ -42,7 +42,8 @@ public: */ ErrCode Parse( const std::string &pathName, - InnerBundleInfo &innerBundleInfo) const; + InnerBundleInfo &innerBundleInfo, + bool &isAbcCompressed) const; ErrCode ParsePackInfo(const std::string &pathName, BundlePackInfo &bundlePackInfo) const; /** diff --git a/services/bundlemgr/include/event_report.h b/services/bundlemgr/include/event_report.h index 00c70805e611926c348d14954ced49bbb0020014..487fce748a74d803b5fed11f7be280e663b1df97 100644 --- a/services/bundlemgr/include/event_report.h +++ b/services/bundlemgr/include/event_report.h @@ -142,6 +142,9 @@ struct EventInfo { bool isPatch = false; + // abc compressed + bool isAbcCompressed = false; + InstallScene preBundleScene = InstallScene::NORMAL; // only used in user event @@ -160,6 +163,11 @@ struct EventInfo { uint32_t versionCode = 0; uint32_t successCnt = 0; + // only used in install and update + int32_t targetAPIVersion = 0; + uint32_t minAPIVersion = 0; + int32_t uid = 0; + // only used in fault event ErrCode errCode = ERR_OK; int64_t costTimeSeconds = 0; @@ -183,6 +191,9 @@ struct EventInfo { std::string failureReason; std::string processName; + // only used in install and update + std::string compileSdkVersion; + //for query of continue type std::string continueType; std::string fileName; @@ -268,6 +279,10 @@ struct EventInfo { bundleNameList.clear(); callingAppIdList.clear(); callingBundleNameList.clear(); + targetAPIVersion = 0; + minAPIVersion = 0; + uid = 0; + isAbcCompressed = false; } }; diff --git a/services/bundlemgr/include/inner_bundle_info.h b/services/bundlemgr/include/inner_bundle_info.h index dd651a927ec1a4f0d40c69d01c5c1bfe99edd120..77ac6e47c85dfa9cbcfc8de64c296aa867cfe635 100644 --- a/services/bundlemgr/include/inner_bundle_info.h +++ b/services/bundlemgr/include/inner_bundle_info.h @@ -2397,6 +2397,7 @@ private: // need to send a notification when uninstallState_ change bool isNeedSendNotify_ = false; + BundleStatus bundleStatus_ = BundleStatus::ENABLED; int32_t appIndex_ = Constants::INITIAL_APP_INDEX; // apply quick fix frequency diff --git a/services/bundlemgr/src/base_bundle_installer.cpp b/services/bundlemgr/src/base_bundle_installer.cpp index 875a4746fb8d2eb8367f48200f1b06e1142291cc..fdc1f1684b7e8c7ab584347837939ebda3f69033 100644 --- a/services/bundlemgr/src/base_bundle_installer.cpp +++ b/services/bundlemgr/src/base_bundle_installer.cpp @@ -1552,6 +1552,12 @@ ErrCode BaseBundleInstaller::ProcessBundleInstall(const std::vector LOG_W(BMS_TAG_INSTALLER, "ProcessExtProfile failed"); } SetHybridSpawn(); + // set api and sdk version to systemevent + SetAPIAndSdkVersions(cacheInfo.GetBaseApplicationInfo().apiTargetVersion, + cacheInfo.GetBaseApplicationInfo().apiCompatibleVersion, + cacheInfo.GetBaseApplicationInfo().compileSdkVersion); + SetUid(uid); + SetIsAbcCompressed(); LOG_I(BMS_TAG_INSTALLER, "finish install %{public}s", bundleName_.c_str()); UtdHandler::InstallUtdAsync(bundleName_, userId_); CheckAddResultMsg(newInfos, oldInfo, isContainEntry_); @@ -7988,5 +7994,23 @@ bool BaseBundleInstaller::CheckAddResultMsg(const std::unordered_mapGetIsAbcCompressed(); +} } // namespace AppExecFwk } // namespace OHOS diff --git a/services/bundlemgr/src/bundle_extractor.cpp b/services/bundlemgr/src/bundle_extractor.cpp index 4ff2ef7214b71438102c5215eef65180601c274f..ab638af733b091c9b112832e33fd815e2aefee15 100644 --- a/services/bundlemgr/src/bundle_extractor.cpp +++ b/services/bundlemgr/src/bundle_extractor.cpp @@ -23,6 +23,8 @@ namespace { constexpr const char* BUNDLE_PROFILE_NAME = "config.json"; constexpr const char* MODULE_PROFILE_NAME = "module.json"; constexpr const char* BUNDLE_PACKFILE_NAME = "pack.info"; +constexpr const char* MERGE_ABC_PATH = "ets/modules.abc"; + } BundleExtractor::BundleExtractor(const std::string &source, bool parallel) : BaseExtractor(source, parallel) { @@ -60,6 +62,18 @@ bool BundleExtractor::ExtractModuleProfile(std::ostream &dest) const return false; } +void BundleExtractor::IsHapCompress(bool &isAbcCompressed) const +{ + ZipEntry zipEntry; + if (!zipFile_.GetEntry(MERGE_ABC_PATH, zipEntry)) { + APP_LOGE("GetEntry failed entryName: %{public}s", MERGE_ABC_PATH); + return; + } + if (zipEntry.compressionMethod != 0) { + isAbcCompressed = true; + } +} + BundleParallelExtractor::BundleParallelExtractor(const std::string &source) : BundleExtractor(source, true) { APP_LOGD("BundleParallelExtractor is created"); diff --git a/services/bundlemgr/src/bundle_install_checker.cpp b/services/bundlemgr/src/bundle_install_checker.cpp index 16d00b90bb98b223a898c3ccaeea2b414bbb7f45..36231e75a7de4f2a9c3f72ff4c255987bb155dcc 100644 --- a/services/bundlemgr/src/bundle_install_checker.cpp +++ b/services/bundlemgr/src/bundle_install_checker.cpp @@ -840,7 +840,7 @@ ErrCode BundleInstallChecker::ParseBundleInfo( BundlePackInfo &packInfo) { BundleParser bundleParser; - ErrCode result = bundleParser.Parse(bundleFilePath, info); + ErrCode result = bundleParser.Parse(bundleFilePath, info, isAbcCompressed_); if (result != ERR_OK) { LOG_E(BMS_TAG_INSTALLER, "parse bundle info failed, error: %{public}d", result); if (result == ERR_APPEXECFWK_PARSE_NATIVE_SO_FAILED) { @@ -851,7 +851,6 @@ ErrCode BundleInstallChecker::ParseBundleInfo( } return result; } - const auto extensions = info.GetInnerExtensionInfos(); for (const auto &item : extensions) { if (item.second.type == ExtensionAbilityType::UNSPECIFIED && @@ -1813,5 +1812,15 @@ bool BundleInstallChecker::DetermineCloneApp(InnerBundleInfo &innerBundleInfo) } return true; } + +bool BundleInstallChecker::GetIsAbcCompressed() const +{ + return isAbcCompressed_; +} + +void BundleInstallChecker::SetIsAbcCompressed(const bool &isAbcCompressed) +{ + isAbcCompressed_ = isAbcCompressed; +} } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file diff --git a/services/bundlemgr/src/bundle_mgr_host_impl.cpp b/services/bundlemgr/src/bundle_mgr_host_impl.cpp index 2a42a0e1d411525fb56e1b19175480df768fe262..492fe0f273ccecf3534b0cb4d4f2e2f74be0925a 100644 --- a/services/bundlemgr/src/bundle_mgr_host_impl.cpp +++ b/services/bundlemgr/src/bundle_mgr_host_impl.cpp @@ -1428,7 +1428,8 @@ bool BundleMgrHostImpl::GetBundleArchiveInfo( InnerBundleInfo info; BundleParser bundleParser; - ret = bundleParser.Parse(realPath, info); + bool isAbcCompressed = false; + ret = bundleParser.Parse(realPath, info, isAbcCompressed); if (ret != ERR_OK) { APP_LOGE("parse bundle info failed, error: %{public}d", ret); return false; @@ -1472,7 +1473,8 @@ ErrCode BundleMgrHostImpl::GetBundleArchiveInfoV9( } InnerBundleInfo info; BundleParser bundleParser; - ret = bundleParser.Parse(realPath, info); + bool isAbcCompressed = false; + ret = bundleParser.Parse(realPath, info, isAbcCompressed); if (ret != ERR_OK) { APP_LOGE("parse bundle info failed, error: %{public}d", ret); return ERR_BUNDLE_MANAGER_INVALID_HAP_PATH; @@ -1528,7 +1530,8 @@ ErrCode BundleMgrHostImpl::GetBundleArchiveInfoBySandBoxPath(const std::string & } InnerBundleInfo info; BundleParser bundleParser; - ret = bundleParser.Parse(realPath, info); + bool isAbcCompressed = false; + ret = bundleParser.Parse(realPath, info, isAbcCompressed); if (ret != ERR_OK) { APP_LOGE("parse bundle info failed, error: %{public}d", ret); BundleUtil::DeleteDir(tempHapPath); diff --git a/services/bundlemgr/src/bundle_mgr_service_event_handler.cpp b/services/bundlemgr/src/bundle_mgr_service_event_handler.cpp index d7de503ef50a69ba11faf822613ee448ff685c52..5a577ee2bb9500ef603ee6eff1c3f507b8977a96 100644 --- a/services/bundlemgr/src/bundle_mgr_service_event_handler.cpp +++ b/services/bundlemgr/src/bundle_mgr_service_event_handler.cpp @@ -3766,7 +3766,8 @@ bool BMSEventHandler::ParseHapFiles( BundleParser bundleParser; for (auto realPath : realPaths) { InnerBundleInfo innerBundleInfo; - ret = bundleParser.Parse(realPath, innerBundleInfo); + bool isAbcCompressed = false; + ret = bundleParser.Parse(realPath, innerBundleInfo, isAbcCompressed); if (ret != ERR_OK) { LOG_E(BMS_TAG_DEFAULT, "Parse bundle info failed, error: %{public}d", ret); continue; diff --git a/services/bundlemgr/src/bundle_parser.cpp b/services/bundlemgr/src/bundle_parser.cpp index d61ae4273aab85193bd1bf88d3ff9ad9e4001c35..34b5a7728297b4236e14d4f53a72f7594b69b792 100644 --- a/services/bundlemgr/src/bundle_parser.cpp +++ b/services/bundlemgr/src/bundle_parser.cpp @@ -103,7 +103,8 @@ bool BundleParser::ReadFileIntoJson(const std::string &filePath, nlohmann::json ErrCode BundleParser::Parse( const std::string &pathName, - InnerBundleInfo &innerBundleInfo) const + InnerBundleInfo &innerBundleInfo, + bool &isAbcCompressed) const { APP_LOGD("parse from %{private}s", pathName.c_str()); BundleExtractor bundleExtractor(pathName); @@ -144,6 +145,7 @@ ErrCode BundleParser::Parse( } } + bundleExtractor.IsHapCompress(isAbcCompressed); return ERR_OK; } diff --git a/services/bundlemgr/src/extend_resource/extend_resource_manager_host_impl.cpp b/services/bundlemgr/src/extend_resource/extend_resource_manager_host_impl.cpp index e2afc24c5249bb8bf1fda5d2d2119a31d71dc11c..eb8ab197b1670ad4df71c541ad1fe9c81466208b 100644 --- a/services/bundlemgr/src/extend_resource/extend_resource_manager_host_impl.cpp +++ b/services/bundlemgr/src/extend_resource/extend_resource_manager_host_impl.cpp @@ -219,7 +219,8 @@ ErrCode ExtendResourceManagerHostImpl::ParseExtendResourceFile( for (uint32_t i = 0; i < filePaths.size(); ++i) { BundleParser bundleParser; InnerBundleInfo innerBundleInfo; - ErrCode result = bundleParser.Parse(filePaths[i], innerBundleInfo); + bool isAbcCompressed = false; + ErrCode result = bundleParser.Parse(filePaths[i], innerBundleInfo, isAbcCompressed); if (result != ERR_OK) { APP_LOGE("parse bundle info %{public}s failed, err %{public}d", filePaths[i].c_str(), result); diff --git a/services/bundlemgr/src/hmp_bundle_installer.cpp b/services/bundlemgr/src/hmp_bundle_installer.cpp index 66b4129111e8f1bf642d691dcc1e5aaad3d72d77..dba5482b9e7d52adcbc6fc7515a95e8e8299fdc6 100644 --- a/services/bundlemgr/src/hmp_bundle_installer.cpp +++ b/services/bundlemgr/src/hmp_bundle_installer.cpp @@ -236,7 +236,8 @@ bool HmpBundleInstaller::ParseHapFiles( BundleParser bundleParser; for (auto realPath : realPaths) { InnerBundleInfo innerBundleInfo; - ret = bundleParser.Parse(realPath, innerBundleInfo); + bool isAbcCompressed = false; + ret = bundleParser.Parse(realPath, innerBundleInfo, isAbcCompressed); if (ret != ERR_OK) { APP_LOGE("Parse bundle info failed, error: %{public}d", ret); continue; diff --git a/services/bundlemgr/src/inner_event_report.cpp b/services/bundlemgr/src/inner_event_report.cpp index 26f77d06c88d54445b26a904203a3c393aaafaac..568b66206b386cf72df693dc07c61e64913c592e 100644 --- a/services/bundlemgr/src/inner_event_report.cpp +++ b/services/bundlemgr/src/inner_event_report.cpp @@ -95,6 +95,12 @@ const char* REMAIN_PARTITION_SIZE_KEY = "REMAIN_PARTITION_SIZE"; const char* USER_DATA_SIZE = "USER_DATA_SIZE"; const char* EVENT_PARAM_WANT = "WANT"; const char* EVENT_PARAM_UTD = "UTD"; +// API and SDK version +const char* EVENT_PARAM_MIN_API_VERSION = "MIN_API_VERSION"; +const char* EVENT_PARAM_TARGET_API_VERSION = "TARGET_API_VERSION"; +const char* EVENT_PARAM_COMPILE_SDK_VERSION = "COMPILE_SDK_VERSION"; +const char* EVENT_PARAM_UID = "UID"; +const char* EVENT_PARAM_IS_ABC_COMPRESSED = "IS_ABC_COMPRESSED"; const char* FREE_INSTALL_TYPE = "FreeInstall"; const char* PRE_BUNDLE_INSTALL_TYPE = "PreBundleInstall"; @@ -493,7 +499,12 @@ void InnerEventReport::InnerSendBundleInstallEvent(const EventInfo& eventInfo) EVENT_PARAM_INSTALL_TYPE, GetInstallType(eventInfo), EVENT_PARAM_SCENE, GetInstallScene(eventInfo), EVENT_PARAM_APP_INDEX, eventInfo.appIndex, - EVENT_PARAM_IS_PATCH, eventInfo.isPatch); + EVENT_PARAM_IS_PATCH, eventInfo.isPatch, + EVENT_PARAM_MIN_API_VERSION, eventInfo.minAPIVersion, + EVENT_PARAM_TARGET_API_VERSION, eventInfo.targetAPIVersion, + EVENT_PARAM_COMPILE_SDK_VERSION, eventInfo.compileSdkVersion, + EVENT_PARAM_UID, eventInfo.uid, + EVENT_PARAM_IS_ABC_COMPRESSED, eventInfo.isAbcCompressed); } void InnerEventReport::InnerSendBundleUninstallEvent(const EventInfo& eventInfo) @@ -533,7 +544,12 @@ void InnerEventReport::InnerSendBundleUpdateEvent(const EventInfo& eventInfo) EVENT_PARAM_FINGERPRINT, eventInfo.fingerprint, EVENT_PARAM_HIDE_DESKTOP_ICON, eventInfo.hideDesktopIcon, EVENT_PARAM_INSTALL_TYPE, GetInstallType(eventInfo), - EVENT_PARAM_IS_PATCH, eventInfo.isPatch); + EVENT_PARAM_IS_PATCH, eventInfo.isPatch, + EVENT_PARAM_MIN_API_VERSION, eventInfo.minAPIVersion, + EVENT_PARAM_TARGET_API_VERSION, eventInfo.targetAPIVersion, + EVENT_PARAM_COMPILE_SDK_VERSION, eventInfo.compileSdkVersion, + EVENT_PARAM_UID, eventInfo.uid, + EVENT_PARAM_IS_ABC_COMPRESSED, eventInfo.isAbcCompressed); } void InnerEventReport::InnerSendPreBundleRecoverEvent(const EventInfo& eventInfo) diff --git a/services/bundlemgr/test/unittest/bms_bundle_parser_test/bms_bundle_parser_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_parser_test/bms_bundle_parser_test.cpp index c696411921a34550d805811e60e87dc65fde8d01..f480e2d71e14119c762c7787e0142b36ccf86d38 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_parser_test/bms_bundle_parser_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_parser_test/bms_bundle_parser_test.cpp @@ -14,6 +14,7 @@ */ #define private public +#define protected public #include #include @@ -2136,7 +2137,8 @@ HWTEST_F(BmsBundleParserTest, TestParse_0200, Function | SmallTest | Level0) BundleParser bundleParser; InnerBundleInfo innerBundleInfo; pathStream_ << RESOURCE_ROOT_PATH << UNKOWN_PATH << INSTALL_FILE_SUFFIX; - ErrCode result = bundleParser.Parse(pathStream_.str(), innerBundleInfo); + bool isAbcCompressed = false; + ErrCode result = bundleParser.Parse(pathStream_.str(), innerBundleInfo, isAbcCompressed); EXPECT_EQ(result, ERR_APPEXECFWK_PARSE_UNEXPECTED); } @@ -2349,17 +2351,18 @@ HWTEST_F(BmsBundleParserTest, TestParse_1600, Function | SmallTest | Level0) BundleParser bundleParser; InnerBundleInfo innerBundleInfo; pathStream_ << RESOURCE_ROOT_PATH << "demo.error_type"; - ErrCode result = bundleParser.Parse(pathStream_.str(), innerBundleInfo); + bool isAbcCompressed = false; + ErrCode result = bundleParser.Parse(pathStream_.str(), innerBundleInfo, isAbcCompressed); EXPECT_EQ(result, ERR_APPEXECFWK_PARSE_UNEXPECTED); pathStream_.str(""); pathStream_ << RESOURCE_ROOT_PATH << "demo."; - result = bundleParser.Parse(pathStream_.str(), innerBundleInfo); + result = bundleParser.Parse(pathStream_.str(), innerBundleInfo, isAbcCompressed); EXPECT_EQ(result, ERR_APPEXECFWK_PARSE_UNEXPECTED); pathStream_.str(""); pathStream_ << RESOURCE_ROOT_PATH << "bundle_suffix_test.BUNDLE"; - result = bundleParser.Parse(pathStream_.str(), innerBundleInfo); + result = bundleParser.Parse(pathStream_.str(), innerBundleInfo, isAbcCompressed); EXPECT_EQ(result, ERR_APPEXECFWK_PARSE_UNEXPECTED); } @@ -2379,7 +2382,8 @@ HWTEST_F(BmsBundleParserTest, TestParse_1700, Function | SmallTest | Level1) pathStream_ << "test/"; } pathStream_ << NEW_APP << INSTALL_FILE_SUFFIX; - ErrCode result = bundleParser.Parse(pathStream_.str(), innerBundleInfo); + bool isAbcCompressed = false; + ErrCode result = bundleParser.Parse(pathStream_.str(), innerBundleInfo, isAbcCompressed); EXPECT_EQ(result, ERR_APPEXECFWK_PARSE_UNEXPECTED) << pathStream_.str(); } @@ -2399,7 +2403,8 @@ HWTEST_F(BmsBundleParserTest, TestParse_1800, Function | SmallTest | Level1) pathStream_ << "test/"; } pathStream_ << NEW_APP << INSTALL_FILE_SUFFIX; - ErrCode result = bundleParser.Parse(pathStream_.str(), innerBundleInfo); + bool isAbcCompressed = false; + ErrCode result = bundleParser.Parse(pathStream_.str(), innerBundleInfo, isAbcCompressed); EXPECT_EQ(result, ERR_APPEXECFWK_PARSE_UNEXPECTED); } @@ -2416,7 +2421,8 @@ HWTEST_F(BmsBundleParserTest, TestParse_1900, Function | SmallTest | Level1) pathStream_ << RESOURCE_ROOT_PATH; std::string specialChars = "~!@#$%^&*(){}[]:;'?<>,.|`/./+_-"; pathStream_ << specialChars << "new" << INSTALL_FILE_SUFFIX; - ErrCode result = bundleParser.Parse(pathStream_.str(), innerBundleInfo); + bool isAbcCompressed = false; + ErrCode result = bundleParser.Parse(pathStream_.str(), innerBundleInfo, isAbcCompressed); EXPECT_EQ(result, ERR_APPEXECFWK_PARSE_UNEXPECTED); } @@ -4992,4 +4998,35 @@ HWTEST_F(BmsBundleParserTest, ParseArkStartupCacheConfig_0100, Function | Medium ret = BundleParser::ParseArkStartupCacheConfig(ServiceConstants::APP_STARTUP_CACHE_CONG, arkStartupCacheList); EXPECT_EQ(ret, ERR_OK); } + +/** + * @tc.number: IsHapCompress_0100 + * @tc.name: parse abc compressed in hap + * @tc.desc: 1. test IsHapCompress in bundleExtractor + */ +HWTEST_F(BmsBundleParserTest, IsHapCompress_0100, Function | SmallTest | Level1) +{ + BundleParser bundleParser; + pathStream_ << RESOURCE_ROOT_PATH << UNKOWN_PATH << INSTALL_FILE_SUFFIX; + bool result = false; + + BundleExtractor bundleExtractor(pathStream_.str()); + bundleExtractor.IsHapCompress(result); + EXPECT_FALSE(result); + + ZipEntry zipEntry; + zipEntry.compressionMethod = 0; + bundleExtractor.zipFile_.entriesMap_.emplace( + std::string("ets/modules.abc"), zipEntry); + bundleExtractor.IsHapCompress(result); + EXPECT_FALSE(result); + + BundleExtractor bundleExtractor2(pathStream_.str()); + zipEntry.compressionMethod = 1; + bundleExtractor2.zipFile_.entriesMap_.emplace( + std::string("ets/modules.abc"), zipEntry); + bundleExtractor2.IsHapCompress(result); + EXPECT_TRUE(result); +} + } // OHOS \ No newline at end of file diff --git a/services/test/moduletest/common/bms/bundle_parser_test/bms_bundle_parser_module_test.cpp b/services/test/moduletest/common/bms/bundle_parser_test/bms_bundle_parser_module_test.cpp index 991c71528f8d7af6a1383b3517e6cd8d306b2d97..96dd841e8eefa09690c70b40ea3288e42c9a9eb0 100644 --- a/services/test/moduletest/common/bms/bundle_parser_test/bms_bundle_parser_module_test.cpp +++ b/services/test/moduletest/common/bms/bundle_parser_test/bms_bundle_parser_module_test.cpp @@ -36,7 +36,8 @@ public: { BundleParser bundleParser; InnerBundleInfo innerBundleInfo; - ErrCode result = bundleParser.Parse(pathStream.str(), innerBundleInfo); + bool isAbcCompressed = false; + ErrCode result = bundleParser.Parse(pathStream.str(), innerBundleInfo, isAbcCompressed); BundleInfo bundleInfo = innerBundleInfo.GetBaseBundleInfo(); EXPECT_EQ(result, ERR_OK); diff --git a/test/fuzztest/fuzztest_others/parse_fuzzer/parse_fuzzer.cpp b/test/fuzztest/fuzztest_others/parse_fuzzer/parse_fuzzer.cpp index 9fd78bd7c21ac76cd5252ffa0f80f4dc46a45d17..0f91d4b0703a4a9f937ebb0186d4893eacca4b41 100644 --- a/test/fuzztest/fuzztest_others/parse_fuzzer/parse_fuzzer.cpp +++ b/test/fuzztest/fuzztest_others/parse_fuzzer/parse_fuzzer.cpp @@ -51,7 +51,8 @@ namespace OHOS { pFile = nullptr; InnerBundleInfo info; BundleParser bundleParser; - auto ret = bundleParser.Parse("myHap.hap", info); + bool isAbcCompressed = false; + auto ret = bundleParser.Parse("myHap.hap", info, isAbcCompressed); if (ret != ERR_OK) { return false; }