diff --git a/services/bundlemgr/include/base_bundle_installer.h b/services/bundlemgr/include/base_bundle_installer.h index 446ee0de21761052bd89fcc00e2962c7b3de7c2d..63a6b7525d7f0ce5dbb6d339378ad5cc326076bb 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(bool isAbcCompressed); 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..c8dbcad2c2178db31f049349d86addd83dda0609 100644 --- a/services/bundlemgr/include/bundle_install_checker.h +++ b/services/bundlemgr/include/bundle_install_checker.h @@ -206,7 +206,8 @@ private: ErrCode ParseBundleInfo( const std::string &bundleFilePath, InnerBundleInfo &info, - BundlePackInfo &packInfo); + BundlePackInfo &packInfo, + bool &isAbcCompressed); ErrCode CheckSystemSize( const std::string &bundlePath, 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..ed846ceb030b441f4d5a47f01563557ed1284808 100644 --- a/services/bundlemgr/include/inner_bundle_info.h +++ b/services/bundlemgr/include/inner_bundle_info.h @@ -2306,6 +2306,8 @@ public: void SetUninstallState(const bool &uninstallState); bool IsNeedSendNotify() const; void SetNeedSendNotify(const bool needStatus); + bool GetIsAbcCompressed() const; + void SetIsAbcCompressed(const bool &isAbcCompressed); void UpdateMultiAppMode(const InnerBundleInfo &newInfo); void UpdateReleaseType(const InnerBundleInfo &newInfo); ErrCode AddCloneBundle(const InnerBundleCloneInfo &attr); @@ -2397,6 +2399,8 @@ private: // need to send a notification when uninstallState_ change bool isNeedSendNotify_ = false; + + bool isAbcCompressed_ = 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..073e52942aafe19c554b8883a338a98a0cc43649 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(cacheInfo.GetIsAbcCompressed()); LOG_I(BMS_TAG_INSTALLER, "finish install %{public}s", bundleName_.c_str()); UtdHandler::InstallUtdAsync(bundleName_, userId_); CheckAddResultMsg(newInfos, oldInfo, isContainEntry_); @@ -2335,6 +2341,12 @@ ErrCode BaseBundleInstaller::InnerProcessInstallByPreInstallInfo( } // process resource BundleResourceHelper::AddResourceInfoByBundleName(bundleName, userId_, ADD_RESOURCE_TYPE::CREATE_USER); + // set api and sdk version to systemevent + SetAPIAndSdkVersions(oldInfo.GetBaseApplicationInfo().apiTargetVersion, + oldInfo.GetBaseApplicationInfo().apiCompatibleVersion, + oldInfo.GetBaseApplicationInfo().compileSdkVersion); + SetUid(uid); + SetIsAbcCompressed(oldInfo.GetIsAbcCompressed()); return ERR_OK; } } @@ -7988,5 +8000,23 @@ bool BaseBundleInstaller::CheckAddResultMsg(const std::unordered_mapsecond.SetIsAbcCompressed(isAbcCompressed); } if ((result = CheckModuleNameForMulitHaps(infos)) != ERR_OK) { @@ -837,10 +839,11 @@ void BundleInstallChecker::SetPackInstallationFree(BundlePackInfo &bundlePackInf ErrCode BundleInstallChecker::ParseBundleInfo( const std::string &bundleFilePath, InnerBundleInfo &info, - BundlePackInfo &packInfo) + BundlePackInfo &packInfo, + bool &isAbcCompressed) { 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) { 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_bundle_info.cpp b/services/bundlemgr/src/inner_bundle_info.cpp index 596862263e954f7bdecf75263a30da1698756136..64342eb65a4f10cf725e6feb14491ceb79f97390 100644 --- a/services/bundlemgr/src/inner_bundle_info.cpp +++ b/services/bundlemgr/src/inner_bundle_info.cpp @@ -372,6 +372,7 @@ InnerBundleInfo &InnerBundleInfo::operator=(const InnerBundleInfo &info) this->odid_ = info.odid_; this->uninstallState_ = info.uninstallState_; this->pluginBundleInfos_ = info.pluginBundleInfos_; + this->isAbcCompressed_ = info.isAbcCompressed_; return *this; } @@ -4737,6 +4738,16 @@ void InnerBundleInfo::SetNeedSendNotify(const bool needStatus) isNeedSendNotify_ = needStatus; } +bool InnerBundleInfo::GetIsAbcCompressed() const +{ + return isAbcCompressed_; +} + +void InnerBundleInfo::SetIsAbcCompressed(const bool &isAbcCompressed) +{ + isAbcCompressed_ = isAbcCompressed; +} + std::vector InnerBundleInfo::GetAllExtensionDirsInSpecifiedModule(const std::string &moduleName) const { std::vector dirVec; 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_installer_test/bms_bundle_install_checker_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_bundle_install_checker_test.cpp index 184d2bf56b76478d356c8d9d01bf5adc894e2a18..99a64f3c7dd3e84467d9abf5a5718d1f0dfd0384 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_bundle_install_checker_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_bundle_install_checker_test.cpp @@ -2504,7 +2504,8 @@ HWTEST_F(BmsBundleInstallCheckerTest, ParseBundleInfo_0100, Function | SmallTest std::string bundlePath = ""; InnerBundleInfo info; BundlePackInfo packInfo; - bool ret = installChecker.ParseBundleInfo(bundlePath, info, packInfo); + bool isAbcCompressed = false; + bool ret = installChecker.ParseBundleInfo(bundlePath, info, packInfo, isAbcCompressed); EXPECT_NE(ret, ERR_OK); } diff --git a/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_bundle_installer_test.cpp b/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_bundle_installer_test.cpp index c220cd66b3ee4a91305ec6b703bf9fc10ad0957f..e8e24b123f55a0b159528b354b219880afaaf7fb 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_bundle_installer_test.cpp +++ b/services/bundlemgr/test/unittest/bms_bundle_installer_test/bms_bundle_installer_test.cpp @@ -3928,7 +3928,8 @@ HWTEST_F(BmsBundleInstallerTest, InstallChecker_0800, Function | SmallTest | Lev BundleInstallChecker installChecker; InnerBundleInfo info; BundlePackInfo packInfo; - auto ret = installChecker.ParseBundleInfo("", info, packInfo); + bool isAbcCompressed = false; + auto ret = installChecker.ParseBundleInfo("", info, packInfo, isAbcCompressed); EXPECT_EQ(ret, ERR_APPEXECFWK_PARSE_UNEXPECTED); } 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; }