From c27e0dca068ee55ae3fb4ca01420b2d1339d3df6 Mon Sep 17 00:00:00 2001 From: 18710539902 Date: Wed, 22 May 2024 15:41:11 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E6=8F=90=E4=BE=9Bcache=E7=A9=BA=E9=97=B4?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=B8=85=E7=90=86=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 18710539902 --- .../include/appexecfwk_errors.h | 5 + ...bundle_framework_core_ipc_interface_code.h | 1 + .../include/bundlemgr/bundle_mgr_host.h | 7 + .../include/bundlemgr/bundle_mgr_interface.h | 9 + .../include/bundlemgr/bundle_mgr_proxy.h | 6 + .../src/bundlemgr/bundle_mgr_host.cpp | 16 ++ .../src/bundlemgr/bundle_mgr_proxy.cpp | 28 +++ .../bundlemgr/include/bundle_mgr_host_impl.h | 11 + services/bundlemgr/include/bundle_util.h | 2 + .../bundlemgr/src/bundle_mgr_host_impl.cpp | 217 ++++++++++++++++++ services/bundlemgr/src/bundle_util.cpp | 40 ++++ 11 files changed, 342 insertions(+) diff --git a/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h b/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h index 58cf51a3f..c56abc8b3 100644 --- a/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h +++ b/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h @@ -383,6 +383,11 @@ enum { // query errcode ERR_BUNDLE_MANAGER_NOT_APP_GALLERY_CALL = 8521250, + ERR_BUNDLE_MANAGER_GET_SYSTEM_ABILITY_FAILED = 8521251, + ERR_BUNDLE_MANAGER_GET_ALL_RUNNING_PROCESSES_FAILED = 8521252, + ERR_BUNDLE_MANAGER_GET_BUNDLE_LIST_FAILED = 8521253, + ERR_BUNDLE_MANAGER_ALL_BUNDLES_ARE_RUNNING = 8521254, + ERR_BUNDLE_MANAGER_ALL_UNUSED_BUNDLES_USAGE_TIME_ARE_EMPTY = 8521255, // app jump interceptor ERR_BUNDLE_MANAGER_APP_JUMP_INTERCEPTOR_INTERNAL_ERROR = APPEXECFWK_BUNDLEMGR_ERR_OFFSET + 0x0701, // 8521473 diff --git a/interfaces/inner_api/appexecfwk_core/include/bundle_framework_core_ipc_interface_code.h b/interfaces/inner_api/appexecfwk_core/include/bundle_framework_core_ipc_interface_code.h index fca23aeee..4b111b530 100644 --- a/interfaces/inner_api/appexecfwk_core/include/bundle_framework_core_ipc_interface_code.h +++ b/interfaces/inner_api/appexecfwk_core/include/bundle_framework_core_ipc_interface_code.h @@ -174,6 +174,7 @@ enum class BundleMgrInterfaceCode : uint32_t { GET_CLONE_APP_INDEXES, GET_NAME_AND_APPINDEX_FOR_UID, QUERY_CLONE_EXTENSION_ABILITY_INFO_WITH_APP_INDEX, + AUTO_CLEAN_CACHE_BY_SIZE, }; /* SAID: 401-85 Interface No.85 subservice also provides the following interfaces */ diff --git a/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_host.h b/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_host.h index c7d19636c..998f06a55 100644 --- a/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_host.h +++ b/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_host.h @@ -382,6 +382,13 @@ private: * @return Returns ERR_OK if called successfully; returns error code otherwise. */ ErrCode HandleGetPermissionDef(MessageParcel &data, MessageParcel &reply); + /** + * @brief Handles the CleanBundleCacheFilesAutomatic function called from a IBundleMgr proxy object. + * @param data Indicates the data to be read. + * @param reply Indicates the reply to be sent; + * @return Returns ERR_OK if called successfully; returns error code otherwise. + */ + ErrCode HandleCleanBundleCacheFilesAutomatic(MessageParcel &data, MessageParcel &reply); /** * @brief Handles the CleanBundleCacheFiles function called from a IBundleMgr proxy object. * @param data Indicates the data to be read. diff --git a/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_interface.h b/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_interface.h index 4ce71975a..645faba40 100644 --- a/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_interface.h +++ b/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_interface.h @@ -690,6 +690,15 @@ public: { return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; } + /** + * @brief Clears cache data of a specified size. + * @param cacheSize Indicates the size of the cache data is to be cleared. + * @return Returns ERR_OK if this function is successfully called; returns other ErrCode otherwise. + */ + virtual ErrCode CleanBundleCacheFilesAutomatic(uint64_t cacheSize) + { + return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; + } /** * @brief Clears application running data of a specified application. * @param bundleName Indicates the bundle name of the application whose data is to be cleared. diff --git a/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_proxy.h b/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_proxy.h index 10f11ad18..87379cff1 100644 --- a/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_proxy.h +++ b/interfaces/inner_api/appexecfwk_core/include/bundlemgr/bundle_mgr_proxy.h @@ -501,6 +501,12 @@ public: * @return Returns ERR_OK if the PermissionDef object is successfully obtained; returns other ErrCode otherwise. */ virtual ErrCode GetPermissionDef(const std::string &permissionName, PermissionDef &permissionDef) override; + /** + * @brief Clears cache data of a specified size through the proxy object. + * @param cacheSize Indicates the size of the cache data is to be cleared. + * @return Returns ERR_OK if this function is successfully called; returns other ErrCode otherwise. + */ + virtual ErrCode CleanBundleCacheFilesAutomatic(uint64_t cacheSize) override; /** * @brief Clears cache data of a specified application through the proxy object. * @param bundleName Indicates the bundle name of the application whose cache data is to be cleared. diff --git a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp index a76ea9a4a..8f740b305 100644 --- a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp +++ b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_host.cpp @@ -158,6 +158,8 @@ void BundleMgrHost::init() &BundleMgrHost::HandleGetLaunchWantForBundle); funcMap_.emplace(static_cast(BundleMgrInterfaceCode::GET_PERMISSION_DEF), &BundleMgrHost::HandleGetPermissionDef); + funcMap_.emplace(static_cast(BundleMgrInterfaceCode::AUTO_CLEAN_CACHE_BY_SIZE), + &BundleMgrHost::HandleCleanBundleCacheFilesAutomatic); funcMap_.emplace(static_cast(BundleMgrInterfaceCode::CLEAN_BUNDLE_CACHE_FILES), &BundleMgrHost::HandleCleanBundleCacheFiles); funcMap_.emplace(static_cast(BundleMgrInterfaceCode::CREATE_BUNDLE_DATA_DIR), @@ -1400,6 +1402,20 @@ ErrCode BundleMgrHost::HandleGetPermissionDef(MessageParcel &data, MessageParcel return ERR_OK; } +ErrCode BundleMgrHost::HandleCleanBundleCacheFilesAutomatic(MessageParcel &data, MessageParcel &reply) +{ + HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); + + uint64_t cacheSize = data.ReadUint64(); + ErrCode ret = CleanBundleCacheFilesAutomatic(cacheSize); + + if (!reply.WriteInt32(ret)) { + APP_LOGE("WriteInt32 failed"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + return ERR_OK; +} + ErrCode BundleMgrHost::HandleCleanBundleCacheFiles(MessageParcel &data, MessageParcel &reply) { HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); diff --git a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp index bdf8f6fd1..167fd7bfe 100644 --- a/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp +++ b/interfaces/inner_api/appexecfwk_core/src/bundlemgr/bundle_mgr_proxy.cpp @@ -1619,6 +1619,34 @@ ErrCode BundleMgrProxy::GetPermissionDef(const std::string &permissionName, Perm BundleMgrInterfaceCode::GET_PERMISSION_DEF, data, permissionDef); } +ErrCode BundleMgrProxy::CleanBundleCacheFilesAutomatic(uint64_t cacheSize) +{ + HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__); + APP_LOGI("begin to CleanBundleCacheFilesAutomatic cache size of %{public}llu", cacheSize); + + if (cacheSize == 0) { + APP_LOGE("parameter error, cache size must be greater than 0"); + return ERR_BUNDLE_MANAGER_INVALID_PARAMETER; + } + + MessageParcel data; + if (!data.WriteInterfaceToken(GetDescriptor())) { + APP_LOGE("fail to CleanBundleCacheFilesAutomatic due to write InterfaceToken fail"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + if (!data.WriteUint64(cacheSize)) { + APP_LOGE("fail to CleanBundleCacheFilesAutomatic due to write cache size fail"); + return ERR_APPEXECFWK_PARCEL_ERROR; + } + + MessageParcel reply; + if (!SendTransactCmd(BundleMgrInterfaceCode::AUTO_CLEAN_CACHE_BY_SIZE, data, reply)) { + APP_LOGE("fail to CleanBundleCacheFilesAutomatic from server"); + return ERR_BUNDLE_MANAGER_IPC_TRANSACTION; + } + return reply.ReadInt32(); +} + ErrCode BundleMgrProxy::CleanBundleCacheFiles( const std::string &bundleName, const sptr cleanCacheCallback, int32_t userId) { diff --git a/services/bundlemgr/include/bundle_mgr_host_impl.h b/services/bundlemgr/include/bundle_mgr_host_impl.h index cfa79aad3..7220c0201 100644 --- a/services/bundlemgr/include/bundle_mgr_host_impl.h +++ b/services/bundlemgr/include/bundle_mgr_host_impl.h @@ -488,6 +488,12 @@ public: * @return Returns true if the PermissionDef object is successfully obtained; returns false otherwise. */ virtual ErrCode GetPermissionDef(const std::string &permissionName, PermissionDef &permissionDef) override; + /** + * @brief Clears cache data of a specified size. + * @param cacheSize Indicates the size of the cache data is to be cleared. + * @return Returns ERR_OK if this function is successfully called; returns other ErrCode otherwise. + */ + virtual ErrCode CleanBundleCacheFilesAutomatic(uint64_t cacheSize) override; /** * @brief Clears cache data of a specified application. * @param bundleName Indicates the bundle name of the application whose cache data is to be cleared. @@ -967,6 +973,11 @@ private: bool VerifyDependency(const std::string &sharedBundleName); void CleanBundleCacheTask(const std::string &bundleName, const sptr cleanCacheCallback, const std::shared_ptr &dataMgr, int32_t userId); + ErrCode CleanBundleCacheFilesGetCleanSize(const std::string &bundleName, + int32_t userId, uint64_t &cleanCacheSize); + void CleanBundleCacheTaskGetCleanSize(const std::string &bundleName, + const std::shared_ptr &dataMgr, + int32_t userId, uint64_t &cleanCacheSize); void NotifyBundleStatus(const NotifyBundleEvents &installRes); ErrCode GetBundleArchiveInfoBySandBoxPath( const std::string &hapFilePath, int32_t flags, BundleInfo &bundleInfo, bool fromV9 = false); diff --git a/services/bundlemgr/include/bundle_util.h b/services/bundlemgr/include/bundle_util.h index ae3c78e43..5148f4886 100644 --- a/services/bundlemgr/include/bundle_util.h +++ b/services/bundlemgr/include/bundle_util.h @@ -176,6 +176,8 @@ public: static bool EndWith(const std::string &source, const std::string &suffix); static int64_t GetFileSize(const std::string &filePath); static int64_t CalculateFileSize(const std::string &bundlePath); + static void GetTotalSizeOfFiles(const std::string& path, off_t &totalSize); + static uint64_t GetTotalSizeOfFilesInDirectory(const std::string& directoryPath); static std::string CreateTempDir(const std::string &tempDir); static std::string CopyFileToSecurityDir(const std::string &filePath, const DirType &dirType, std::vector &toDeletePaths); diff --git a/services/bundlemgr/src/bundle_mgr_host_impl.cpp b/services/bundlemgr/src/bundle_mgr_host_impl.cpp index 52f2398f7..4c2a0b01f 100644 --- a/services/bundlemgr/src/bundle_mgr_host_impl.cpp +++ b/services/bundlemgr/src/bundle_mgr_host_impl.cpp @@ -49,6 +49,11 @@ #include "json_serializer.h" #include "scope_guard.h" #include "system_ability_definition.h" +#include "app_mgr_interface.h" +#include "system_ability_helper.h" +#include "running_process_info.h" +#include "bundle_active_client.h" +#include "bundle_active_period_stats.h" namespace OHOS { namespace AppExecFwk { @@ -1243,6 +1248,218 @@ ErrCode BundleMgrHostImpl::GetPermissionDef(const std::string &permissionName, P return BundlePermissionMgr::GetPermissionDef(permissionName, permissionDef); } +ErrCode BundleMgrHostImpl::CleanBundleCacheFilesAutomatic(uint64_t cacheSize) +{ + APP_LOGI("start CleanBundleCacheFilesAutomatic, cacheSize : %{public}llu", cacheSize); + + if (cacheSize == 0) { + APP_LOGE("parameter error, cache size must be greater than 0"); + return ERR_BUNDLE_MANAGER_INVALID_PARAMETER; + } + + if (!BundlePermissionMgr::VerifyCallingPermissionForAll(Constants::PERMISSION_REMOVECACHEFILE)) { + APP_LOGE("ohos.permission.REMOVE_CACHE_FILES permission denied"); + return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; + } + + int32_t currentUserId = AccountHelper::GetCurrentActiveUserId(); + APP_LOGI("current active userId is %{public}d", currentUserId); + if (currentUserId == Constants::INVALID_USERID) { + APP_LOGE("currentUserId %{public}d is invalid", currentUserId); + return ERR_BUNDLE_MANAGER_INVALID_USER_ID; + } + + // Get all apps under the current active user + auto dataMgr = GetDataMgrFromService(); + if (dataMgr == nullptr) { + APP_LOGE("DataMgr is nullptr"); + return ERR_BUNDLE_MANAGER_INTERNAL_ERROR; + } + + // all apps under the current active user + std::vector currentUserBundleNames; + if (!dataMgr->GetBundleList(currentUserBundleNames, currentUserId)) { + APP_LOGE("get bundle list failed by currentUserId(%{public}d)", currentUserId); + return ERR_BUNDLE_MANAGER_GET_BUNDLE_LIST_FAILED; + } + + // Get all running apps + sptr appMgrProxy = + iface_cast(SystemAbilityHelper::GetSystemAbility(APP_MGR_SERVICE_ID)); + if (appMgrProxy == nullptr) { + APP_LOGE("fail to find the app mgr service to check app is running"); + return ERR_BUNDLE_MANAGER_GET_SYSTEM_ABILITY_FAILED; + } + + std::vector runningList; + int result = appMgrProxy->GetAllRunningProcesses(runningList); + if (result != ERR_OK) { + APP_LOGE("GetAllRunningProcesses failed."); + return ERR_BUNDLE_MANAGER_GET_ALL_RUNNING_PROCESSES_FAILED; + } + + // All apps that are not running under the current active user + std::vector currentUserNotRunningBundleNames; + for (auto bundleName : currentUserBundleNames) { + bool isRunning = false; + for (const auto &info : runningList) { + auto res = std::any_of(info.bundleNames.begin(), info.bundleNames.end(), + [bundleName](const auto &bundleNameInRunningProcessInfo) { + return bundleNameInRunningProcessInfo == bundleName; + }); + if (res) { + isRunning = true; + } + } + if (!isRunning) { + currentUserNotRunningBundleNames.push_back(bundleName); + } + } + + if (currentUserNotRunningBundleNames.empty()) { + APP_LOGE("All apps are running under the current active user"); + return ERR_BUNDLE_MANAGER_ALL_BUNDLES_ARE_RUNNING; + } + + // Get apps use time + int64_t startTime = 0; + int64_t endTime = BundleUtil::GetCurrentTimeMs(); + const int32_t PERIOD_ANNUALLY = 4; + std::vector useStats; + DeviceUsageStats::BundleActiveClient::GetInstance().QueryBundleStatsInfoByInterval( + useStats, PERIOD_ANNUALLY, startTime, endTime, currentUserId); + + // Sort apps use time from small to large + std::map bundleUseTimeMap; + for (auto bundleName : currentUserNotRunningBundleNames) { + for (auto useStat : useStats) { + if (bundleName == useStat.bundleName_) { + bundleUseTimeMap.insert(make_pair(useStat.totalInFrontTime_, bundleName)); + } + } + } + + if (bundleUseTimeMap.empty()) { + APP_LOGE("the current active user all unused apps usage time are empty"); + return ERR_BUNDLE_MANAGER_ALL_UNUSED_BUNDLES_USAGE_TIME_ARE_EMPTY; + } + + uint64_t cleanCacheSize = 0; // The cache size of a single application cleaned up + uint64_t cleanCacheSum = 0; // The total amount of application cache currently cleaned + for (const auto& bundleMap : bundleUseTimeMap) { + ErrCode ret = CleanBundleCacheFilesGetCleanSize(bundleMap.second, currentUserId, cleanCacheSize); + if (ret != ERR_OK) { + return ret; + } + cleanCacheSum += cleanCacheSize; + if (cleanCacheSum >= cacheSize) { + return ERR_OK; + } + } + + return ERR_OK; +} + +ErrCode BundleMgrHostImpl::CleanBundleCacheFilesGetCleanSize(const std::string &bundleName, + int32_t userId, uint64_t &cleanCacheSize) +{ + APP_LOGI("start CleanBundleCacheFilesGetCleanSize, bundleName : %{public}s, userId : %{public}d", + bundleName.c_str(), userId); + + if (!BundlePermissionMgr::IsSystemApp()) { + APP_LOGE("non-system app calling system api"); + return ERR_BUNDLE_MANAGER_SYSTEM_API_DENIED; + } + + if (userId < 0) { + APP_LOGE("userId is invalid"); + EventReport::SendCleanCacheSysEvent(bundleName, userId, true, true); + return ERR_BUNDLE_MANAGER_INVALID_USER_ID; + } + + if (bundleName.empty()) { + APP_LOGE("the bundleName empty"); + EventReport::SendCleanCacheSysEvent(bundleName, userId, true, true); + return ERR_BUNDLE_MANAGER_PARAM_ERROR; + } + + ApplicationInfo applicationInfo; + auto dataMgr = GetDataMgrFromService(); + if (dataMgr == nullptr) { + APP_LOGE("DataMgr is nullptr"); + EventReport::SendCleanCacheSysEvent(bundleName, userId, true, true); + return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR; + } + + auto ret = dataMgr->GetApplicationInfoWithResponseId(bundleName, + static_cast(GetApplicationFlag::GET_APPLICATION_INFO_WITH_DISABLE), userId, applicationInfo); + if (ret != ERR_OK) { + APP_LOGE("can not get application info of %{public}s", bundleName.c_str()); + EventReport::SendCleanCacheSysEvent(bundleName, userId, true, true); + return ret; + } + + if (!applicationInfo.userDataClearable) { + APP_LOGE("can not clean cacheFiles of %{public}s due to userDataClearable is false", bundleName.c_str()); + EventReport::SendCleanCacheSysEvent(bundleName, userId, true, true); + return ERR_BUNDLE_MANAGER_CAN_NOT_CLEAR_USER_DATA; + } + + CleanBundleCacheTaskGetCleanSize(bundleName, dataMgr, userId, cleanCacheSize); + return ERR_OK; +} + +void BundleMgrHostImpl::CleanBundleCacheTaskGetCleanSize(const std::string &bundleName, + const std::shared_ptr &dataMgr, + int32_t userId, uint64_t &cleanCacheSize) +{ + std::vector rootDir; + for (const auto &el : ServiceConstants::BUNDLE_EL) { + std::string dataDir = ServiceConstants::BUNDLE_APP_DATA_BASE_DIR + el + + ServiceConstants::PATH_SEPARATOR + std::to_string(userId) + ServiceConstants::BASE + bundleName; + rootDir.emplace_back(dataDir); + } + + auto cleanCache = [bundleName, userId, &cleanCacheSize, rootDir, dataMgr, this]() { + std::vector caches; + for (const auto &st : rootDir) { + std::vector cache; + if (InstalldClient::GetInstance()->GetBundleCachePath(st, cache) != ERR_OK) { + APP_LOGE("GetBundleCachePath failed, path: %{public}s", st.c_str()); + } + std::copy(cache.begin(), cache.end(), std::back_inserter(caches)); + } + + bool succeed = true; + if (!caches.empty()) { + for (const auto& cache : caches) { + cleanCacheSize += BundleUtil::GetTotalSizeOfFilesInDirectory(cache); + ErrCode ret = InstalldClient::GetInstance()->CleanBundleDataDir(cache); + if (ret != ERR_OK) { + APP_LOGE("CleanBundleDataDir failed, path: %{private}s", cache.c_str()); + succeed = false; + } + } + } + EventReport::SendCleanCacheSysEvent(bundleName, userId, true, !succeed); + APP_LOGE("CleanBundleCacheFiles with succeed %{public}d", succeed); + InnerBundleUserInfo innerBundleUserInfo; + if (!this->GetBundleUserInfo(bundleName, userId, innerBundleUserInfo)) { + APP_LOGE("Get calling userInfo in bundle(%{public}s) failed", bundleName.c_str()); + return; + } + NotifyBundleEvents installRes = { + .bundleName = bundleName, + .resultCode = ERR_OK, + .type = NotifyType::BUNDLE_CACHE_CLEARED, + .uid = innerBundleUserInfo.uid, + .accessTokenId = innerBundleUserInfo.accessTokenId + }; + NotifyBundleStatus(installRes); + }; + ffrt::submit(cleanCache); +} + ErrCode BundleMgrHostImpl::CleanBundleCacheFiles( const std::string &bundleName, const sptr cleanCacheCallback, int32_t userId) diff --git a/services/bundlemgr/src/bundle_util.cpp b/services/bundlemgr/src/bundle_util.cpp index 05b7951ff..c587592bb 100644 --- a/services/bundlemgr/src/bundle_util.cpp +++ b/services/bundlemgr/src/bundle_util.cpp @@ -703,6 +703,46 @@ int64_t BundleUtil::GetFileSize(const std::string &filePath) return fileInfo.st_size; } +void BundleUtil::GetTotalSizeOfFiles(const std::string& path, off_t &totalSize) +{ + struct stat fileStat; + if (stat(path.c_str(), &fileStat) == 0) { + if (S_ISREG(fileStat.st_mode)) { + totalSize += fileStat.st_size; + } else if (S_ISDIR(fileStat.st_mode)) { + totalSize += GetTotalSizeOfFilesInDirectory(path); + } + } else { + APP_LOGE("Error getting information for file/directory: %{public}s", path.c_str()); + } +} + +uint64_t BundleUtil::GetTotalSizeOfFilesInDirectory(const std::string& directoryPath) +{ + DIR* dir; + struct dirent* ent; + off_t totalSize = 0; + + APP_LOGI("GetTotalSizeOfFilesInDirectory directoryPath: %{public}s", directoryPath.c_str()); + + if ((dir = opendir(directoryPath.c_str())) != NULL) { + while ((ent = readdir(dir)) != NULL) { + std::string path = directoryPath + "/" + ent->d_name; + + if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) { + continue; + } + + GetTotalSizeOfFiles(path, totalSize); + } + closedir(dir); + } else { + APP_LOGE("opendir failed, path: %{public}s", directoryPath.c_str()); + } + + return static_cast(totalSize); +} + std::string BundleUtil::CopyFileToSecurityDir(const std::string &filePath, const DirType &dirType, std::vector &toDeletePaths) { From 04a6c8f1b56a1afb9b7f06816245154015afbb8b Mon Sep 17 00:00:00 2001 From: 18710539902 Date: Wed, 22 May 2024 16:49:23 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E6=8F=90=E4=BE=9Bcache=E7=A9=BA=E9=97=B4?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=B8=85=E7=90=86=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 18710539902 --- .../bms_ability_manager_helper_test/BUILD.gn | 2 + .../bms_bundle_accesstokenid_test/BUILD.gn | 2 + .../unittest/bms_bundle_aot_test/BUILD.gn | 2 + .../bms_bundle_app_control_test/BUILD.gn | 4 ++ .../BUILD.gn | 2 + .../bms_bundle_clone_app_test/BUILD.gn | 4 ++ .../unittest/bms_bundle_common_test/BUILD.gn | 2 + .../bms_bundle_crowdtesting_test/BUILD.gn | 2 + .../bms_bundle_data_group_test/BUILD.gn | 2 + .../bms_bundle_default_app_test/BUILD.gn | 2 + .../bms_bundle_dependencies_test/BUILD.gn | 2 + .../bms_bundle_hap_verify_test/BUILD.gn | 2 + .../unittest/bms_bundle_hsp_test/BUILD.gn | 6 ++ .../BUILD.gn | 2 + .../bms_bundle_installer_test/BUILD.gn | 18 +++++ .../bms_bundle_installers_test/BUILD.gn | 2 + .../bms_bundle_kit_service_base_test/BUILD.gn | 2 + .../bms_bundle_kit_service_test/BUILD.gn | 6 ++ .../unittest/bms_bundle_manager_test/BUILD.gn | 2 + .../bms_bundle_navigation_test/BUILD.gn | 2 + .../unittest/bms_bundle_overlay_test/BUILD.gn | 71 +++++++++++++++++++ .../bms_bundle_permission_grant_test/BUILD.gn | 14 ++++ .../BUILD.gn | 2 + .../BUILD.gn | 2 + .../BUILD.gn | 2 + .../BUILD.gn | 2 + .../bms_bundle_quick_fix_query_test/BUILD.gn | 2 + .../BUILD.gn | 2 + .../bms_bundle_quick_fix_test/BUILD.gn | 2 + .../bms_bundle_resource_manager_test/BUILD.gn | 2 + .../bms_bundle_resource_test/BUILD.gn | 2 + .../bms_bundle_sandbox_app_test/BUILD.gn | 4 ++ .../bms_bundle_uninstaller_test/BUILD.gn | 2 + .../unittest/bms_bundle_updater_test/BUILD.gn | 2 + .../bms_bundle_verifymanager_test/BUILD.gn | 2 + .../test/unittest/bms_data_mgr_test/BUILD.gn | 4 ++ .../unittest/bms_event_handler_test/BUILD.gn | 4 ++ .../bms_extend_resource_manager_test/BUILD.gn | 2 + .../unittest/bms_installd_host_test/BUILD.gn | 2 + .../bms_rdb_data_manager_test/BUILD.gn | 2 + .../bms_service_bundle_scan_test/BUILD.gn | 2 + .../bms_service_startup_test/BUILD.gn | 2 + .../unittest/bms_syscap_tool_test/BUILD.gn | 2 + .../bundleinstalldhost_fuzzer/BUILD.gn | 2 + .../bundleinstallerhost_fuzzer/BUILD.gn | 2 + 45 files changed, 205 insertions(+) diff --git a/services/bundlemgr/test/unittest/bms_ability_manager_helper_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_ability_manager_helper_test/BUILD.gn index 9ce5f789e..9c14e8a2d 100644 --- a/services/bundlemgr/test/unittest/bms_ability_manager_helper_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_ability_manager_helper_test/BUILD.gn @@ -53,9 +53,11 @@ ohos_unittest("BmsAbilityManagerHelperTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_accesstokenid_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_accesstokenid_test/BUILD.gn index d87db29c0..12541f1a0 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_accesstokenid_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_accesstokenid_test/BUILD.gn @@ -75,11 +75,13 @@ ohos_unittest("BmsBundleAccessTokenIdTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_aot_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_aot_test/BUILD.gn index 640337642..aaa6e0301 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_aot_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_aot_test/BUILD.gn @@ -63,11 +63,13 @@ ohos_unittest("BmsAOTMgrTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_app_control_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_app_control_test/BUILD.gn index 6ad33ec00..97ee570f1 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_app_control_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_app_control_test/BUILD.gn @@ -67,11 +67,13 @@ ohos_unittest("BmsBundleAppControlTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -216,11 +218,13 @@ ohos_unittest("BmsBundleMockAppControlTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_app_provision_info_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_app_provision_info_test/BUILD.gn index 7dd7cdc28..7ecbafbf2 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_app_provision_info_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_app_provision_info_test/BUILD.gn @@ -65,11 +65,13 @@ ohos_unittest("BmsBundleAppProvisionInfoTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_clone_app_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_clone_app_test/BUILD.gn index 6f09b4396..2272643f6 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_clone_app_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_clone_app_test/BUILD.gn @@ -61,9 +61,11 @@ ohos_unittest("BmsBundleCloneAppBundleLogicTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -264,11 +266,13 @@ ohos_unittest("BmsBundleCloneAppIpcTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_common_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_common_test/BUILD.gn index 27b6f3268..74dbe8938 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_common_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_common_test/BUILD.gn @@ -67,11 +67,13 @@ ohos_unittest("BmsBundleCommonTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_crowdtesting_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_crowdtesting_test/BUILD.gn index 435aba2e9..2e48cd5ac 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_crowdtesting_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_crowdtesting_test/BUILD.gn @@ -65,11 +65,13 @@ ohos_unittest("BmsBundleCrowdtestingTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_data_group_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_data_group_test/BUILD.gn index 94e31b304..043c6fbaa 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_data_group_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_data_group_test/BUILD.gn @@ -54,9 +54,11 @@ ohos_unittest("BmsBundleDataGroupTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_default_app_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_default_app_test/BUILD.gn index 2b69b8728..919e3ce96 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_default_app_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_default_app_test/BUILD.gn @@ -63,11 +63,13 @@ ohos_unittest("BmsBundleDefaultAppTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_dependencies_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_dependencies_test/BUILD.gn index 4c9156e7b..ad8076043 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_dependencies_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_dependencies_test/BUILD.gn @@ -66,11 +66,13 @@ ohos_unittest("BmsBundleDependenciesTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_hap_verify_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_hap_verify_test/BUILD.gn index dc8315344..4093e9f23 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_hap_verify_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_hap_verify_test/BUILD.gn @@ -61,11 +61,13 @@ ohos_unittest("BmsBundleHapVerifyTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_hsp_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_hsp_test/BUILD.gn index b178bec88..602d6289b 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_hsp_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_hsp_test/BUILD.gn @@ -68,11 +68,13 @@ ohos_unittest("BmsBundleHspTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -221,11 +223,13 @@ ohos_unittest("BmsBundleSharedLibraryInstallTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -369,11 +373,13 @@ ohos_unittest("BmsBundleSharedLibraryUninstallTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_installer_manager_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_installer_manager_test/BUILD.gn index c834c4171..1ae27c89d 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_installer_manager_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_installer_manager_test/BUILD.gn @@ -63,11 +63,13 @@ ohos_unittest("BmsBundleInstallerManagerTest") { external_deps = [ "ability_base:want", "ability_runtime:ability_manager", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_installer_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_installer_test/BUILD.gn index cff859631..4797ba850 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_installer_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_installer_test/BUILD.gn @@ -77,11 +77,13 @@ ohos_unittest("BmsBundleInstallerTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -256,11 +258,13 @@ ohos_unittest("BmsBundleOtaUpdateTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -444,11 +448,13 @@ ohos_unittest("BmsMultipleBundleInstallerTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -597,11 +603,13 @@ ohos_unittest("BmsBundleInstallIpcTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -743,9 +751,11 @@ ohos_unittest("BmsBundleInstallCheckerTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -879,9 +889,11 @@ ohos_unittest("BmsBundleInstallDeviceTypeTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -1016,9 +1028,11 @@ ohos_unittest("BmsSystemBundleInstallerTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -1185,11 +1199,13 @@ ohos_unittest("BmsBundleInstallDriverTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -1342,11 +1358,13 @@ ohos_unittest("BmsBundleAppServiceFwkInstallerTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_installers_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_installers_test/BUILD.gn index 927611ac7..ef2d74ee6 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_installers_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_installers_test/BUILD.gn @@ -56,11 +56,13 @@ ohos_unittest("BmsBundleInstallersTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_kit_service_base_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_kit_service_base_test/BUILD.gn index 61c3e29f1..dc0f28c7b 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_kit_service_base_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_kit_service_base_test/BUILD.gn @@ -63,11 +63,13 @@ ohos_unittest("BmsBundleKitServiceBaseTest") { external_deps = [ "ability_base:want", "ability_runtime:ability_manager", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/BUILD.gn index 3f31a118d..baf0f7c2e 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/BUILD.gn @@ -65,11 +65,13 @@ ohos_unittest("BmsBundleDataMgrTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -228,11 +230,13 @@ ohos_unittest("BmsBundleKitServiceTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -385,11 +389,13 @@ ohos_unittest("BmsBundleGetWindowPropertiesTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_manager_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_manager_test/BUILD.gn index f4d774fa9..b595e9f48 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_manager_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_manager_test/BUILD.gn @@ -61,11 +61,13 @@ ohos_unittest("BmsBundleManagerTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_navigation_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_navigation_test/BUILD.gn index 9e3883928..747f460df 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_navigation_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_navigation_test/BUILD.gn @@ -60,11 +60,13 @@ ohos_unittest("BmsBundleNavigationTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_overlay_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_overlay_test/BUILD.gn index 722db3445..315fbd59d 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_overlay_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_overlay_test/BUILD.gn @@ -74,6 +74,18 @@ ohos_unittest("BmsBundleOverlayCheckerTest") { "safwk:system_ability_fwk", "samgr:samgr_proxy", ] + + external_deps += [ + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "battery_manager:batterysrv_client", + "device_usage_statistics:usagestatsinner", + "display_manager:displaymgr", + "ffrt:libffrt", + "power_manager:powermgr_client", + "syscap_codec:syscap_interface_shared", + ] + external_deps += bundle_install_external_deps if (code_signature_enable) { @@ -161,6 +173,17 @@ ohos_unittest("BmsBundleOverlayInfoTest") { "ipc:ipc_single", ] + external_deps += [ + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "battery_manager:batterysrv_client", + "device_usage_statistics:usagestatsinner", + "display_manager:displaymgr", + "ffrt:libffrt", + "power_manager:powermgr_client", + "syscap_codec:syscap_interface_shared", + ] + if (bundle_framework_power_mgr_enable) { external_deps += aot_external_deps } @@ -249,6 +272,18 @@ ohos_unittest("BmsBundleOverlayIpcTest") { "safwk:system_ability_fwk", "samgr:samgr_proxy", ] + + external_deps += [ + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "battery_manager:batterysrv_client", + "device_usage_statistics:usagestatsinner", + "display_manager:displaymgr", + "ffrt:libffrt", + "power_manager:powermgr_client", + "syscap_codec:syscap_interface_shared", + ] + external_deps += bundle_install_external_deps if (bundle_framework_power_mgr_enable) { @@ -364,6 +399,18 @@ ohos_unittest("BmsBundleManagerOverlayIpcTest") { "safwk:system_ability_fwk", "samgr:samgr_proxy", ] + + external_deps += [ + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "battery_manager:batterysrv_client", + "device_usage_statistics:usagestatsinner", + "display_manager:displaymgr", + "ffrt:libffrt", + "power_manager:powermgr_client", + "syscap_codec:syscap_interface_shared", + ] + external_deps += bundle_install_external_deps if (bundle_framework_power_mgr_enable) { @@ -480,6 +527,18 @@ ohos_unittest("BmsBundleSetOverlayEnabledTest") { "safwk:system_ability_fwk", "samgr:samgr_proxy", ] + + external_deps += [ + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "battery_manager:batterysrv_client", + "device_usage_statistics:usagestatsinner", + "display_manager:displaymgr", + "ffrt:libffrt", + "power_manager:powermgr_client", + "syscap_codec:syscap_interface_shared", + ] + external_deps += bundle_install_external_deps if (bundle_framework_power_mgr_enable) { @@ -596,6 +655,18 @@ ohos_unittest("BmsBundleGetOverlayModuleInfoTest") { "safwk:system_ability_fwk", "samgr:samgr_proxy", ] + + external_deps += [ + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "battery_manager:batterysrv_client", + "device_usage_statistics:usagestatsinner", + "display_manager:displaymgr", + "ffrt:libffrt", + "power_manager:powermgr_client", + "syscap_codec:syscap_interface_shared", + ] + external_deps += bundle_install_external_deps if (bundle_framework_power_mgr_enable) { diff --git a/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/BUILD.gn index b56d10073..21372fcf7 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/BUILD.gn @@ -79,11 +79,13 @@ ohos_unittest("BmsBundlePermissionDefListTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -243,11 +245,13 @@ ohos_unittest("BmsBundlePermissionGrantTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -405,11 +409,13 @@ ohos_unittest("BmsBundlePermissionFalseTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -573,11 +579,13 @@ ohos_unittest("BmsBundlePermissionStartFullTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -740,11 +748,13 @@ ohos_unittest("BmsBundlePermissionSyetemAppFalseTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -905,11 +915,13 @@ ohos_unittest("BmsBundlePermissionTokenTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -1061,9 +1073,11 @@ ohos_unittest("BmsBundlePermissionGetRequestTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_boot_scanner_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_boot_scanner_test/BUILD.gn index 08c4f07bc..9c9521ecd 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_boot_scanner_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_boot_scanner_test/BUILD.gn @@ -63,11 +63,13 @@ ohos_unittest("BmsBundleQuickFixBootScannerTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_deleter_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_deleter_test/BUILD.gn index 24ddeaed4..86d1ce4c2 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_deleter_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_deleter_test/BUILD.gn @@ -65,11 +65,13 @@ ohos_unittest("BmsBundleQuickFixDeleterTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_manager_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_manager_test/BUILD.gn index 15d582bbb..60b2dc5a8 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_manager_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_manager_test/BUILD.gn @@ -63,11 +63,13 @@ ohos_unittest("BmsBundleQuickFixManagerTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_mgr_rdb_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_mgr_rdb_test/BUILD.gn index 3724e59f8..9bedd5d1c 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_mgr_rdb_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_mgr_rdb_test/BUILD.gn @@ -71,11 +71,13 @@ ohos_unittest("BmsBundleQuickFixMgrRdbTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_query_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_query_test/BUILD.gn index 7e23bf31b..e5b33d6b4 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_query_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_query_test/BUILD.gn @@ -53,9 +53,11 @@ ohos_unittest("BmsBundleQuickFixQueryTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_switcher_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_switcher_test/BUILD.gn index 3d501849f..0d540589c 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_switcher_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_switcher_test/BUILD.gn @@ -65,11 +65,13 @@ ohos_unittest("BmsBundleQuickFixSwitcherTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/BUILD.gn index 9e9da1e5f..c582c839e 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/BUILD.gn @@ -63,11 +63,13 @@ ohos_unittest("BmsBundleQuickFixTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_resource_manager_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_resource_manager_test/BUILD.gn index d7653f57f..ffd844c48 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_resource_manager_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_resource_manager_test/BUILD.gn @@ -64,11 +64,13 @@ ohos_unittest("BmsBundleResourceManagerTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_resource_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_resource_test/BUILD.gn index a2b01e072..211cb356e 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_resource_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_resource_test/BUILD.gn @@ -68,11 +68,13 @@ ohos_unittest("BmsBundleResourceTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_sandbox_app_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_sandbox_app_test/BUILD.gn index cfd45c4bc..7661ea230 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_sandbox_app_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_sandbox_app_test/BUILD.gn @@ -62,11 +62,13 @@ ohos_unittest("BmsSandboxAppTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -218,11 +220,13 @@ ohos_unittest("BmsSandboxRdbTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/BUILD.gn index 3dd8bf8b3..1150b3336 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/BUILD.gn @@ -77,11 +77,13 @@ ohos_unittest("BmsBundleUninstallerTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_updater_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_updater_test/BUILD.gn index e611e551a..f460dc853 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_updater_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_updater_test/BUILD.gn @@ -81,11 +81,13 @@ ohos_unittest("BmsBundleUpdaterTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_verifymanager_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_verifymanager_test/BUILD.gn index 881ee8b8c..89576d71c 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_verifymanager_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_verifymanager_test/BUILD.gn @@ -64,11 +64,13 @@ ohos_unittest("BmsBundleVerifyManagerTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_data_mgr_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_data_mgr_test/BUILD.gn index 42ad5c091..f96818a54 100644 --- a/services/bundlemgr/test/unittest/bms_data_mgr_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_data_mgr_test/BUILD.gn @@ -54,9 +54,11 @@ ohos_unittest("BmsDataMgrTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -177,9 +179,11 @@ ohos_unittest("BmsExtensionDataMgrTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", + "battery_manager:batterysrv_client", "bundle_framework:appexecfwk_core", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", diff --git a/services/bundlemgr/test/unittest/bms_event_handler_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_event_handler_test/BUILD.gn index 61ed54de3..ad428f3a7 100644 --- a/services/bundlemgr/test/unittest/bms_event_handler_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_event_handler_test/BUILD.gn @@ -41,9 +41,11 @@ ohos_unittest("BmsEventHandlerTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -150,9 +152,11 @@ ohos_unittest("BmsEventHandlerUnLockedTest") { deps += bundle_install_deps external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_extend_resource_manager_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_extend_resource_manager_test/BUILD.gn index 62d2d83ca..47fd7758e 100644 --- a/services/bundlemgr/test/unittest/bms_extend_resource_manager_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_extend_resource_manager_test/BUILD.gn @@ -66,11 +66,13 @@ ohos_unittest("BmsExtendResourceManagerTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_installd_host_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_installd_host_test/BUILD.gn index 2cbac25b0..40552dbc9 100644 --- a/services/bundlemgr/test/unittest/bms_installd_host_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_installd_host_test/BUILD.gn @@ -62,11 +62,13 @@ ohos_unittest("BmsInstalldHostTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_rdb_data_manager_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_rdb_data_manager_test/BUILD.gn index f57b82ad1..9fe7e21e9 100755 --- a/services/bundlemgr/test/unittest/bms_rdb_data_manager_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_rdb_data_manager_test/BUILD.gn @@ -61,10 +61,12 @@ ohos_unittest("BmsRdbDataManagerTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:libaccesstoken_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_service_bundle_scan_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_service_bundle_scan_test/BUILD.gn index aa107b83e..6158e024c 100644 --- a/services/bundlemgr/test/unittest/bms_service_bundle_scan_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_service_bundle_scan_test/BUILD.gn @@ -51,9 +51,11 @@ ohos_unittest("BmsServiceBundleScanTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_service_startup_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_service_startup_test/BUILD.gn index dba0064eb..88adc7356 100644 --- a/services/bundlemgr/test/unittest/bms_service_startup_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_service_startup_test/BUILD.gn @@ -47,9 +47,11 @@ ohos_unittest("BmsServiceStartupTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_syscap_tool_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_syscap_tool_test/BUILD.gn index e00a53dde..b49c4ea19 100755 --- a/services/bundlemgr/test/unittest/bms_syscap_tool_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_syscap_tool_test/BUILD.gn @@ -55,11 +55,13 @@ ohos_unittest("BmsSyscapToolTest") { external_deps = [ "ability_base:want", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/test/fuzztest/fuzztest_application/bundleinstalldhost_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_application/bundleinstalldhost_fuzzer/BUILD.gn index e06ddbfa4..ffb859b08 100644 --- a/test/fuzztest/fuzztest_application/bundleinstalldhost_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_application/bundleinstalldhost_fuzzer/BUILD.gn @@ -61,11 +61,13 @@ ohos_fuzztest("BundleInstalldHostFuzzTest") { external_deps = [ "ability_runtime:ability_manager", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "c_utils:utils", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", diff --git a/test/fuzztest/fuzztest_application/bundleinstallerhost_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_application/bundleinstallerhost_fuzzer/BUILD.gn index 9a1d0f6c7..e9fdbcbba 100644 --- a/test/fuzztest/fuzztest_application/bundleinstallerhost_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_application/bundleinstallerhost_fuzzer/BUILD.gn @@ -61,11 +61,13 @@ ohos_fuzztest("BundleInstallerHostFuzzTest") { external_deps = [ "ability_runtime:ability_manager", + "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", + "battery_manager:batterysrv_client", "c_utils:utils", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", From 9f51d97130f585ec2df214d391bf25435d287471 Mon Sep 17 00:00:00 2001 From: 18710539902 Date: Wed, 22 May 2024 19:55:05 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E6=8F=90=E4=BE=9Bcache=E7=A9=BA=E9=97=B4?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=B8=85=E7=90=86=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 18710539902 --- services/bundlemgr/src/bundle_mgr_host_impl.cpp | 6 +++--- .../bundleinstalldhost_fuzzer/BUILD.gn | 14 ++++++++++++-- .../bundleinstallerhost_fuzzer/BUILD.gn | 14 ++++++++++++-- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/services/bundlemgr/src/bundle_mgr_host_impl.cpp b/services/bundlemgr/src/bundle_mgr_host_impl.cpp index 4c2a0b01f..31d1e1f11 100644 --- a/services/bundlemgr/src/bundle_mgr_host_impl.cpp +++ b/services/bundlemgr/src/bundle_mgr_host_impl.cpp @@ -1262,6 +1262,7 @@ ErrCode BundleMgrHostImpl::CleanBundleCacheFilesAutomatic(uint64_t cacheSize) return ERR_BUNDLE_MANAGER_PERMISSION_DENIED; } + // Get current active userId int32_t currentUserId = AccountHelper::GetCurrentActiveUserId(); APP_LOGI("current active userId is %{public}d", currentUserId); if (currentUserId == Constants::INVALID_USERID) { @@ -1276,8 +1277,7 @@ ErrCode BundleMgrHostImpl::CleanBundleCacheFilesAutomatic(uint64_t cacheSize) return ERR_BUNDLE_MANAGER_INTERNAL_ERROR; } - // all apps under the current active user - std::vector currentUserBundleNames; + std::vector currentUserBundleNames; // All apps under the current active user if (!dataMgr->GetBundleList(currentUserBundleNames, currentUserId)) { APP_LOGE("get bundle list failed by currentUserId(%{public}d)", currentUserId); return ERR_BUNDLE_MANAGER_GET_BUNDLE_LIST_FAILED; @@ -1344,9 +1344,9 @@ ErrCode BundleMgrHostImpl::CleanBundleCacheFilesAutomatic(uint64_t cacheSize) return ERR_BUNDLE_MANAGER_ALL_UNUSED_BUNDLES_USAGE_TIME_ARE_EMPTY; } - uint64_t cleanCacheSize = 0; // The cache size of a single application cleaned up uint64_t cleanCacheSum = 0; // The total amount of application cache currently cleaned for (const auto& bundleMap : bundleUseTimeMap) { + uint64_t cleanCacheSize = 0; // The cache size of a single application cleaned up ErrCode ret = CleanBundleCacheFilesGetCleanSize(bundleMap.second, currentUserId, cleanCacheSize); if (ret != ERR_OK) { return ret; diff --git a/test/fuzztest/fuzztest_application/bundleinstalldhost_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_application/bundleinstalldhost_fuzzer/BUILD.gn index ffb859b08..19e24a0a7 100644 --- a/test/fuzztest/fuzztest_application/bundleinstalldhost_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_application/bundleinstalldhost_fuzzer/BUILD.gn @@ -61,13 +61,11 @@ ohos_fuzztest("BundleInstalldHostFuzzTest") { external_deps = [ "ability_runtime:ability_manager", - "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "c_utils:utils", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", @@ -78,6 +76,18 @@ ohos_fuzztest("BundleInstalldHostFuzzTest") { "safwk:system_ability_fwk", "samgr:samgr_proxy", ] + + external_deps += [ + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "battery_manager:batterysrv_client", + "device_usage_statistics:usagestatsinner", + "display_manager:displaymgr", + "ffrt:libffrt", + "power_manager:powermgr_client", + "syscap_codec:syscap_interface_shared", + ] + external_deps += bundle_install_external_deps if (bundle_framework_power_mgr_enable) { diff --git a/test/fuzztest/fuzztest_application/bundleinstallerhost_fuzzer/BUILD.gn b/test/fuzztest/fuzztest_application/bundleinstallerhost_fuzzer/BUILD.gn index e9fdbcbba..369636255 100644 --- a/test/fuzztest/fuzztest_application/bundleinstallerhost_fuzzer/BUILD.gn +++ b/test/fuzztest/fuzztest_application/bundleinstallerhost_fuzzer/BUILD.gn @@ -61,13 +61,11 @@ ohos_fuzztest("BundleInstallerHostFuzzTest") { external_deps = [ "ability_runtime:ability_manager", - "ability_runtime:app_manager", "access_token:el5_filekey_manager_sdk", "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "c_utils:utils", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", @@ -78,6 +76,18 @@ ohos_fuzztest("BundleInstallerHostFuzzTest") { "safwk:system_ability_fwk", "samgr:samgr_proxy", ] + + external_deps += [ + "ability_runtime:ability_manager", + "ability_runtime:app_manager", + "battery_manager:batterysrv_client", + "device_usage_statistics:usagestatsinner", + "display_manager:displaymgr", + "ffrt:libffrt", + "power_manager:powermgr_client", + "syscap_codec:syscap_interface_shared", + ] + external_deps += bundle_install_external_deps if (bundle_framework_power_mgr_enable) { From ff5274dbe35b14b670cfdbd472cbae71de73aad3 Mon Sep 17 00:00:00 2001 From: 18710539902 Date: Wed, 22 May 2024 23:38:24 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E6=8F=90=E4=BE=9Bcache=E7=A9=BA=E9=97=B4?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=B8=85=E7=90=86=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 18710539902 --- .../include/appexecfwk_errors.h | 4 +- .../bundlemgr/src/bundle_mgr_host_impl.cpp | 82 +++++++------------ .../bms_ability_manager_helper_test/BUILD.gn | 1 - .../bms_bundle_accesstokenid_test/BUILD.gn | 1 - .../unittest/bms_bundle_aot_test/BUILD.gn | 1 - .../bms_bundle_app_control_test/BUILD.gn | 2 - .../BUILD.gn | 1 - .../bms_bundle_clone_app_test/BUILD.gn | 2 - .../unittest/bms_bundle_common_test/BUILD.gn | 1 - .../bms_bundle_crowdtesting_test/BUILD.gn | 1 - .../bms_bundle_data_group_test/BUILD.gn | 1 - .../bms_bundle_default_app_test/BUILD.gn | 1 - .../bms_bundle_dependencies_test/BUILD.gn | 1 - .../bms_bundle_hap_verify_test/BUILD.gn | 1 - .../unittest/bms_bundle_hsp_test/BUILD.gn | 3 - .../BUILD.gn | 1 - .../bms_bundle_installer_test/BUILD.gn | 9 -- .../bms_bundle_installers_test/BUILD.gn | 1 - .../bms_bundle_kit_service_base_test/BUILD.gn | 1 - .../bms_bundle_kit_service_test/BUILD.gn | 1 - .../unittest/bms_bundle_manager_test/BUILD.gn | 1 - .../bms_bundle_navigation_test/BUILD.gn | 1 - .../bms_bundle_permission_grant_test/BUILD.gn | 7 -- .../BUILD.gn | 1 - .../BUILD.gn | 1 - .../BUILD.gn | 1 - .../BUILD.gn | 1 - .../bms_bundle_quick_fix_query_test/BUILD.gn | 1 - .../BUILD.gn | 1 - .../bms_bundle_quick_fix_test/BUILD.gn | 1 - .../bms_bundle_resource_manager_test/BUILD.gn | 1 - .../bms_bundle_resource_test/BUILD.gn | 1 - .../bms_bundle_sandbox_app_test/BUILD.gn | 2 - .../bms_bundle_uninstaller_test/BUILD.gn | 1 - .../unittest/bms_bundle_updater_test/BUILD.gn | 1 - .../bms_bundle_verifymanager_test/BUILD.gn | 1 - .../test/unittest/bms_data_mgr_test/BUILD.gn | 2 - .../unittest/bms_event_handler_test/BUILD.gn | 2 - .../bms_extend_resource_manager_test/BUILD.gn | 1 - .../unittest/bms_installd_host_test/BUILD.gn | 1 - .../bms_rdb_data_manager_test/BUILD.gn | 1 - .../bms_service_bundle_scan_test/BUILD.gn | 1 - .../bms_service_startup_test/BUILD.gn | 1 - .../unittest/bms_syscap_tool_test/BUILD.gn | 1 - 44 files changed, 29 insertions(+), 120 deletions(-) diff --git a/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h b/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h index c56abc8b3..11bfb3b86 100644 --- a/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h +++ b/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h @@ -385,9 +385,7 @@ enum { ERR_BUNDLE_MANAGER_NOT_APP_GALLERY_CALL = 8521250, ERR_BUNDLE_MANAGER_GET_SYSTEM_ABILITY_FAILED = 8521251, ERR_BUNDLE_MANAGER_GET_ALL_RUNNING_PROCESSES_FAILED = 8521252, - ERR_BUNDLE_MANAGER_GET_BUNDLE_LIST_FAILED = 8521253, - ERR_BUNDLE_MANAGER_ALL_BUNDLES_ARE_RUNNING = 8521254, - ERR_BUNDLE_MANAGER_ALL_UNUSED_BUNDLES_USAGE_TIME_ARE_EMPTY = 8521255, + ERR_BUNDLE_MANAGER_DEVICE_USAGE_STATS_EMPTY = 8521253, // app jump interceptor ERR_BUNDLE_MANAGER_APP_JUMP_INTERCEPTOR_INTERNAL_ERROR = APPEXECFWK_BUNDLEMGR_ERR_OFFSET + 0x0701, // 8521473 diff --git a/services/bundlemgr/src/bundle_mgr_host_impl.cpp b/services/bundlemgr/src/bundle_mgr_host_impl.cpp index 31d1e1f11..8c464e699 100644 --- a/services/bundlemgr/src/bundle_mgr_host_impl.cpp +++ b/services/bundlemgr/src/bundle_mgr_host_impl.cpp @@ -1270,18 +1270,25 @@ ErrCode BundleMgrHostImpl::CleanBundleCacheFilesAutomatic(uint64_t cacheSize) return ERR_BUNDLE_MANAGER_INVALID_USER_ID; } - // Get all apps under the current active user - auto dataMgr = GetDataMgrFromService(); - if (dataMgr == nullptr) { - APP_LOGE("DataMgr is nullptr"); - return ERR_BUNDLE_MANAGER_INTERNAL_ERROR; + // Get apps use time under the current active user + int64_t startTime = 0; + int64_t endTime = BundleUtil::GetCurrentTimeMs(); + const int32_t PERIOD_ANNUALLY = 4; + std::vector useStats; + DeviceUsageStats::BundleActiveClient::GetInstance().QueryBundleStatsInfoByInterval( + useStats, PERIOD_ANNUALLY, startTime, endTime, currentUserId); + + if (useStats.empty()) { + APP_LOGE("useStats under the current active user is empty"); + return ERR_BUNDLE_MANAGER_DEVICE_USAGE_STATS_EMPTY; } - std::vector currentUserBundleNames; // All apps under the current active user - if (!dataMgr->GetBundleList(currentUserBundleNames, currentUserId)) { - APP_LOGE("get bundle list failed by currentUserId(%{public}d)", currentUserId); - return ERR_BUNDLE_MANAGER_GET_BUNDLE_LIST_FAILED; - } + // Sort apps use time from small to large under the current active user + std::sort(useStats.begin(), useStats.end(), + [](DeviceUsageStats::BundleActivePackageStats a, + DeviceUsageStats::BundleActivePackageStats b) { + return a.totalInFrontTime_ < b.totalInFrontTime_; + }); // Get all running apps sptr appMgrProxy = @@ -1298,10 +1305,10 @@ ErrCode BundleMgrHostImpl::CleanBundleCacheFilesAutomatic(uint64_t cacheSize) return ERR_BUNDLE_MANAGER_GET_ALL_RUNNING_PROCESSES_FAILED; } - // All apps that are not running under the current active user - std::vector currentUserNotRunningBundleNames; - for (auto bundleName : currentUserBundleNames) { + uint64_t cleanCacheSum = 0; // The total amount of application cache currently cleaned + for (auto useStat : useStats) { bool isRunning = false; + std::string bundleName = useStat.bundleName_; for (const auto &info : runningList) { auto res = std::any_of(info.bundleNames.begin(), info.bundleNames.end(), [bundleName](const auto &bundleNameInRunningProcessInfo) { @@ -1312,48 +1319,15 @@ ErrCode BundleMgrHostImpl::CleanBundleCacheFilesAutomatic(uint64_t cacheSize) } } if (!isRunning) { - currentUserNotRunningBundleNames.push_back(bundleName); - } - } - - if (currentUserNotRunningBundleNames.empty()) { - APP_LOGE("All apps are running under the current active user"); - return ERR_BUNDLE_MANAGER_ALL_BUNDLES_ARE_RUNNING; - } - - // Get apps use time - int64_t startTime = 0; - int64_t endTime = BundleUtil::GetCurrentTimeMs(); - const int32_t PERIOD_ANNUALLY = 4; - std::vector useStats; - DeviceUsageStats::BundleActiveClient::GetInstance().QueryBundleStatsInfoByInterval( - useStats, PERIOD_ANNUALLY, startTime, endTime, currentUserId); - - // Sort apps use time from small to large - std::map bundleUseTimeMap; - for (auto bundleName : currentUserNotRunningBundleNames) { - for (auto useStat : useStats) { - if (bundleName == useStat.bundleName_) { - bundleUseTimeMap.insert(make_pair(useStat.totalInFrontTime_, bundleName)); + uint64_t cleanCacheSize = 0; // The cache size of a single application cleaned up + ErrCode ret = CleanBundleCacheFilesGetCleanSize(bundleName, currentUserId, cleanCacheSize); + if (ret != ERR_OK) { + return ret; + } + cleanCacheSum += cleanCacheSize; + if (cleanCacheSum >= cacheSize) { + return ERR_OK; } - } - } - - if (bundleUseTimeMap.empty()) { - APP_LOGE("the current active user all unused apps usage time are empty"); - return ERR_BUNDLE_MANAGER_ALL_UNUSED_BUNDLES_USAGE_TIME_ARE_EMPTY; - } - - uint64_t cleanCacheSum = 0; // The total amount of application cache currently cleaned - for (const auto& bundleMap : bundleUseTimeMap) { - uint64_t cleanCacheSize = 0; // The cache size of a single application cleaned up - ErrCode ret = CleanBundleCacheFilesGetCleanSize(bundleMap.second, currentUserId, cleanCacheSize); - if (ret != ERR_OK) { - return ret; - } - cleanCacheSum += cleanCacheSize; - if (cleanCacheSum >= cacheSize) { - return ERR_OK; } } diff --git a/services/bundlemgr/test/unittest/bms_ability_manager_helper_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_ability_manager_helper_test/BUILD.gn index 9c14e8a2d..44f98b6b0 100644 --- a/services/bundlemgr/test/unittest/bms_ability_manager_helper_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_ability_manager_helper_test/BUILD.gn @@ -57,7 +57,6 @@ ohos_unittest("BmsAbilityManagerHelperTest") { "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_accesstokenid_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_accesstokenid_test/BUILD.gn index 12541f1a0..20a3505b6 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_accesstokenid_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_accesstokenid_test/BUILD.gn @@ -81,7 +81,6 @@ ohos_unittest("BmsBundleAccessTokenIdTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_aot_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_aot_test/BUILD.gn index aaa6e0301..81f4112ad 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_aot_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_aot_test/BUILD.gn @@ -69,7 +69,6 @@ ohos_unittest("BmsAOTMgrTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_app_control_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_app_control_test/BUILD.gn index 97ee570f1..b61b6eb28 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_app_control_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_app_control_test/BUILD.gn @@ -73,7 +73,6 @@ ohos_unittest("BmsBundleAppControlTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -224,7 +223,6 @@ ohos_unittest("BmsBundleMockAppControlTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_app_provision_info_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_app_provision_info_test/BUILD.gn index 7ecbafbf2..243de7e8d 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_app_provision_info_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_app_provision_info_test/BUILD.gn @@ -71,7 +71,6 @@ ohos_unittest("BmsBundleAppProvisionInfoTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_clone_app_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_clone_app_test/BUILD.gn index 2272643f6..28075b542 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_clone_app_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_clone_app_test/BUILD.gn @@ -65,7 +65,6 @@ ohos_unittest("BmsBundleCloneAppBundleLogicTest") { "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -272,7 +271,6 @@ ohos_unittest("BmsBundleCloneAppIpcTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_common_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_common_test/BUILD.gn index 74dbe8938..04c23a7b8 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_common_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_common_test/BUILD.gn @@ -73,7 +73,6 @@ ohos_unittest("BmsBundleCommonTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_crowdtesting_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_crowdtesting_test/BUILD.gn index 2e48cd5ac..71e4c0b0d 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_crowdtesting_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_crowdtesting_test/BUILD.gn @@ -71,7 +71,6 @@ ohos_unittest("BmsBundleCrowdtestingTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_data_group_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_data_group_test/BUILD.gn index 043c6fbaa..2f6888132 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_data_group_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_data_group_test/BUILD.gn @@ -58,7 +58,6 @@ ohos_unittest("BmsBundleDataGroupTest") { "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_default_app_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_default_app_test/BUILD.gn index 919e3ce96..247d0c639 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_default_app_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_default_app_test/BUILD.gn @@ -69,7 +69,6 @@ ohos_unittest("BmsBundleDefaultAppTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_dependencies_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_dependencies_test/BUILD.gn index ad8076043..2e8949a74 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_dependencies_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_dependencies_test/BUILD.gn @@ -72,7 +72,6 @@ ohos_unittest("BmsBundleDependenciesTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_hap_verify_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_hap_verify_test/BUILD.gn index 4093e9f23..a5c768841 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_hap_verify_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_hap_verify_test/BUILD.gn @@ -67,7 +67,6 @@ ohos_unittest("BmsBundleHapVerifyTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_hsp_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_hsp_test/BUILD.gn index 602d6289b..2e6f78d5c 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_hsp_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_hsp_test/BUILD.gn @@ -74,7 +74,6 @@ ohos_unittest("BmsBundleHspTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -229,7 +228,6 @@ ohos_unittest("BmsBundleSharedLibraryInstallTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -379,7 +377,6 @@ ohos_unittest("BmsBundleSharedLibraryUninstallTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_installer_manager_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_installer_manager_test/BUILD.gn index 1ae27c89d..a0b3ab986 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_installer_manager_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_installer_manager_test/BUILD.gn @@ -69,7 +69,6 @@ ohos_unittest("BmsBundleInstallerManagerTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_installer_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_installer_test/BUILD.gn index 4797ba850..7dbeb7271 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_installer_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_installer_test/BUILD.gn @@ -83,7 +83,6 @@ ohos_unittest("BmsBundleInstallerTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -264,7 +263,6 @@ ohos_unittest("BmsBundleOtaUpdateTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -454,7 +452,6 @@ ohos_unittest("BmsMultipleBundleInstallerTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -609,7 +606,6 @@ ohos_unittest("BmsBundleInstallIpcTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -755,7 +751,6 @@ ohos_unittest("BmsBundleInstallCheckerTest") { "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -893,7 +888,6 @@ ohos_unittest("BmsBundleInstallDeviceTypeTest") { "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -1032,7 +1026,6 @@ ohos_unittest("BmsSystemBundleInstallerTest") { "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -1205,7 +1198,6 @@ ohos_unittest("BmsBundleInstallDriverTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -1364,7 +1356,6 @@ ohos_unittest("BmsBundleAppServiceFwkInstallerTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_installers_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_installers_test/BUILD.gn index ef2d74ee6..bcf460280 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_installers_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_installers_test/BUILD.gn @@ -62,7 +62,6 @@ ohos_unittest("BmsBundleInstallersTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_kit_service_base_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_kit_service_base_test/BUILD.gn index dc0f28c7b..4aa50fa16 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_kit_service_base_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_kit_service_base_test/BUILD.gn @@ -69,7 +69,6 @@ ohos_unittest("BmsBundleKitServiceBaseTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/BUILD.gn index baf0f7c2e..d1accc436 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/BUILD.gn @@ -71,7 +71,6 @@ ohos_unittest("BmsBundleDataMgrTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_manager_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_manager_test/BUILD.gn index b595e9f48..ddd506afd 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_manager_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_manager_test/BUILD.gn @@ -67,7 +67,6 @@ ohos_unittest("BmsBundleManagerTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_navigation_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_navigation_test/BUILD.gn index 747f460df..d97cd79cd 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_navigation_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_navigation_test/BUILD.gn @@ -66,7 +66,6 @@ ohos_unittest("BmsBundleNavigationTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/BUILD.gn index 21372fcf7..8bca44507 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_permission_grant_test/BUILD.gn @@ -85,7 +85,6 @@ ohos_unittest("BmsBundlePermissionDefListTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -251,7 +250,6 @@ ohos_unittest("BmsBundlePermissionGrantTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -415,7 +413,6 @@ ohos_unittest("BmsBundlePermissionFalseTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -585,7 +582,6 @@ ohos_unittest("BmsBundlePermissionStartFullTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -754,7 +750,6 @@ ohos_unittest("BmsBundlePermissionSyetemAppFalseTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -921,7 +916,6 @@ ohos_unittest("BmsBundlePermissionTokenTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -1077,7 +1071,6 @@ ohos_unittest("BmsBundlePermissionGetRequestTest") { "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_boot_scanner_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_boot_scanner_test/BUILD.gn index 9c9521ecd..5b2864ade 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_boot_scanner_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_boot_scanner_test/BUILD.gn @@ -69,7 +69,6 @@ ohos_unittest("BmsBundleQuickFixBootScannerTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_deleter_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_deleter_test/BUILD.gn index 86d1ce4c2..106685fbd 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_deleter_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_deleter_test/BUILD.gn @@ -71,7 +71,6 @@ ohos_unittest("BmsBundleQuickFixDeleterTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_manager_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_manager_test/BUILD.gn index 60b2dc5a8..28ea3e943 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_manager_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_manager_test/BUILD.gn @@ -69,7 +69,6 @@ ohos_unittest("BmsBundleQuickFixManagerTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_mgr_rdb_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_mgr_rdb_test/BUILD.gn index 9bedd5d1c..255e501f2 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_mgr_rdb_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_mgr_rdb_test/BUILD.gn @@ -77,7 +77,6 @@ ohos_unittest("BmsBundleQuickFixMgrRdbTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_query_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_query_test/BUILD.gn index e5b33d6b4..3ad911c7b 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_query_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_query_test/BUILD.gn @@ -57,7 +57,6 @@ ohos_unittest("BmsBundleQuickFixQueryTest") { "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_switcher_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_switcher_test/BUILD.gn index 0d540589c..b4ecff1a5 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_switcher_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_switcher_test/BUILD.gn @@ -71,7 +71,6 @@ ohos_unittest("BmsBundleQuickFixSwitcherTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/BUILD.gn index c582c839e..1f8e659d4 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_quick_fix_test/BUILD.gn @@ -69,7 +69,6 @@ ohos_unittest("BmsBundleQuickFixTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_resource_manager_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_resource_manager_test/BUILD.gn index ffd844c48..0dbefe0b3 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_resource_manager_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_resource_manager_test/BUILD.gn @@ -70,7 +70,6 @@ ohos_unittest("BmsBundleResourceManagerTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_resource_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_resource_test/BUILD.gn index 211cb356e..3aa90641d 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_resource_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_resource_test/BUILD.gn @@ -74,7 +74,6 @@ ohos_unittest("BmsBundleResourceTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_sandbox_app_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_sandbox_app_test/BUILD.gn index 7661ea230..1bef12583 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_sandbox_app_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_sandbox_app_test/BUILD.gn @@ -68,7 +68,6 @@ ohos_unittest("BmsSandboxAppTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -226,7 +225,6 @@ ohos_unittest("BmsSandboxRdbTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/BUILD.gn index 1150b3336..fc9ed9864 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_uninstaller_test/BUILD.gn @@ -83,7 +83,6 @@ ohos_unittest("BmsBundleUninstallerTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_updater_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_updater_test/BUILD.gn index f460dc853..c7f9bb6df 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_updater_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_updater_test/BUILD.gn @@ -87,7 +87,6 @@ ohos_unittest("BmsBundleUpdaterTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_bundle_verifymanager_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_verifymanager_test/BUILD.gn index 89576d71c..be2ced188 100755 --- a/services/bundlemgr/test/unittest/bms_bundle_verifymanager_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_verifymanager_test/BUILD.gn @@ -70,7 +70,6 @@ ohos_unittest("BmsBundleVerifyManagerTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_data_mgr_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_data_mgr_test/BUILD.gn index f96818a54..6b1b0d0ac 100644 --- a/services/bundlemgr/test/unittest/bms_data_mgr_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_data_mgr_test/BUILD.gn @@ -58,7 +58,6 @@ ohos_unittest("BmsDataMgrTest") { "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -183,7 +182,6 @@ ohos_unittest("BmsExtensionDataMgrTest") { "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", - "battery_manager:batterysrv_client", "bundle_framework:appexecfwk_core", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", diff --git a/services/bundlemgr/test/unittest/bms_event_handler_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_event_handler_test/BUILD.gn index ad428f3a7..7af02357b 100644 --- a/services/bundlemgr/test/unittest/bms_event_handler_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_event_handler_test/BUILD.gn @@ -45,7 +45,6 @@ ohos_unittest("BmsEventHandlerTest") { "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -156,7 +155,6 @@ ohos_unittest("BmsEventHandlerUnLockedTest") { "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_extend_resource_manager_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_extend_resource_manager_test/BUILD.gn index 47fd7758e..fb8f88fbe 100644 --- a/services/bundlemgr/test/unittest/bms_extend_resource_manager_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_extend_resource_manager_test/BUILD.gn @@ -72,7 +72,6 @@ ohos_unittest("BmsExtendResourceManagerTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_installd_host_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_installd_host_test/BUILD.gn index 40552dbc9..73e019611 100644 --- a/services/bundlemgr/test/unittest/bms_installd_host_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_installd_host_test/BUILD.gn @@ -68,7 +68,6 @@ ohos_unittest("BmsInstalldHostTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_rdb_data_manager_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_rdb_data_manager_test/BUILD.gn index 9fe7e21e9..d6ed81783 100755 --- a/services/bundlemgr/test/unittest/bms_rdb_data_manager_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_rdb_data_manager_test/BUILD.gn @@ -66,7 +66,6 @@ ohos_unittest("BmsRdbDataManagerTest") { "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_service_bundle_scan_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_service_bundle_scan_test/BUILD.gn index 6158e024c..69fdff4f8 100644 --- a/services/bundlemgr/test/unittest/bms_service_bundle_scan_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_service_bundle_scan_test/BUILD.gn @@ -55,7 +55,6 @@ ohos_unittest("BmsServiceBundleScanTest") { "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_service_startup_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_service_startup_test/BUILD.gn index 88adc7356..0b100e5f5 100644 --- a/services/bundlemgr/test/unittest/bms_service_startup_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_service_startup_test/BUILD.gn @@ -51,7 +51,6 @@ ohos_unittest("BmsServiceStartupTest") { "access_token:libprivacy_sdk", "access_token:libtokenid_sdk", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", diff --git a/services/bundlemgr/test/unittest/bms_syscap_tool_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_syscap_tool_test/BUILD.gn index b49c4ea19..af5b24017 100755 --- a/services/bundlemgr/test/unittest/bms_syscap_tool_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_syscap_tool_test/BUILD.gn @@ -61,7 +61,6 @@ ohos_unittest("BmsSyscapToolTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", From 222f297f025721614ad18928b7a81033db3215ac Mon Sep 17 00:00:00 2001 From: 18710539902 Date: Wed, 22 May 2024 23:46:31 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E6=8F=90=E4=BE=9Bcache=E7=A9=BA=E9=97=B4?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=B8=85=E7=90=86=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 18710539902 --- .../test/unittest/bms_bundle_kit_service_test/BUILD.gn | 2 -- 1 file changed, 2 deletions(-) diff --git a/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/BUILD.gn b/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/BUILD.gn index d1accc436..2faaba344 100644 --- a/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/BUILD.gn +++ b/services/bundlemgr/test/unittest/bms_bundle_kit_service_test/BUILD.gn @@ -235,7 +235,6 @@ ohos_unittest("BmsBundleKitServiceTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", @@ -394,7 +393,6 @@ ohos_unittest("BmsBundleGetWindowPropertiesTest") { "access_token:libtokenid_sdk", "appspawn:hnpapi", "appverify:libhapverify", - "battery_manager:batterysrv_client", "common_event_service:cesfwk_innerkits", "eventhandler:libeventhandler", "hilog:libhilog", From 634b917961ea93613aee55320a764e07c9ead74b Mon Sep 17 00:00:00 2001 From: 18710539902 Date: Thu, 23 May 2024 00:51:01 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E6=8F=90=E4=BE=9Bcache=E7=A9=BA=E9=97=B4?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=B8=85=E7=90=86=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 18710539902 --- .../inner_api/appexecfwk_base/include/appexecfwk_errors.h | 1 + services/bundlemgr/src/bundle_mgr_host_impl.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h b/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h index 11bfb3b86..fa1ac97fd 100644 --- a/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h +++ b/interfaces/inner_api/appexecfwk_base/include/appexecfwk_errors.h @@ -386,6 +386,7 @@ enum { ERR_BUNDLE_MANAGER_GET_SYSTEM_ABILITY_FAILED = 8521251, ERR_BUNDLE_MANAGER_GET_ALL_RUNNING_PROCESSES_FAILED = 8521252, ERR_BUNDLE_MANAGER_DEVICE_USAGE_STATS_EMPTY = 8521253, + ERR_BUNDLE_MANAGER_ALL_BUNDLES_ARE_RUNNING = 8521254, // app jump interceptor ERR_BUNDLE_MANAGER_APP_JUMP_INTERCEPTOR_INTERNAL_ERROR = APPEXECFWK_BUNDLEMGR_ERR_OFFSET + 0x0701, // 8521473 diff --git a/services/bundlemgr/src/bundle_mgr_host_impl.cpp b/services/bundlemgr/src/bundle_mgr_host_impl.cpp index 8c464e699..8417cca0b 100644 --- a/services/bundlemgr/src/bundle_mgr_host_impl.cpp +++ b/services/bundlemgr/src/bundle_mgr_host_impl.cpp @@ -1305,6 +1305,7 @@ ErrCode BundleMgrHostImpl::CleanBundleCacheFilesAutomatic(uint64_t cacheSize) return ERR_BUNDLE_MANAGER_GET_ALL_RUNNING_PROCESSES_FAILED; } + uint32_t notRunningSum = 0; // The total amount of application that is not running uint64_t cleanCacheSum = 0; // The total amount of application cache currently cleaned for (auto useStat : useStats) { bool isRunning = false; @@ -1319,6 +1320,7 @@ ErrCode BundleMgrHostImpl::CleanBundleCacheFilesAutomatic(uint64_t cacheSize) } } if (!isRunning) { + notRunningSum++; uint64_t cleanCacheSize = 0; // The cache size of a single application cleaned up ErrCode ret = CleanBundleCacheFilesGetCleanSize(bundleName, currentUserId, cleanCacheSize); if (ret != ERR_OK) { @@ -1331,6 +1333,11 @@ ErrCode BundleMgrHostImpl::CleanBundleCacheFilesAutomatic(uint64_t cacheSize) } } + if (notRunningSum == 0) { + APP_LOGE("All apps are running under the current active user"); + return ERR_BUNDLE_MANAGER_ALL_BUNDLES_ARE_RUNNING; + } + return ERR_OK; } From c3ea4ec21c9555cf4bfba2d7e5126b135cf87b2b Mon Sep 17 00:00:00 2001 From: 18710539902 Date: Thu, 23 May 2024 01:24:41 +0800 Subject: [PATCH 7/8] =?UTF-8?q?=E6=8F=90=E4=BE=9Bcache=E7=A9=BA=E9=97=B4?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=B8=85=E7=90=86=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 18710539902 --- services/bundlemgr/src/bundle_mgr_host_impl.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/services/bundlemgr/src/bundle_mgr_host_impl.cpp b/services/bundlemgr/src/bundle_mgr_host_impl.cpp index 8417cca0b..754d693ea 100644 --- a/services/bundlemgr/src/bundle_mgr_host_impl.cpp +++ b/services/bundlemgr/src/bundle_mgr_host_impl.cpp @@ -1311,11 +1311,8 @@ ErrCode BundleMgrHostImpl::CleanBundleCacheFilesAutomatic(uint64_t cacheSize) bool isRunning = false; std::string bundleName = useStat.bundleName_; for (const auto &info : runningList) { - auto res = std::any_of(info.bundleNames.begin(), info.bundleNames.end(), - [bundleName](const auto &bundleNameInRunningProcessInfo) { - return bundleNameInRunningProcessInfo == bundleName; - }); - if (res) { + std::unordered_set infoSet(info.bundleNames.begin(), info.bundleNames.end()); + if (infoSet.find(bundleName) != infoSet.end()) { isRunning = true; } } From 217d8c4030fc82feb42a351746be3f93df129dbb Mon Sep 17 00:00:00 2001 From: 18710539902 Date: Thu, 23 May 2024 11:25:52 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E6=8F=90=E4=BE=9Bcache=E7=A9=BA=E9=97=B4?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=B8=85=E7=90=86=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 18710539902 --- .../bundlemgr/src/bundle_mgr_host_impl.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/services/bundlemgr/src/bundle_mgr_host_impl.cpp b/services/bundlemgr/src/bundle_mgr_host_impl.cpp index 754d693ea..a19b29891 100644 --- a/services/bundlemgr/src/bundle_mgr_host_impl.cpp +++ b/services/bundlemgr/src/bundle_mgr_host_impl.cpp @@ -1273,7 +1273,7 @@ ErrCode BundleMgrHostImpl::CleanBundleCacheFilesAutomatic(uint64_t cacheSize) // Get apps use time under the current active user int64_t startTime = 0; int64_t endTime = BundleUtil::GetCurrentTimeMs(); - const int32_t PERIOD_ANNUALLY = 4; + const int32_t PERIOD_ANNUALLY = 4; // 4 is the number of the period ANN std::vector useStats; DeviceUsageStats::BundleActiveClient::GetInstance().QueryBundleStatsInfoByInterval( useStats, PERIOD_ANNUALLY, startTime, endTime, currentUserId); @@ -1305,21 +1305,18 @@ ErrCode BundleMgrHostImpl::CleanBundleCacheFilesAutomatic(uint64_t cacheSize) return ERR_BUNDLE_MANAGER_GET_ALL_RUNNING_PROCESSES_FAILED; } + std::unordered_set runningSet; + for (const auto &info : runningList) { + runningSet.insert(info.bundleNames.begin(), info.bundleNames.end()); + } + uint32_t notRunningSum = 0; // The total amount of application that is not running uint64_t cleanCacheSum = 0; // The total amount of application cache currently cleaned for (auto useStat : useStats) { - bool isRunning = false; - std::string bundleName = useStat.bundleName_; - for (const auto &info : runningList) { - std::unordered_set infoSet(info.bundleNames.begin(), info.bundleNames.end()); - if (infoSet.find(bundleName) != infoSet.end()) { - isRunning = true; - } - } - if (!isRunning) { + if (runningSet.find(useStat.bundleName_) == runningSet.end()) { notRunningSum++; uint64_t cleanCacheSize = 0; // The cache size of a single application cleaned up - ErrCode ret = CleanBundleCacheFilesGetCleanSize(bundleName, currentUserId, cleanCacheSize); + ErrCode ret = CleanBundleCacheFilesGetCleanSize(useStat.bundleName_, currentUserId, cleanCacheSize); if (ret != ERR_OK) { return ret; }