From 236d09fac6f5ace681ed906f0ef3410916587c71 Mon Sep 17 00:00:00 2001 From: small_leek Date: Wed, 3 Sep 2025 12:03:56 +0800 Subject: [PATCH] add apiversion, sdkversion and uid to isntall/update sysytem event Signed-off-by: small_leek --- .../bundlemgr/include/base_bundle_installer.h | 3 ++ services/bundlemgr/include/bundle_extractor.h | 2 + .../include/bundle_install_checker.h | 5 ++ services/bundlemgr/include/bundle_parser.h | 3 +- services/bundlemgr/include/event_report.h | 15 ++++++ .../bundlemgr/include/inner_bundle_info.h | 1 + .../bundlemgr/src/base_bundle_installer.cpp | 24 +++++++++ services/bundlemgr/src/bundle_extractor.cpp | 14 +++++ .../bundlemgr/src/bundle_install_checker.cpp | 13 ++++- .../bundlemgr/src/bundle_mgr_host_impl.cpp | 9 ++-- .../src/bundle_mgr_service_event_handler.cpp | 3 +- services/bundlemgr/src/bundle_parser.cpp | 4 +- .../extend_resource_manager_host_impl.cpp | 3 +- .../bundlemgr/src/hmp_bundle_installer.cpp | 3 +- services/bundlemgr/src/inner_event_report.cpp | 20 +++++++- .../bms_bundle_parser_test.cpp | 51 ++++++++++++++++--- .../bms_bundle_parser_module_test.cpp | 3 +- .../parse_fuzzer/parse_fuzzer.cpp | 3 +- 18 files changed, 158 insertions(+), 21 deletions(-) diff --git a/services/bundlemgr/include/base_bundle_installer.h b/services/bundlemgr/include/base_bundle_installer.h index 446ee0de21..0cda6dad19 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 1be34ccb59..7e8116a5a4 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 e43813e4e3..b1abd515a6 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 672f4b98d8..0bb4f69d14 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 00c70805e6..487fce748a 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 dd651a927e..77ac6e47c8 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 875a4746fb..fdc1f1684b 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 4ff2ef7214..ab638af733 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 16d00b90bb..36231e75a7 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 2a42a0e1d4..492fe0f273 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 d7de503ef5..5a577ee2bb 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 d61ae4273a..34b5a77282 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 e2afc24c52..eb8ab197b1 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 66b4129111..dba5482b9e 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 26f77d06c8..568b66206b 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 c696411921..f480e2d71e 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 991c71528f..96dd841e8e 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 9fd78bd7c2..0f91d4b070 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; } -- Gitee