1 /* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_CACHE_MGR_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_CACHE_MGR_H 18 19 #include <mutex> 20 #include <vector> 21 22 #include "account_helper.h" 23 #include "app_log_tag_wrapper.h" 24 #include "bundle_data_mgr.h" 25 #include "inner_bundle_clone_common.h" 26 #include "install_param.h" 27 #include "installd_client.h" 28 #include "ipc_skeleton.h" 29 #include "process_cache_callback_interface.h" 30 #include "system_ability_helper.h" 31 32 namespace OHOS { 33 namespace AppExecFwk { 34 class BundleCacheMgr { 35 public: 36 static std::vector<std::string> GetBundleCachePath(const std::string &bundleName, const int32_t userId, 37 const int32_t appIndex, const std::vector<std::string> &moduleNameList); 38 /** 39 * @brief get cache size of all bundle. 40 * @param validBundles indicates the tuple of <bundleName, moduleNames, appCloneIndexes> 41 * @param cacheStat indicates the result of all bundle cache size 42 * @return Returns ERR_OK if get all bundle cache size; returns errCode otherwise. 43 */ 44 static void GetBundleCacheSize(const std::vector<std::tuple<std::string, 45 std::vector<std::string>, std::vector<int32_t>>> &validBundles, 46 const int32_t userId, uint64_t &cacheStat); 47 static ErrCode GetAllBundleCacheStat(const sptr<IProcessCacheCallback> processCacheCallback); 48 static ErrCode CleanBundleCloneCache(const std::string &bundleName, int32_t userId, 49 int32_t appCloneIndex, const std::vector<std::string> &moduleNames); 50 static ErrCode CleanBundleCache(const std::vector<std::tuple<std::string, 51 std::vector<std::string>, std::vector<int32_t>>> &validBundles, int32_t userId); 52 static ErrCode CleanAllBundleCache(const sptr<IProcessCacheCallback> processCacheCallback); 53 }; 54 } // AppExecFwk 55 } // OHOS 56 57 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_BUNDLE_CACHE_MGR_H